Skip to contentSkip to conversation

board/visionfive2: add spi-nor image

PATCH Applied Lukasz Tekieli 2 participants 2 messages Apr 14, 2024 – Apr 28, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board/visionfive2: add spi-nor image

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

---
 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
board/visionfive2/genimage_spi-nor.cfg new file +36 -0
new file mode 100644
index 0000000000..8b1d13989a
@@ -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
+	}
+}
board/visionfive2/post-image.sh new file +4 -0
new file mode 100755
index 0000000000..3da106dc26
@@ -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
board/visionfive2/readme.txt +21 -4
index 85be1d5dfc..31edef02e4 100644
@@ -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
 
configs/visionfive2_defconfig +1 -2
index c8576a35a7..699ea8dd4b 100644
@@ -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"
Signature · 6 lines
2.40.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 9 lines · Lukasz Tekieli

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

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

Quoted 112 lines
---
  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

board/visionfive2/genimage_spi-nor.cfg new file +36 -0
new file mode 100644
index 0000000000..8b1d13989a
@@ -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
+	}
+}
board/visionfive2/post-image.sh new file +4 -0
new file mode 100755
index 0000000000..3da106dc26
@@ -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
board/visionfive2/readme.txt +21 -4
index 85be1d5dfc..31edef02e4 100644
@@ -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
 
configs/visionfive2_defconfig +0 -0
index c8576a35a7..699ea8dd4b 100644

configs/visionfive2_defconfig BR2_riscv=y · line 8

Quoted 9 lines
configs/visionfive2_defconfig +1 -2
@@ -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"

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot