From a964f6ea27db1de4441b15ac440b236921a8d88a Mon Sep 17 00:00:00 2001 From: Justin Hammond Date: Mon, 6 Mar 2023 15:43:27 +0800 Subject: [PATCH] DTB Overlay Support and extlinux.conf (#43) --- .github/workflows/buildroot.yml | 7 ++---- README.md | 4 ++-- board/pine64/ox64/genimage.cfg | 3 +++ ...ariables-for-extlinux-loading-to-wor.patch | 22 +++++++++++++++++++ board/pine64/ox64/post-build.sh | 9 ++++---- .../boot/extlinux/extlinux.conf | 12 ++++++++++ .../ox64/rootfs-overlay/root/README!!!!.txt | 12 ++++++---- board/pine64/ox64/uboot_defconfig | 5 +++++ 8 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 board/pine64/ox64/patches/uboot/0002-add-a-few-more-variables-for-extlinux-loading-to-wor.patch create mode 100644 board/pine64/ox64/rootfs-overlay/boot/extlinux/extlinux.conf diff --git a/.github/workflows/buildroot.yml b/.github/workflows/buildroot.yml index a2c0f26..03945b2 100644 --- a/.github/workflows/buildroot.yml +++ b/.github/workflows/buildroot.yml @@ -73,8 +73,7 @@ jobs: echo "DTB=${{ github.workspace }}/buildroot/output/images/bl808-*.dtb" >> $GITHUB_ENV echo "OPENSBI=${{ github.workspace }}/buildroot/output/images/fw_jump.bin" >> $GITHUB_ENV echo "LOWLOAD=${{ github.workspace }}/buildroot/output/images/*_lowload_bl808_*.bin" >> $GITHUB_ENV - echo "WHOLEBINOX=${{ github.workspace }}/buildroot/output/images/pine64-ox64-firmware.bin" >> $GITHUB_ENV - echo "WHOLEBINM1=${{ github.workspace }}/buildroot/output/images/sispeed-m1s-firmware.bin" >> $GITHUB_ENV + echo "WHOLEBINOX=${{ github.workspace }}/buildroot/output/images/bl808-firmware.bin" >> $GITHUB_ENV echo "BRSDK=${{ github.workspace }}/buildroot/output/images/riscv*.tar.gz" >> $GITHUB_ENV - name: Upload package uses: actions/upload-artifact@master @@ -87,7 +86,6 @@ jobs: ${{env.OPENSBI}} ${{env.LOWLOAD}} ${{env.WHOLEBINOX}} - ${{env.WHOLEBINM1}} - name: Upload sdk if: matrix.target == 'pine64_ox64_full_defconfig' uses: actions/upload-artifact@master @@ -123,8 +121,7 @@ jobs: mv Image-${{ matrix.target }}.lz4 Image.lz4 mkdir firmware cp *_lowload_bl808_*.bin firmware/ - cp pine64-ox64-firmware.bin firmware/ - cp sispeed-m1s-firmware.bin firmware/ + cp bl808-firmware.bin firmware/ cp sdcard-${{ matrix.target }}.img.xz firmware/ tar -czvf bl808-linux-${{ matrix.target }}.tar.gz firmware echo "FIRMWARE=${{ github.workspace }}/build/bl808-linux-${{ matrix.target }}.tar.gz" >> $GITHUB_ENV diff --git a/README.md b/README.md index 14cf5f7..2dad27f 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The SD card images are configured with a 1Gb Swap Partition, and will resize the Inside the downloads you will find the following files: * m0_lowload_bl808_m0.bin - This firmware runs on M0 and forwards interupts to the D0 for several peripherals * d0_lowload_bl808_d0.bin - This is a very basic bootloader that loads opensbi, the kernel and dts files into ram -* pine64-ox64-firmware.bin/sispeed-m1s-firmware.bin - A image containing OpenSBI, the Kernel and DTS files for Pine64 OX64 and SiSpeed M1S Dock +* bl808-firmware.bin - A image containing OpenSBI, Uboot and uboot dtb files. * sdcard-*.tar.xz - A tarball containing the rootfs for the image to be flashed to the SD card ### Development images @@ -51,7 +51,7 @@ Download your prefered image above and extract the files. - D0 Group[Group0] Image Addr [0x58100000] [PATH to d0_low_load_bl808_d0.bin] - Click 'Create & Download' and wait until it's done - Switch to [IOT] page -- Enable 'Single Download', set Address with 0x800000, choose [PATH to pine64-ox64-firmware.bin/sispeed-m1s-firmware.bin] (depending on your board) +- Enable 'Single Download', set Address with 0x800000, choose [bl808-firmware.bin] - Click 'Create & Download' again and wait until it's done - flash the sdcard-pine64-*.img.xz to your SD card (you can use dd (after uncompressing) or https://github.com/balena-io/etcher) - Serial Console access: diff --git a/board/pine64/ox64/genimage.cfg b/board/pine64/ox64/genimage.cfg index 748403f..267017f 100644 --- a/board/pine64/ox64/genimage.cfg +++ b/board/pine64/ox64/genimage.cfg @@ -8,6 +8,9 @@ image boot.vfat { "boot-m1s.scr", "boot-pine64.scr", } + file "extlinux/extlinux.conf" { + image = "extlinux/extlinux.conf" + } } size = 200M } diff --git a/board/pine64/ox64/patches/uboot/0002-add-a-few-more-variables-for-extlinux-loading-to-wor.patch b/board/pine64/ox64/patches/uboot/0002-add-a-few-more-variables-for-extlinux-loading-to-wor.patch new file mode 100644 index 0000000..d0258f7 --- /dev/null +++ b/board/pine64/ox64/patches/uboot/0002-add-a-few-more-variables-for-extlinux-loading-to-wor.patch @@ -0,0 +1,22 @@ +From da8f2c5011a1783d3458b42d49b274e935fb80f9 Mon Sep 17 00:00:00 2001 +From: Justin Hammond +Date: Sat, 4 Mar 2023 15:53:10 +0800 +Subject: [PATCH] add a few more variables for extlinux loading to work + +--- +diff --git a/include/configs/bl808.h b/include/configs/bl808.h +index 976640894d..5de6947958 100644 +--- a/include/configs/bl808.h ++++ b/include/configs/bl808.h +@@ -46,7 +46,10 @@ + + #define CFG_EXTRA_ENV_SETTINGS \ + "scriptaddr=0x50000000\0" \ +- BOOTENV ++ "kernel_addr_r=0x50200000\0" \ ++ "fdt_addr_r=0x51ff8000\0" \ ++ "fdtoverlay_addr_r=0x52008000\0" \ ++ BOOTENV + #endif + + #endif /* __CONFIG_H */ diff --git a/board/pine64/ox64/post-build.sh b/board/pine64/ox64/post-build.sh index f11c238..04de884 100755 --- a/board/pine64/ox64/post-build.sh +++ b/board/pine64/ox64/post-build.sh @@ -1,18 +1,17 @@ #!/bin/sh -#echo "Compressing Kernel Image" -#lz4 -9 -f $BINARIES_DIR/Image $BINARIES_DIR/Image.lz4 echo "Compressing UBoot Image" lz4 -9 -f $BINARIES_DIR/u-boot.bin $BINARIES_DIR/u-boot.bin.lz4 cd $BINARIES_DIR -echo "Creating OpenSBI/DTB/Kernel Image" -$BR2_EXTERNAL_BOUFFALO_BR_PATH/board/pine64/ox64/mergebin.py -o pine64-ox64-firmware.bin -k u-boot.bin.lz4 -d u-boot.dtb -s fw_jump.bin -$BR2_EXTERNAL_BOUFFALO_BR_PATH/board/pine64/ox64/mergebin.py -o sispeed-m1s-firmware.bin -k u-boot.bin.lz4 -d u-boot.dtb -s fw_jump.bin +echo "Creating OpenSBI/DTB/Uboot Image" +$BR2_EXTERNAL_BOUFFALO_BR_PATH/board/pine64/ox64/mergebin.py -o bl808-firmware.bin -k u-boot.bin.lz4 -d u-boot.dtb -s fw_jump.bin echo "Copying Boot Script" $BINARIES_DIR/../host/bin/mkimage -C none -A riscv -T script -d $BR2_EXTERNAL_BOUFFALO_BR_PATH/board/pine64/ox64/boot-m1s.cmd $BINARIES_DIR/boot-m1s.scr $BINARIES_DIR/../host/bin/mkimage -C none -A riscv -T script -d $BR2_EXTERNAL_BOUFFALO_BR_PATH/board/pine64/ox64/boot-pine64.cmd $BINARIES_DIR/boot-pine64.scr cp $BINARIES_DIR/boot-pine64.scr $BINARIES_DIR/boot.scr cp $BINARIES_DIR/*.scr $TARGET_DIR/boot/ cp $BR2_EXTERNAL_BOUFFALO_BR_PATH/board/pine64/ox64/*.cmd $TARGET_DIR/boot/ +mkdir -p $BINARIES_DIR/extlinux/ +cp $TARGET_DIR/boot/extlinux/* $BINARIES_DIR/extlinux/ echo "Creating Filesystem Image" $BASE_DIR/../support/scripts/genimage.sh -c $BR2_EXTERNAL_BOUFFALO_BR_PATH/board/pine64/ox64/genimage.cfg echo "Completed - Images are at $BINARIES_DIR" diff --git a/board/pine64/ox64/rootfs-overlay/boot/extlinux/extlinux.conf b/board/pine64/ox64/rootfs-overlay/boot/extlinux/extlinux.conf new file mode 100644 index 0000000..b181544 --- /dev/null +++ b/board/pine64/ox64/rootfs-overlay/boot/extlinux/extlinux.conf @@ -0,0 +1,12 @@ +# Generic Distro Configuration file generated by OpenEmbedded +menu title Select the boot mode +TIMEOUT 30 +DEFAULT Pine64 OX64 Kernel +LABEL Pine64 0X64 Kernel + KERNEL ../Image + FDT ../bl808-pine64-ox64.dtb + APPEND root=PARTLABEL=rootfs rootwait rw rootfstype=ext4 console=ttyS0,2000000 loglevel=8 earlycon=sbi +LABEL Sipeed M1SDock Kernel + KERNEL ../Image + FDT ../bl808-sipeed-m1s.dtb + APPEND root=PARTLABEL=rootfs rootwait rw rootfstype=ext4 console=ttyS0,2000000 loglevel=8 earlycon=sbi diff --git a/board/pine64/ox64/rootfs-overlay/root/README!!!!.txt b/board/pine64/ox64/rootfs-overlay/root/README!!!!.txt index 1fc0a40..65c0b16 100644 --- a/board/pine64/ox64/rootfs-overlay/root/README!!!!.txt +++ b/board/pine64/ox64/rootfs-overlay/root/README!!!!.txt @@ -1,7 +1,11 @@ By Default, this image is configured to boot the Pine64 Ox64 image. -If you want to boot a different image, please copy the boot-m1s.scr -in /boot to /boot/boot.scr -The boot-m1s.scr/boot.scr file(s) are U-Boot scripts that will load the -correct DTB file the board you are using. +To change the image, you need to edit the file /boot/extlinux/extlinux.conf +and change the Default entry to Sipeed M1SDock Kernel +Alternatively, if you have custom images, and using uboot scripts, you can +add the relevent uboot script to the /boot/boot.scr file. + +Please see the following link for more information on how how uboot is +configured: +https://github.com/openbouffalo/buildroot_bouffalo/wiki/U-Boot-Bootflow diff --git a/board/pine64/ox64/uboot_defconfig b/board/pine64/ox64/uboot_defconfig index 4c35dc1..0c82289 100644 --- a/board/pine64/ox64/uboot_defconfig +++ b/board/pine64/ox64/uboot_defconfig @@ -24,10 +24,14 @@ CONFIG_BOOTCOMMAND="mmc rescan; sleep 1; mmc rescan; run distro_bootcmd" # CONFIG_BOOTM_PLAN9 is not set # CONFIG_BOOTM_RTEMS is not set # CONFIG_BOOTM_VXWORKS is not set +CONFIG_CMD_BOOTMENU=y CONFIG_CMD_CLK=y CONFIG_CMD_GPIO=y CONFIG_CMD_MMC=y # CONFIG_OF_OMIT_DTB is not set +CONFIG_ENV_IS_NOWHERE=y +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:auto" CONFIG_NET_RANDOM_ETHADDR=y CONFIG_MMC=y CONFIG_MMC_BROKEN_CD=y @@ -41,3 +45,4 @@ CONFIG_PINCONF=y CONFIG_BAUDRATE=2000000 CONFIG_SYSRESET=y # CONFIG_SHA256 is not set +CONFIG_OF_LIBFDT_OVERLAY=y \ No newline at end of file