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
??https://harmonyos.51cto.com??