kumquat-buildroot/board/canaan/k210-soc/post-build.sh

29 lines
775 B
Bash
Raw Normal View History

board: Add common support for Canaan K210 SoC-based boards The Linux environment for all boards using the Canaan Kendryte K210 SoC can be built with the same process, using configurations that differ only by the device tree used for the build. This patch add the shared configurations, rootfs overlay and scripts used for all K210-based boards. Since the K210 SoC only has 8 MB of SRAM, a special busybox configuration and rootfs overlay are added to save memory at runtime: * For configurations using direct kernel boot (no boot loader), the default busybox configuration busybox-minimal.config is modified using the fragment file board/canaan/k210-soc/busybox-tiny.config. This reduces the size of the busybox executable to save memory when executing shell commands. * Busybox init system is not used and a special init scripts is provided using the rootfs_overlay root file system overlay. This init script simply mounts devtmpfs, /proc and /sys, and exec an interactive shell after printing a logo. This avoids (1) boot failures due to large memory allocations by the regular busybox init system (these allocations fail on the K210 for lack of enough memory) and avoids (2) keeping the init process sleeping in the background (wasted memory). The board/canaan/k210-soc/busybox-tiny.config and the rootfs overlay files in board/canaan/k210-soc/rootfs_overlay are used for all Canaan K210 SoC based boards. For board configurations booting using the U-Boot boot loader, a common set of linux kernel configuration parameters is provided by the file board/canaan/k210-soc/linux-sdcard.config. In addition, the post build script board/canaan/k210-soc/post-build.sh file and U-Boot image generation configuration file board/canaan/k210-soc/genimage.cfg are provided. The post-build script creates a generic "k210.dtb" symlink to the compiled device tree file for the target board. This symlink is used by the genimage.cfg configuration, making this file common for all boards. Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2022-07-20 04:45:26 +02:00
#!/bin/sh
MKIMAGE=${HOST_DIR}/bin/mkimage
# Generate u-Boot kernel image
${MKIMAGE} -A riscv -O linux -T kernel -C none \
-a 0x80000000 -e 0x80000000 \
-n Linux -d ${BINARIES_DIR}/loader.bin ${BINARIES_DIR}/uImage
# Link the kernel-built board dtb file to using the k210.dtb generic
# name for use by genimage.cfg
BOARDDTBKPATH="$(grep BR2_LINUX_KERNEL_INTREE_DTS_NAME ${BR2_CONFIG} | cut -d'=' -f2 | tr -d \")"
BOARDDTB="$(basename ${BOARDDTBKPATH})"
if [ -z "${BOARDDTB}" ]; then
echo "Board DTB file not specified"
exit 1
fi
BOARDDTB="${BINARIES_DIR}/${BOARDDTB}.dtb"
if [ ! -f "${BOARDDTB}" ]; then
echo "Board DTB file not found in ${BINARIES_DIR}"
exit 1
fi
TARGETDTB=${BINARIES_DIR}/k210.dtb
rm -f ${TARGETDTB}
ln -s ${BOARDDTB} ${TARGETDTB}