diff --git a/board/khadas/vim3/extlinux.conf b/board/khadas/vim3/extlinux.conf new file mode 100644 index 0000000000..fede99b502 --- /dev/null +++ b/board/khadas/vim3/extlinux.conf @@ -0,0 +1,4 @@ +default buildroot +label buildroot + kernel /Image +append root=/dev/mmcblk0p2 rootwait console=ttyAML0,115200 diff --git a/board/khadas/vim3/genimage.cfg b/board/khadas/vim3/genimage.cfg new file mode 100644 index 0000000000..79d7f9ca07 --- /dev/null +++ b/board/khadas/vim3/genimage.cfg @@ -0,0 +1,33 @@ +image boot.vfat { + vfat { + files = { + "Image", + "meson-g12b-a311d-khadas-vim3.dtb", + "extlinux" + } + + label = "boot" + } + + size = 64M +} + +image sdcard.img { + hdimage { + } + + partition boot { + partition-type = 0xC + bootable = "true" + image="boot.vfat" + size = 64M + offset = 2M + } + + partition rootfs { + partition-type = 0x83 + image = "rootfs.ext2" + size = 128M + offset = 0 + } +} diff --git a/board/khadas/vim3/post-build.sh b/board/khadas/vim3/post-build.sh new file mode 100755 index 0000000000..8dae08a47c --- /dev/null +++ b/board/khadas/vim3/post-build.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +BOARD_DIR="$(dirname "$0")" + +install -m 0644 -D "$BOARD_DIR"/extlinux.conf "$BINARIES_DIR"/extlinux/extlinux.conf diff --git a/board/khadas/vim3/post-image.sh b/board/khadas/vim3/post-image.sh new file mode 100755 index 0000000000..db38421494 --- /dev/null +++ b/board/khadas/vim3/post-image.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +BOARD_DIR="$(dirname "$0")" + +support/scripts/genimage.sh -c "${BOARD_DIR}/genimage.cfg" + +AMLOGIC_DIR=${BINARIES_DIR}/amlogic-boot-fip +FIP_DIR=${BINARIES_DIR}/fip + +mkdir -p "${FIP_DIR}" + +(cd "${AMLOGIC_DIR}" && \ + ./build-fip.sh khadas-vim3 \ + "${BINARIES_DIR}"/u-boot.bin \ + "${FIP_DIR}") + +dd if="${FIP_DIR}"/u-boot.bin.sd.bin \ + of="${BINARIES_DIR}"/sdcard.img \ + conv=fsync,notrunc bs=1 count=444 + +dd if="${FIP_DIR}"/u-boot.bin.sd.bin \ + of="${BINARIES_DIR}"/sdcard.img \ + conv=fsync,notrunc bs=512 skip=1 seek=1 diff --git a/board/khadas/vim3/readme.txt b/board/khadas/vim3/readme.txt new file mode 100644 index 0000000000..cc9b513644 --- /dev/null +++ b/board/khadas/vim3/readme.txt @@ -0,0 +1,71 @@ +Khadas VIM3 + +Description +=========== + +This configuration builds a complete image for the Khadas VIM3 to be flashed +on an SD-card. + +How to build it +=============== + +Select the default configuration for the target: +$ make khadas_vim3_defconfig + +Optional: modify the configuration: +$ make menuconfig + +Build: +$ make + +Result of the build +=================== +output/images/ ++-- amlogic-boot-fip ++ +-- build-fip.sh ++ +-- g12a.inc ++ `-- khadas-vim3 ++ +-- acs.bin ++ +-- acs_tool.py ++ +-- aml_ddr.fw ++ +-- aml_encrypt_g12b ++ +-- bl2.bin ++ +-- bl301.bin ++ +-- bl30.bin ++ +-- bl31.bin ++ +-- bl31.img ++ +-- blx_fix.sh ++ +-- ddr3_1d.fw ++ +-- ddr4_1d.fw ++ +-- ddr4_2d.fw ++ +-- diag_lpddr4.fw ++ +-- lpddr3_1d.fw ++ +-- lpddr4_1d.fw ++ +-- lpddr4_2d.fw ++ +-- Makefile ++ `-- piei.fw ++-- boot.vfat ++-- extlinux ++ `-- extlinux.conf ++-- fip ++ +-- u-boot.bin ++ +-- u-boot.bin.sd.bin ++ +-- u-boot.bin.usb.bl2 ++ `-- u-boot.bin.usb.tpl ++-- Image ++-- meson-g12b-a311d-khadas-vim3.dtb ++-- rootfs.ext2 ++-- rootfs.ext4 -> rootfs.ext2 ++-- rootfs.tar ++-- sdcard.img +`-- u-boot.bin + +The post-image script uses the files in the amlogic-boot-fip folder to sign +the bootloader image before integrating it into the sdcard image. + +To copy the image file to the sdcard use dd: +$ dd if=output/images/sdcard.img of=/dev/sdX + +Tested hardware +=============== +Khadas vim3 (rev. 14) diff --git a/configs/khadas_vim3_defconfig b/configs/khadas_vim3_defconfig new file mode 100644 index 0000000000..0a83883334 --- /dev/null +++ b/configs/khadas_vim3_defconfig @@ -0,0 +1,47 @@ +# Architecture +BR2_aarch64=y +BR2_cortex_a73_a53=y +BR2_ARM_FPU_VFPV4=y + +# Image +BR2_ROOTFS_POST_BUILD_SCRIPT="board/khadas/vim3/post-build.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/khadas/vim3/post-image.sh" + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.3" +BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y +BR2_LINUX_KERNEL_DTS_SUPPORT=y +BR2_LINUX_KERNEL_INTREE_DTS_NAME="amlogic/meson-g12b-a311d-khadas-vim3" +BR2_LINUX_KERNEL_INSTALL_TARGET=y + +# Linux headers same as kernel, a 6.3 series +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_3=y + +# Filesystem +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_ROOTFS_EXT2_4=y +BR2_TARGET_ROOTFS_EXT2_SIZE="128M" + +# Bootloader +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y +BR2_TARGET_UBOOT_CUSTOM_VERSION=y +BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2023.04" +BR2_TARGET_UBOOT_BOARD_DEFCONFIG="khadas-vim3" +BR2_TARGET_UBOOT_NEEDS_OPENSSL=y + +# Required tool to sign the bootloader image +BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP=y +BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE="khadas-vim3" + +# Required tools to create the SD image +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_HOST_GENIMAGE=y +BR2_PACKAGE_HOST_MTOOLS=y +BR2_PACKAGE_HOST_DOSFSTOOLS=y + +# Supporting host tools to build FIT image +# BR2_PACKAGE_HOST_UBOOT_TOOLS=y +# BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y