本文讲述如何修改内核配置等基础修改
vendor/hihope/rk3568
device/board/hihope/rk3568
device/soc/rockchip/rk3568
base/startup/init_lite/servcies/etc/param/ohos.para
这个设置修改的是设置->设备信息中的内容
const.actionable_compatible_property.enabled=false
const.postinstall.fstab.prefix=/system
const.secure=1
security.perf_harden=1
const.allow.mock.location=0
const.debuggable=1
const.build.characteristics=default
const.product.model=test3568
const.product.name="这里写设备名字"
persist.sys.usb.config=hdc
const.sandbox=enable
const.product.devicetype=M3568
const.software.model=default
const.product.manufacturer=这里写公司名字
const.product.brand=default
const.build.product=default
const.product.hardwareversion=default
const.product.bootloader.version=bootloader
const.product.cpu.abilist=default
const.product.software.version=这里写固件名字
const.product.incremental.version=default
const.product.firstapiversion=1
const.product.build.type=default
const.product.build.user=default
const.product.build.host=default
const.product.build.date=default
const.product.hardwareprofile=default
const.ohos.buildroothash=default
vendor/hihope/rk3568/config.json
我们不需要使用ramdisk进行初始化,找到enable_ramdisk,改为false
"enable_ramdisk": false,
可以参考paramter.txt
FIRMWARE_VER:11.0
MACHINE_MODEL:rk3568_r
MACHINE_ID:007
MANUFACTURER: rockchip
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: rk3568_r
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
CMDLINE:mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00030000@0x00008000(boot),0x00002000@0x00038000(resource),0x00002000@0x0003A000(misc),0x000010000@0x0003C000(updater),0x100000@0x004C000(vendor),0x00400000@0x0014C000(system),-@0x0054C000(userdata:grow)
uuid:system=614e0000-0000-4b53-8000-1d28000054a9
uuid:boot=a2d37d82-51e0-420d-83f5-470db993dd35
uuid:userdata=8b13db99-110a-41c2-b16b-dfd44d7ebeca
uboot:uboot第二部分分区,烧写uboot.img
boot:kernel的分区,同样包含了设备树,烧写boot.img
resource:烧写resource.img,里面包含了logo
misc:空分区,但是以后可能胡有用
updater:存放updater的分区,未验证,烧写update.img
vendor:存放产商相关代码,烧写vendor.img
system:存放OHOS本身系统代码的分区,烧写sysytem.img
userdata:存放用户数据的分区,剩下的空间都给它,烧写userdata.img
除此以外,还需要MiniLoaderAll.bin和paramter.txt本身。
./build.sh --product-name rk3568 --ccache
cp ./out/kernel/src_tmp/linux-5.10 ../ohos-kernel -r
进入到刚才复制出来的kernel文件夹中,执行以下命令,完成git仓库的初始化
#初始化文件夹作为git仓库
git init
#git全局配置
git config --global user.name "yourname"
git config --global user.email "youremail"
#进行第一次提交代码
git add -A
git commit -m 'frist commit'
(1) 把自己的设备树放到ohos-kernel/arch/arm64/boot/dts/rockchip
下
注:设备树一定需要include rk3568-linux.dtsi文件
(2) 修改make-ohos.sh
假设这里我们最终需要生成的设备树文件为my3568-board-linux.dtb
#!/bin/bash
set -e
export PATH=../../../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/:$PATH
export PRODUCT_PATH=vendor/hihope/rk3568
IMAGE_SIZE=64 # 64M
IMAGE_BLOCKS=4096
CPUs=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
MAKE="make CROSS_COMPILE=../../../../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-"
BUILD_PATH=boot_linux
EXTLINUX_PATH=${BUILD_PATH}/extlinux
EXTLINUX_CONF=${EXTLINUX_PATH}/extlinux.conf
#TOYBRICK_DTB=toybrick.dtb
MY3568_DTB=my3568-board-linux.dtb
if [ ${KBUILD_OUTPUT} ]; then
OBJ_PATH=${KBUILD_OUTPUT}/
fi
ID_MODEL=1
ID_ARCH=2
ID_UART=3
ID_DTB=4
ID_IMAGE=5
ID_CONF=6
model_list=(
"TB-RK3568X0 arm64 0xfe660000 rk3568-toybrick-x0-linux Image rockchip_linux_defconfig"
"TB-RK3568X10 arm64 0xfe660000 rk3568-toybrick-x10-linux Image rockchip_linux_defconfig"
"MYBOARD3568 arm64 0xfe660000 my3568-board-linux Image rockchip_linux_defconfig"
)
function help()
{
echo "Usage: ./make-ohos.sh {BOARD_NAME}"
echo "e.g."
for i in "${model_list[@]}"; do
echo " ./make-ohos.sh $(echo $i | awk '{print $1}')"
done
}
function make_extlinux_conf()
{
dtb_path=$1
uart=$2
image=$3
echo "label rockchip-kernel-5.10" > ${EXTLINUX_CONF}
echo " kernel /extlinux/${image}" >> ${EXTLINUX_CONF}
#echo " fdt /extlinux/${TOYBRICK_DTB}" >> ${EXTLINUX_CONF}
echo " fdt /extlinux/${MY3568_DTB}" >> ${EXTLINUX_CONF}
cmdline="append earlycon=uart8250,mmio32,${uart} root=PARTUUID=614e0000-0000-4b53-8000-1d28000054a9 rw rootwait rootfstype=ext4"
echo " ${cmdline}" >> ${EXTLINUX_CONF}
}
function make_kernel_image()
{
arch=$1
conf=$2
dtb=$3
${MAKE} ARCH=${arch} ${conf}
if [ $? -ne 0 ]; then
echo "FAIL: ${MAKE} ARCH=${arch} ${conf}"
return -1
fi
${MAKE} ARCH=${arch} ${dtb}.img -j${CPUs}
if [ $? -ne 0 ]; then
echo "FAIL: ${MAKE} ARCH=${arch} ${dtb}.img"
return -2
fi
return 0
}
function make_ext2_image()
{
blocks=${IMAGE_BLOCKS}
block_size=$((${IMAGE_SIZE} * 1024 * 1024 / ${blocks}))
if [ "`uname -m`" == "aarch64" ]; then
echo y | sudo mke2fs -b ${block_size} -d boot_linux -i 8192 -t ext2 boot_linux.img ${blocks}
else
genext2fs -B ${blocks} -b ${block_size} -d boot_linux -i 8192 -U boot_linux.img
fi
return $?
}
function make_boot_linux()
{
arch=${!ID_ARCH}
uart=${!ID_UART}
dtb=${!ID_DTB}
image=${!ID_IMAGE}
conf=${!ID_CONF}
if [ ${arch} == "arm" ]; then
dtb_path=arch/arm/boot/dts
else
dtb_path=arch/arm64/boot/dts/rockchip
fi
rm -rf ${BUILD_PATH}
mkdir -p ${EXTLINUX_PATH}
make_kernel_image ${arch} ${conf} ${dtb}
if [ $? -ne 0 ]; then
exit 1
fi
make_extlinux_conf ${dtb_path} ${uart} ${image}
cp -f ${OBJ_PATH}arch/${arch}/boot/${image} ${EXTLINUX_PATH}/
#cp -f ${OBJ_PATH}${dtb_path}/${dtb}.dtb ${EXTLINUX_PATH}/${TOYBRICK_DTB}
cp -f ${OBJ_PATH}${dtb_path}/${dtb}.dtb ${EXTLINUX_PATH}/${MY3568_DTB}
cp -f logo*.bmp ${BUILD_PATH}/
if [ "enable_ramdisk" != "${ramdisk_flag}" ]; then
make_ext2_image
fi
}
ramdisk_flag=$2
found=0
for i in "${model_list[@]}"; do
if [ "$(echo $i | awk '{print $1}')" == "$1" ]; then
make_boot_linux $i
found=1
fi
done
注意:尽量不要在这份代码中编译!,否则产生的日志文件过大,可以复制一份去尝试编译
假设我们做了若干次修改后,我们使用git log
命令去查看提交的日志(因为我的源码里面日志比较敏感,就不全放了)
假设第一次提交,也就是first commit的日志id为 8148df7c6fdc0bfc5f7549c0eae011043320a461
,最新提交的日志id为fd459ec617481a6d3b6ae6b311c58cc9f95ea38d
,
那么就是git diff 8148df7c6fdc0bfc5f7549c0eae011043320a461 fd459ec617481a6d3b6ae6b311c58cc9f95ea38d > 0001-fixed-kernel-for-myboard.patch
然后移植到SDK中,这里建议用mv,防止下次生成补丁的时候,把补丁文件本身也生成进去
mv 0001-fixed-kernel-for-myboard.patch /home/fenix/SDK/kernel/linux/patches/linux-5.10/rk3568_patch
device/board/hihope/rk3568/kernel/build_kernel.h
增加编译时候对补丁的调用,并更改编译内核的目标板子为我们自己的
...
KERNEL_PATCHES="${ROOT_DIR}/kernel/linux/patches/linux-5.10/rk3568_patch/kernel.patch
${ROOT_DIR}/kernel/linux/patches/linux-5.10/rk3568_patch/0001-fix-m3568.patch"
...
#HDF patch
bash ${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh ${ROOT_DIR} ${KERNEL_SRC_TMP_PATH} ${HDF_PATCH}
#kernel patch
for KERNEL_PATCH in $KERNEL_PATCHES
do
patch -p1 < ${KERNEL_PATCH}
done
....
if [ "enable_ramdisk" == "${9}" ]; then
#./make-ohos.sh TB-RK3568X0 enable_ramdisk
./make-ohos.sh MYBOARD3568 enable_ramdisk
else
#./make-ohos.sh TB-RK3568X0 disable_ramdisk
./make-ohos.sh MYBOARD3568 disable_ramdisk
fi
这个不用我教了吧
下一篇:[OpenHarmony RK3568] (三)蓝牙芯片适配