mirror of
git://git.yoctoproject.org/meta-rockchip.git
synced 2025-07-05 05:04:47 +02:00

The upstream kernel reorganized the 32-bit arch/arm device-tree directory structure to separate out the device-trees by manufacturer (similar to the organization of the arch/arm64 device-trees). Update the references to 32-bit arm device-trees to match. This patch can now be applied since all pre-6.5-rc1 kernels have been removed from oe-core. NOTE: trying to build a post-6.5-rc1 32-bit kernel with this patch applied will fail Signed-off-by: Trevor Woerner <twoerner@gmail.com> Signed-off-by: Stephen Chen <stephen@radxa.com>
150 lines
4.9 KiB
Plaintext
150 lines
4.9 KiB
Plaintext
# Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd
|
|
# Copyright (C) 2017 Trevor Woerner <twoerner@gmail.com>
|
|
# Released under the MIT license (see COPYING.MIT for the terms)
|
|
|
|
inherit image_types
|
|
|
|
# Use an uncompressed ext4 by default as rootfs
|
|
IMG_ROOTFS_TYPE = "ext4"
|
|
IMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${IMG_ROOTFS_TYPE}"
|
|
|
|
# This image depends on the rootfs image
|
|
IMAGE_TYPEDEP:rockchip-gpt-img = "${IMG_ROOTFS_TYPE}"
|
|
|
|
GPTIMG = "${IMAGE_NAME}-gpt.img"
|
|
GPTIMG_SYMLK = "${IMAGE_BASENAME}-${MACHINE}-gpt.img"
|
|
GPTIMG_SIZE ?= "4096"
|
|
BOOT_IMG = "boot.img"
|
|
BOOTIMG_SYMLK = "${IMAGE_BASENAME}-${MACHINE}-${BOOT_IMG}"
|
|
MINILOADER = "loader.bin"
|
|
UBOOT = "u-boot.out"
|
|
TRUST = "trust.out"
|
|
GPTIMG_APPEND ?= "console=tty1 console=ttyS2,115200n8 rw root=/dev/mmcblk2p7 rootfstype=ext4 init=/sbin/init"
|
|
|
|
# default partitions [in Sectors]
|
|
# More info at http://rockchip.wikidot.com/partitions
|
|
LOADER1_SIZE = "8000"
|
|
RESERVED1_SIZE = "128"
|
|
RESERVED2_SIZE = "8192"
|
|
LOADER2_SIZE = "8192"
|
|
ATF_SIZE = "8192"
|
|
BOOT_SIZE = "229376"
|
|
|
|
do_image_rockchip_gpt_img[depends] = "parted-native:do_populate_sysroot \
|
|
u-boot-mkimage-native:do_populate_sysroot \
|
|
mtools-native:do_populate_sysroot \
|
|
dosfstools-native:do_populate_sysroot \
|
|
virtual/kernel:do_deploy \
|
|
virtual/bootloader:do_deploy"
|
|
|
|
PER_CHIP_IMG_GENERATION_COMMAND:rk3288 = "generate_rk3288_loader1_image"
|
|
PER_CHIP_IMG_GENERATION_COMMAND:rock2-square = "generate_rock2_loader1_image"
|
|
|
|
IMAGE_CMD:rockchip-gpt-img () {
|
|
# Change to image directory
|
|
cd ${DEPLOY_DIR_IMAGE}
|
|
|
|
# Remove the existing image symlinks
|
|
rm -f "${GPTIMG_SYMLK}"
|
|
rm -f "${BOOTIMG_SYMLK}"
|
|
|
|
create_rk_image
|
|
|
|
${PER_CHIP_IMG_GENERATION_COMMAND}
|
|
|
|
# create symlink to full GPT image
|
|
cd ${DEPLOY_DIR_IMAGE}
|
|
ln -s ${GPTIMG} ${GPTIMG_SYMLK}
|
|
|
|
# create per-build boot.img with symlink
|
|
cd ${DEPLOY_DIR_IMAGE}
|
|
rm -f ${IMAGE_NAME}-boot.img
|
|
if [ -f ${WORKDIR}/${BOOT_IMG} ]; then
|
|
cp ${WORKDIR}/${BOOT_IMG} ${IMAGE_NAME}-boot.img
|
|
fi
|
|
ln -s ${IMAGE_NAME}-boot.img ${BOOTIMG_SYMLK}
|
|
}
|
|
|
|
create_rk_image () {
|
|
|
|
# Initialize sdcard image file
|
|
dd if=/dev/zero of=${GPTIMG} bs=1M count=0 seek=${GPTIMG_SIZE}
|
|
|
|
# Create partition table
|
|
parted -s ${GPTIMG} mklabel gpt
|
|
|
|
# Create vendor defined partitions
|
|
LOADER1_START=64
|
|
RESERVED1_START=`expr ${LOADER1_START} + ${LOADER1_SIZE}`
|
|
RESERVED2_START=`expr ${RESERVED1_START} + ${RESERVED1_SIZE}`
|
|
LOADER2_START=`expr ${RESERVED2_START} + ${RESERVED2_SIZE}`
|
|
ATF_START=`expr ${LOADER2_START} + ${LOADER2_SIZE}`
|
|
BOOT_START=`expr ${ATF_START} + ${ATF_SIZE}`
|
|
ROOTFS_START=`expr ${BOOT_START} + ${BOOT_SIZE}`
|
|
|
|
parted -s ${GPTIMG} unit s mkpart loader1 ${LOADER1_START} `expr ${RESERVED1_START} - 1`
|
|
parted -s ${GPTIMG} unit s mkpart reserved1 ${RESERVED1_START} `expr ${RESERVED2_START} - 1`
|
|
parted -s ${GPTIMG} unit s mkpart reserved2 ${RESERVED2_START} `expr ${LOADER2_START} - 1`
|
|
parted -s ${GPTIMG} unit s mkpart loader2 ${LOADER2_START} `expr ${ATF_START} - 1`
|
|
parted -s ${GPTIMG} unit s mkpart atf ${ATF_START} `expr ${BOOT_START} - 1`
|
|
|
|
# Create boot partition and mark it as bootable
|
|
parted -s ${GPTIMG} unit s mkpart boot ${BOOT_START} `expr ${ROOTFS_START} - 1`
|
|
parted -s ${GPTIMG} set 6 boot on
|
|
|
|
# Create rootfs partition
|
|
parted -s ${GPTIMG} unit s mkpart root ${ROOTFS_START} 100%
|
|
|
|
parted ${GPTIMG} print
|
|
|
|
# Delete the boot image to avoid trouble with the build cache
|
|
rm -f ${WORKDIR}/${BOOT_IMG}
|
|
|
|
# Create boot partition image
|
|
BOOT_BLOCKS=$(LC_ALL=C parted -s ${GPTIMG} unit b print | awk '/ 6 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
|
|
BOOT_BLOCKS=`expr $BOOT_BLOCKS / 63 \* 63`
|
|
|
|
mkfs.vfat -n "boot" -S 512 -C ${WORKDIR}/${BOOT_IMG} $BOOT_BLOCKS
|
|
mcopy -i ${WORKDIR}/${BOOT_IMG} -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::${KERNEL_IMAGETYPE}
|
|
|
|
DEVICETREE_DEFAULT=""
|
|
for DTS_FILE in $(echo ${KERNEL_DEVICETREE} | cut -d'/' -f2); do
|
|
[ -n "${DEVICETREE_DEFAULT}"] && DEVICETREE_DEFAULT="${DTS_FILE}"
|
|
mcopy -i ${WORKDIR}/${BOOT_IMG} -s ${DEPLOY_DIR_IMAGE}/${DTS_FILE} ::${DTS_FILE}
|
|
done
|
|
|
|
# Create extlinux config file
|
|
cat > ${WORKDIR}/extlinux.conf <<EOF
|
|
default yocto
|
|
|
|
label yocto
|
|
kernel /${KERNEL_IMAGETYPE}
|
|
devicetree /${DEVICETREE_DEFAULT}
|
|
append ${GPTIMG_APPEND}
|
|
EOF
|
|
|
|
mmd -i ${WORKDIR}/${BOOT_IMG} ::/extlinux
|
|
mcopy -i ${WORKDIR}/${BOOT_IMG} -s ${WORKDIR}/extlinux.conf ::/extlinux/
|
|
|
|
# Burn Boot Partition
|
|
dd if=${WORKDIR}/${BOOT_IMG} of=${GPTIMG} conv=notrunc,fsync seek=${BOOT_START}
|
|
|
|
# Burn Rootfs Partition
|
|
dd if=${IMG_ROOTFS} of=${GPTIMG} seek=${ROOTFS_START}
|
|
|
|
}
|
|
|
|
generate_rk3288_loader1_image () {
|
|
|
|
dd if=${DEPLOY_DIR_IMAGE}/idbloader.img-${MACHINE} of=${GPTIMG} conv=notrunc,fsync seek=64
|
|
dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.bin of=${GPTIMG} conv=notrunc,fsync seek=16384
|
|
|
|
}
|
|
|
|
generate_rock2_loader1_image () {
|
|
# Burn bootloader
|
|
mkimage -n rk3288 -T rksd -d ${DEPLOY_DIR_IMAGE}/${SPL_BINARY} ${WORKDIR}/${UBOOT}
|
|
cat ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.bin >> ${WORKDIR}/${UBOOT}
|
|
dd if=${WORKDIR}/${UBOOT} of=${GPTIMG} conv=notrunc,fsync seek=64
|
|
}
|