作者| aaron.feng
本期技术专题分享如何单独编译kernel以及替换升级kernel image。
Android kernel 编译的config由两部分构成:
GKI_DEFCONFIG(Android通用config):
vendor/sigmastar/alkaid/kernel/common/arch/arm64/configs/gki_defconfig 平台
FRAGMENT_CONFIG(芯片平台config):
vendor/sigmastar/alkaid/kernel/common/arch/arm64/configs/pioneer5_android_gki.fragment
这两个config在Kernel vendor/sigmastar/alkaid/kernel/common/build.config.pioneer5_android_gki中指定:
GKI_DEFCONFIG=${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/gki_defconfig
DEFCONFIG=pioneer5_gki_defconfig
FRAGMENT_CONFIG=${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/pioneer5_android_gki.fragment
Kernel build config在device/sigmastar/pioneer5/kernel/BoardKernelConfig.mk中指定:
SSTAR_KERNEL_BUILD_CONFIG := build.config.pioneer5_android_gki
编译的过程中由vendor/sigmastar/alkaid/kernel/build/build.sh 通过如下py合成一个DEFCONFIG:pioneer5_gki_defconfig
if [ -n "${PRE_DEFCONFIG_CMDS}" ]; then
echo "========================================================"
echo " Running pre-defconfig command(s):"
set -x
eval ${PRE_DEFCONFIG_CMDS}
set +x
fi
PRE_DEFCONFIG_CMDS在build.config.pioneer5_android_gki中指定:
PRE_DEFCONFIG_CMDS="KCONFIG_CONFIG=${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG} ${ROOT_DIR}/${KERNEL_DIR}/scripts/kconfig/merge_config.sh -m -r ${GKI_DEFCONFIG} ${FRAGMENT_CONFIG}"
POST_DEFCONFIG_CMDS="rm ${ROOT_DIR}/${KERNEL_DIR}/arch/arm64/configs/${DEFCONFIG}"
其中PRE_DEFCONFIG_CMDS在make defconfig前执行,POST_DEFCONFIG_CMDS在make defconfig之后执行,具体细看build.sh脚本。
如何单独编译kernel?
修改完上述编译config后,在aosp目录执行如下命令单独编译kernel:
./sstar_make.sh -k -a
编译完成后,在编译生成的image目录:out/target/product/pioneer5_sdp,直接单独烧录boot.img即可。
修改kernel build in 模块替换boot.img
修改dtb文件替换vendor_boot.img
修改dtbo文件替换dtbo.img kernel ko生成的image参考device\sigmastar\pioneer5\pioneer5_sdp\BoardConfig.mk:
# Kernel modules
TARGET_KERNEL_DIR := device/sigmastar/pioneer5/kernel
BOARD_VENDOR_RAMDISK_KERNEL_MODULES := \
$(TARGET_KERNEL_DIR)/kdrv_emmc.ko \
$(TARGET_KERNEL_DIR)/sstar_padmux.ko \
$(TARGET_KERNEL_DIR)/sstar_pwm.ko \
$(TARGET_KERNEL_DIR)/pwm_bl.ko
# $(TARGET_KERNEL_DIR)/sstar_voltage_ctrl.ko \
# $(TARGET_KERNEL_DIR)/dummy_battery.ko
# To limit /vendor/lib/modules to just the ones loaded
BOARD_VENDOR_KERNEL_MODULES := $(filter-out \
$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES),$(wildcard $(TARGET_KERNEL_DIR)/*.ko))
TARGET_KERNEL_DIR目录下面的ko,其中BOARD_VENDOR_RAMDISK_KERNEL_MODULES中的ko生成在vendor_boot.img,其他的生成在vendor.img中。
》》原帖地址
End.
往期回顾
串口应用参数设置说明
SSD21X/22X如何支持USB转Ethernet?
RTOS下如何定位TTL屏颜色显示不对的问题?
如何搭建USB RNDIS并使用RTSP出流?
RTOS如何适配USB Host?
扫码进入论坛
原厂答疑|产品选型|官方资源
扫码咨询客服
SDK下载|芯片、开发板购买