Message ID | 20240414190644.1059171-1-tekieli.lukasz@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/1] board/visionfive2: add spi-nor image | expand |
On 14/04/2024 21:06, Lukasz Tekieli wrote: > Builds the spi-nor.img together with the sdcard.img. > Readme is extended with SPI NOR flash writing instructions > and recovery. > > The spi-nor.img layout is based on the following document: > > https://doc-en.rvspace.org/VisionFive2/Boot_UG/JH7110_SDK/boot_address_allocation.html > > Signed-off-by: Lukasz Tekieli <tekieli.lukasz@gmail.com> Applied to master, thanks. I've added the following paragraph to the readme: Note that Buildroot puts the bootloader both in SPI NOR and on the SD card, so after flashing as instructed above, either boot mode should work. If this is not correct, could you please send a correction? Regards, Arnout > --- > board/visionfive2/genimage_spi-nor.cfg | 36 ++++++++++++++++++++++++++ > board/visionfive2/post-image.sh | 4 +++ > board/visionfive2/readme.txt | 25 +++++++++++++++--- > configs/visionfive2_defconfig | 3 +-- > 4 files changed, 62 insertions(+), 6 deletions(-) > create mode 100644 board/visionfive2/genimage_spi-nor.cfg > create mode 100755 board/visionfive2/post-image.sh > > diff --git a/board/visionfive2/genimage_spi-nor.cfg b/board/visionfive2/genimage_spi-nor.cfg > new file mode 100644 > index 0000000000..8b1d13989a > --- /dev/null > +++ b/board/visionfive2/genimage_spi-nor.cfg > @@ -0,0 +1,36 @@ > +flash nor-16M-256 { > + pebsize = 4K > + minimum-io-unit-size = 256 > + numpebs = 4096 > +} > + > +image spi-nor.img { > + size = 16M > + > + flash { > + } > + > + flashtype = "nor-16M-256" > + > + partition spl { > + image = "u-boot-spl.bin.normal.out" > + offset = 0K > + size = 512K > + } > + > + partition uboot-env { > + offset = 960K > + size = 64K > + } > + > + partition uboot { > + image = "u-boot.itb" > + offset = 1M > + size = 4M > + } > + > + partition reserved-data { > + offset = 6M > + size = 10M > + } > +} > diff --git a/board/visionfive2/post-image.sh b/board/visionfive2/post-image.sh > new file mode 100755 > index 0000000000..3da106dc26 > --- /dev/null > +++ b/board/visionfive2/post-image.sh > @@ -0,0 +1,4 @@ > +#!/bin/bash > + > +support/scripts/genimage.sh -c board/visionfive2/genimage.cfg > +support/scripts/genimage.sh -c board/visionfive2/genimage_spi-nor.cfg > diff --git a/board/visionfive2/readme.txt b/board/visionfive2/readme.txt > index 85be1d5dfc..31edef02e4 100644 > --- a/board/visionfive2/readme.txt > +++ b/board/visionfive2/readme.txt > @@ -12,12 +12,27 @@ How to build > $ make visionfive2_defconfig > $ make > > +Once the build process is finished you will have two images > +in the output/images/ directory: > +- sdcard.img > +- spi-nor.img > + > +How to write the SPI NOR flash > +============================= > + > +If you have a booting device use u-boot and tftp: > + > + # tftpboot 0x82000000 spi-nor.img > + # sf probe > + # sf update 0x82000000 0x0 {filesize} > + > +Otherwise, follow the recovery instruction: > + > +https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/recovering_bootloader%20-%20vf2.html > + > How to write the SD card > ======================== > > -Once the build process is finished you will have an image called "sdcard.img" > -in the output/images/ directory. > - > Copy the bootable "sdcard.img" onto an SD card with "dd": > > $ sudo dd if=output/images/sdcard.img of=/dev/sdX > @@ -27,7 +42,9 @@ Preparing the board > > Connect a TTL UART cable to pin 6 (GND), 8 (TX) and 10 (RX). > > -Change the boot mode pins to SD card booting (RGPIO_0=1, GRPIO_1=0): > +Use the correct mode for booting: > +- SD card RGPIO_0=1, GRPIO_1=0 > +- SPI NOR flash RGPIO_0=1, GRPIO_1=1 > > https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/boot_mode_settings.html > > diff --git a/configs/visionfive2_defconfig b/configs/visionfive2_defconfig > index c8576a35a7..699ea8dd4b 100644 > --- a/configs/visionfive2_defconfig > +++ b/configs/visionfive2_defconfig > @@ -2,8 +2,7 @@ BR2_riscv=y > BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_15=y > BR2_SYSTEM_DHCP="eth0" > BR2_ROOTFS_OVERLAY="board/visionfive2/overlay" > -BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh" > -BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/visionfive2/genimage.cfg" > +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/visionfive2/post-image.sh" > BR2_LINUX_KERNEL=y > BR2_LINUX_KERNEL_CUSTOM_TARBALL=y > BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,starfive-tech,linux,05533e9c31d6f0da20efc2d436a3b0f6d516ed4b)/linux-05533e9c31d6f0da20efc2d436a3b0f6d516ed4b.tar.gz"
diff --git a/board/visionfive2/genimage_spi-nor.cfg b/board/visionfive2/genimage_spi-nor.cfg new file mode 100644 index 0000000000..8b1d13989a --- /dev/null +++ b/board/visionfive2/genimage_spi-nor.cfg @@ -0,0 +1,36 @@ +flash nor-16M-256 { + pebsize = 4K + minimum-io-unit-size = 256 + numpebs = 4096 +} + +image spi-nor.img { + size = 16M + + flash { + } + + flashtype = "nor-16M-256" + + partition spl { + image = "u-boot-spl.bin.normal.out" + offset = 0K + size = 512K + } + + partition uboot-env { + offset = 960K + size = 64K + } + + partition uboot { + image = "u-boot.itb" + offset = 1M + size = 4M + } + + partition reserved-data { + offset = 6M + size = 10M + } +} diff --git a/board/visionfive2/post-image.sh b/board/visionfive2/post-image.sh new file mode 100755 index 0000000000..3da106dc26 --- /dev/null +++ b/board/visionfive2/post-image.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +support/scripts/genimage.sh -c board/visionfive2/genimage.cfg +support/scripts/genimage.sh -c board/visionfive2/genimage_spi-nor.cfg diff --git a/board/visionfive2/readme.txt b/board/visionfive2/readme.txt index 85be1d5dfc..31edef02e4 100644 --- a/board/visionfive2/readme.txt +++ b/board/visionfive2/readme.txt @@ -12,12 +12,27 @@ How to build $ make visionfive2_defconfig $ make +Once the build process is finished you will have two images +in the output/images/ directory: +- sdcard.img +- spi-nor.img + +How to write the SPI NOR flash +============================= + +If you have a booting device use u-boot and tftp: + + # tftpboot 0x82000000 spi-nor.img + # sf probe + # sf update 0x82000000 0x0 {filesize} + +Otherwise, follow the recovery instruction: + +https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/recovering_bootloader%20-%20vf2.html + How to write the SD card ======================== -Once the build process is finished you will have an image called "sdcard.img" -in the output/images/ directory. - Copy the bootable "sdcard.img" onto an SD card with "dd": $ sudo dd if=output/images/sdcard.img of=/dev/sdX @@ -27,7 +42,9 @@ Preparing the board Connect a TTL UART cable to pin 6 (GND), 8 (TX) and 10 (RX). -Change the boot mode pins to SD card booting (RGPIO_0=1, GRPIO_1=0): +Use the correct mode for booting: +- SD card RGPIO_0=1, GRPIO_1=0 +- SPI NOR flash RGPIO_0=1, GRPIO_1=1 https://doc-en.rvspace.org/VisionFive2/Quick_Start_Guide/VisionFive2_SDK_QSG/boot_mode_settings.html diff --git a/configs/visionfive2_defconfig b/configs/visionfive2_defconfig index c8576a35a7..699ea8dd4b 100644 --- a/configs/visionfive2_defconfig +++ b/configs/visionfive2_defconfig @@ -2,8 +2,7 @@ BR2_riscv=y BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_15=y BR2_SYSTEM_DHCP="eth0" BR2_ROOTFS_OVERLAY="board/visionfive2/overlay" -BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh" -BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/visionfive2/genimage.cfg" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/visionfive2/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_TARBALL=y BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,starfive-tech,linux,05533e9c31d6f0da20efc2d436a3b0f6d516ed4b)/linux-05533e9c31d6f0da20efc2d436a3b0f6d516ed4b.tar.gz"
Builds the spi-nor.img together with the sdcard.img. Readme is extended with SPI NOR flash writing instructions and recovery. The spi-nor.img layout is based on the following document: https://doc-en.rvspace.org/VisionFive2/Boot_UG/JH7110_SDK/boot_address_allocation.html Signed-off-by: Lukasz Tekieli <tekieli.lukasz@gmail.com> --- board/visionfive2/genimage_spi-nor.cfg | 36 ++++++++++++++++++++++++++ board/visionfive2/post-image.sh | 4 +++ board/visionfive2/readme.txt | 25 +++++++++++++++--- configs/visionfive2_defconfig | 3 +-- 4 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 board/visionfive2/genimage_spi-nor.cfg create mode 100755 board/visionfive2/post-image.sh