OpenHarmony中Linux内核手动编译调试解读
https://harmonyos.51cto.com
一、OpenHarmony手动编译Linux内核
1.首次编译标准系统
./build.sh --product-name Hi3516DV300 --ccache
2.编译完成在编译的内核
在OpenHarmony-v3.1-Beta/out/KERNEL_OBJ/kernel/src_tmp/linux-5.10目录下
配置编译环境变量
export OHOS_ROOT=/home/weimin/OpenHarmony/OpenHarmony-v3.1-Beta
export PATH=$OHOS_ROOT/prebuilts/clang/ohos/linux-x86_64/llvm/bin:$PATH
export PATH=$OHOS_ROOT/prebuilts/gcc/linux-x86/arm/gcc-linaro-7.5.0-arm-linux-gnueabi/bin:$PATH
export MAKE_OPTIONS="ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- CC=clang HOSTCC=clang"
export PRODUCT_PATH=vendor/hisilicon/Hi3516DV300
编译内核
make ${MAKE_OPTIONS} menuconfig hi3516dv300_standard_defconfig
或者
make ${MAKE_OPTIONS} menuconfig hi3516dv300_small_defconfig
make ${MAKE_OPTIONS} uImage
编译完成在out/KERNEL_OBJ/kernel/src_tmp/linux-5.10/arch/arm/boot目录下生成uImage,zImage-dtb,zImage和Image等镜像文件。
二、手动打包ramdisk镜像
进入ramdisk的文件目录执行如下命令:
进入ramdisk的文件目录执行如下命令:
find . | cpio -c -o -v |gzip >../ramdisk.img
三、打包ramdisk.img和zImage-dtb生成boot.img
ohos.its文件内容如下:
/dts-v1/;
/ {
description = "U-Boot uImage source file for Hi3516DV300";
#address-cells = <1>;
images {
kernel@1 {
description = "Linux kernel for Hi3516DV300";
data = /incbin/("./zImage-dtb");
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0x82000000>;
entry = <0x82000000>;
};
ramdisk@1 {
description = "ohos Ramdisk Image";
data = /incbin/("./ramdisk.img");
type = "ramdisk";
arch = "arm";
os = "linux";
compression = "none";
load = <0x84000000>;
entry = <0x84000000>;
};
};
configurations {
default = "conf@boot";
conf@boot {
description = "booting ARM Linux Kernel Image";
kernel = "kernel@1";
ramdisk = "ramdisk@1";
};
};
};
data = /incbin/(“./zImage-dtb”);指定zImage文件的路径
data = /incbin/(“./ramdisk.img”); 指定ramdisk文件的路径
如果ohos.its没有修改,将ohos.its、ramdisk.img和zImage-dtb文件放入同一目录下,执行下面命令生成boot.img:
mkimage -f ohos.its boot.img
© 版权声明
文章版权归作者所有,未经允许请勿转载。