Skip to contentSkip to conversation

boot/sun20i-d1-spl: new package

PATCH Superseded Peter Korsgaard 3 participants 9 messages Nov 5, 2021 – Nov 7, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 boot/sun20i-d1-spl: new package

U-Boot does not yet have SPL code to initialize the DDR controller on the Allwinner D1 - So instead package the sun20i-d1-spl bootloader, which is based on boot0 from the Allwinner BSP with some modifications to build it separately from the BSP and boot mainline U-Boot as explained on the linux-sunxi wiki:

https://linux-sunxi.org/Allwinner_Nezha

---
 DEVELOPERS                            |  1 +
 boot/Config.in                        |  1 +
 boot/sun20i-d1-spl/Config.in          |  8 ++++++++
 boot/sun20i-d1-spl/sun20i-d1-spl.hash |  2 ++
 boot/sun20i-d1-spl/sun20i-d1-spl.mk   | 23 +++++++++++++++++++++++
 5 files changed, 35 insertions(+)
 create mode 100644 boot/sun20i-d1-spl/Config.in
 create mode 100644 boot/sun20i-d1-spl/sun20i-d1-spl.hash
 create mode 100644 boot/sun20i-d1-spl/sun20i-d1-spl.mk
DEVELOPERS +1 -0
index 9d0e92b564..c378270bb7 100644
@@ -2108,6 +2108,7 @@ F:	board/orangepi/
 F:	board/pandaboard/
 F:	board/roseapplepi/
 F:	boot/shim/
+F:	boot/sun20i-d1-spl/
 F:	configs/avenger96_defconfig
 F:	configs/beagleboneai_defconfig
 F:	configs/lafrite_defconfig
boot/Config.in +1 -0
index ff98a49796..40472ae07d 100644
@@ -20,6 +20,7 @@ source "boot/optee-os/Config.in"
 source "boot/opensbi/Config.in"
 source "boot/s500-bootloader/Config.in"
 source "boot/shim/Config.in"
+source "boot/sun20i-d1-spl/Config.in"
 source "boot/syslinux/Config.in"
 source "boot/uboot/Config.in"
 source "boot/vexpress-firmware/Config.in"
boot/sun20i-d1-spl/Config.in new file +8 -0
new file mode 100644
index 0000000000..9d94d87b1c
@@ -0,0 +1,8 @@
+config BR2_TARGET_SUN20I_D1_SPL
+	bool "sun20-d1-spl"
+	depends on BR2_RISCV_64
+	help
+	  Allwinner D1 boot0 code with modifications to use as U-Boot
+	  SPL.
+
+	  https://github.com/smaeul/sun20i_d1_spl
boot/sun20i-d1-spl/sun20i-d1-spl.hash new file +2 -0
new file mode 100644
index 0000000000..6ca60e5278
@@ -0,0 +1,2 @@
+# Locally computed
+sha256  69063601239a7254fb72e486b138d88a6f2b5c645b24cdfe9792123f975d4a8f  sun20i-d1-spl-771192d0b3737798d7feca87263c8fa74a449787.tar.gz
boot/sun20i-d1-spl/sun20i-d1-spl.mk new file +23 -0
new file mode 100644
index 0000000000..2462ce2322
@@ -0,0 +1,23 @@
+################################################################################
+#
+# sun20i-d1-spl
+#
+################################################################################
+
+# Commit on the 'mainline' branch
+SUN20I_D1_SPL_VERSION = 771192d0b3737798d7feca87263c8fa74a449787
+SUN20I_D1_SPL_SITE = $(call github,smaeul,sun20i_d1_spl,$(SUN20I_D1_SPL_VERSION))
+SUN20I_D1_SPL_INSTALL_TARGET = NO
+SUN20I_D1_SPL_INSTALL_IMAGES = YES
+SUN20I_D1_SPL_LICENSE = GPL-2.0+
+
+define SUN20I_D1_SPL_BUILD_CMDS
+	$(MAKE) -C $(@D) CROSS_COMPILE="$(TARGET_CROSS)" p=sun20iw1p1 mmc
+endef
+
+define SUN20I_D1_SPL_INSTALL_IMAGES_CMDS
+	$(INSTALL) -D -m 0644 $(@D)/nboot/boot0_sdcard_sun20iw1p1.bin \
+		$(BINARIES_DIR)/boot0_sdcard_sun20iw1p1.bin
+endef
+
+$(eval $(generic-package))
Signature · 6 lines
2.20.1

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

PATCH 2/2 configs/nezha_defconfig: new defconfig

Add a defconfig for the Allwinner Nezha, a raspberrypi-style board built around the RISC-V 64bit D1 SoC.

There is currently no upstream support, so use the git repos from Samuel Holland as explained on the linux-sunxi wiki:

https://linux-sunxi.org/Allwinner_Nezha

The U-Boot DTB is also used by opensbi, but the two branches are unfortunately not in sync at the moment, so add a patch to fix the compatible for the PLIC so opensbi makes it available to S-Mode (Linux).

The use of the sun20i-d1-spl SPL bootloader / TOC1 file format also makes it a bit more complicated to build the boot image. As this is expected to only be a temporary issue, add a U-Boot patch to build the TOC1 image as part of the build rather than adding explicit support in our U-Boot package to do it.

---
 DEVELOPERS                                    |  2 +
 board/nezha/extlinux.conf                     |  4 ++
 board/nezha/genimage.cfg                      | 37 +++++++++++++
 ...un20i-d1.dtsi-adjust-plic-compatible.patch | 36 +++++++++++++
 ...pport-building-u-boot.toc1-for-nezda.patch | 54 +++++++++++++++++++
 board/nezha/post-build.sh                     |  6 +++
 board/nezha/readme.txt                        | 24 +++++++++
 configs/nezha_defconfig                       | 36 +++++++++++++
 8 files changed, 199 insertions(+)
 create mode 100644 board/nezha/extlinux.conf
 create mode 100644 board/nezha/genimage.cfg
 create mode 100644 board/nezha/patches/uboot/0001-arch-riscv-dts-sun20i-d1.dtsi-adjust-plic-compatible.patch
 create mode 100644 board/nezha/patches/uboot/0002-Makefile-HACK-Support-building-u-boot.toc1-for-nezda.patch
 create mode 100755 board/nezha/post-build.sh
 create mode 100644 board/nezha/readme.txt
 create mode 100644 configs/nezha_defconfig
DEVELOPERS +2 -0
index c378270bb7..50be4e2367 100644
@@ -2101,6 +2101,7 @@ N:	Peter Korsgaard <[email protected]>
 F:	board/arrow/avenger96/
 F:	board/beagleboneai/
 F:	board/minnowboard/
+F:	board/nezha/
 F:	board/librecomputer/lafrite/
 F:	board/nexbox/a95x/
 F:	board/openblocks/a6/
@@ -2115,6 +2116,7 @@ F:	configs/lafrite_defconfig
 F:	configs/minnowboard_max-graphical_defconfig
 F:	configs/minnowboard_max_defconfig
 F:	configs/nexbox_a95x_defconfig
+F:	configs/nezha_defconfig
 F:	configs/openblocks_a6_defconfig
 F:	configs/orangepi_pc_defconfig
 F:	configs/orangepi_r1_defconfig
board/nezha/extlinux.conf new file +4 -0
new file mode 100644
index 0000000000..02232f4d16
@@ -0,0 +1,4 @@
+label linux
+  kernel /boot/Image
+  devicetree /boot/sun20i-d1-nezha.dtb
+  append console=ttyS0,115200 root=/dev/mmcblk0p1 ro rootwait
board/nezha/genimage.cfg new file +37 -0
new file mode 100644
index 0000000000..bf99e00824
@@ -0,0 +1,37 @@
+# Minimal SD card image for the Allwinner Nezha
+
+image sdcard.img {
+	hdimage {
+	}
+
+	partition boot0-1 {
+		in-partition-table = "no"
+		image = "boot0_sdcard_sun20iw1p1.bin"
+		offset = 8192
+	}
+
+	partition boot0-2 {
+		in-partition-table = "no"
+		image = "boot0_sdcard_sun20iw1p1.bin"
+		offset = 131072
+	}
+
+	partition u-boot-1 {
+		in-partition-table = "no"
+		image = "u-boot.toc1"
+		offset = 12582912
+	}
+
+	partition u-boot-2 {
+		in-partition-table = "no"
+		image = "u-boot.toc1"
+		offset = 16793600
+	}
+
+	partition rootfs {
+		partition-type = 0x83
+		image = "rootfs.ext4"
+		bootable = "true"
+		offset = 18M
+	}
+}
board/nezha/patches/uboot/0001-arch-riscv-dts-sun20i-d1.dtsi-adjust-plic-compatible.patch new file +36 -0
new file mode 100644
index 0000000000..3524f44a61
@@ -0,0 +1,36 @@
+From 99cf8f37ceb1def9e7bbaccc395cf2275723e03d Mon Sep 17 00:00:00 2001
+From: Peter Korsgaard <[email protected]>
+Date: Thu, 4 Nov 2021 22:15:13 +0100
+Subject: [PATCH] arch/riscv/dts/sun20i-d1.dtsi: adjust plic compatible to
+ match opensbi
+
+The T-HEAD PLIC is by default not accessible from S-mode, and access must be
+enabled by opensbi to make it accessible to Linux.
+
+The DTB is used both by U-Boot and opensbi (but the PLIC node is ignored by
+U-Boot), so change the compatible to match what opensbi expects to fix a
+crash during Linux boot:
+
+https://github.com/riscv-software-src/opensbi/commit/78c2b19218bd
+
+Signed-off-by: Peter Korsgaard <[email protected]>
+---
+ arch/riscv/dts/sun20i-d1.dtsi | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/riscv/dts/sun20i-d1.dtsi b/arch/riscv/dts/sun20i-d1.dtsi
+index 280e0336d4..56d02c33b0 100644
+--- a/arch/riscv/dts/sun20i-d1.dtsi
++++ b/arch/riscv/dts/sun20i-d1.dtsi
+@@ -1136,7 +1136,7 @@
+ 
+ 		plic: interrupt-controller@10000000 {
+ 			compatible = "allwinner,sun20i-d1-plic",
+-				     "sifive,plic-1.0.0";
++				     "thead,c900-plic";
+ 			reg = <0x10000000 0x4000000>;
+ 			#address-cells = <0>;
+ 			interrupts-extended = <&cpu0_intc 11>,
+-- 
+2.20.1
+
board/nezha/patches/uboot/0002-Makefile-HACK-Support-building-u-boot.toc1-for-nezda.patch new file +54 -0

54 lines not on this page · raw message

board/nezha/post-build.sh new file +6 -0
new file mode 100755
index 0000000000..9d38b13b84
@@ -0,0 +1,6 @@
+#!/bin/sh
+BOARD_DIR=$(dirname $0)
+
+# Bring the extlinux.conf file in
+install -D -m 0644 ${BOARD_DIR}/extlinux.conf \
+	${TARGET_DIR}/boot/extlinux/extlinux.conf
board/nezha/readme.txt new file +24 -0
new file mode 100644
index 0000000000..fd4c6707de
@@ -0,0 +1,24 @@
+Allwinner Nezha
+===============
+
+Nezha is is a low-cost RISC-V 64-bit based platform, powered by an
+Allwinner D1 SoC.
+
+How to build
+============
+
+$ make nezha_defconfig
+$ make
+
+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
+
+Connect a TTL UART to the debug connector, insert the microSD card and
+plug in a USB-C cable to the PWR connector to boot the system.
configs/nezha_defconfig new file +36 -0
new file mode 100644
index 0000000000..f04404b9a4
@@ -0,0 +1,36 @@
+BR2_riscv=y
+BR2_GLOBAL_PATCH_DIR="board/nezha/patches"
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_14=y
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/nezha/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/nezha/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/smaeul/linux.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="012f5a3d01be6d44e32c74bb3637ec281790b297"
+BR2_LINUX_KERNEL_DEFCONFIG="nezha"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="allwinner/sun20i-d1-nezha"
+BR2_LINUX_KERNEL_INSTALL_TARGET=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_OPENSBI=y
+BR2_TARGET_OPENSBI_CUSTOM_GIT=y
+BR2_TARGET_OPENSBI_CUSTOM_REPO_URL="https://github.com/smaeul/opensbi"
+BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION="b9125c6f8909d1cc0417795737fc13cb6297ff11"
+BR2_TARGET_OPENSBI_PLAT="generic"
+# BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set
+BR2_TARGET_SUN20I_D1_SPL=y
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
+BR2_TARGET_UBOOT_CUSTOM_GIT=y
+BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/smaeul/u-boot"
+BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="62392d3b8a624a80646c1876533336f90140088d"
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="nezha"
+BR2_TARGET_UBOOT_NEEDS_DTC=y
+BR2_TARGET_UBOOT_NEEDS_OPENSBI=y
+# BR2_TARGET_UBOOT_FORMAT_BIN is not set
+BR2_TARGET_UBOOT_FORMAT_CUSTOM=y
+BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot.toc1"
+BR2_PACKAGE_HOST_GENIMAGE=y
Signature · 6 lines
2.20.1

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

Re: [Buildroot] [PATCH 2/2] configs/nezha_defconfig: new defconfig

Howdy,

Thanks for this! It's obviously great, just a couple of nits, see below.

board/nezha/post-build.sh line 6

Quoted 12 lines · On Fri, 5 Nov 2021 13:38:47 +0100 Peter Korsgaard <[email protected]> wrote:
board/nezha/post-build.sh new file +6 -0
new file mode 100755
index 0000000000..9d38b13b84
@@ -0,0 +1,6 @@
+#!/bin/sh
+BOARD_DIR=$(dirname $0)
+
+# Bring the extlinux.conf file in
+install -D -m 0644 ${BOARD_DIR}/extlinux.conf \
+	${TARGET_DIR}/boot/extlinux/extlinux.conf

Probably you don't even need a post-build script here, the extlinux.conf could just be added to the rootfs using a rootfs overlay.

Quoted 5 lines

new file mode 100644
index 0000000000..f04404b9a4

configs/nezha_defconfig line 10

Quoted 10 lines
configs/nezha_defconfig new file +10 -0
@@ -0,0 +1,36 @@
+BR2_riscv=y
+BR2_GLOBAL_PATCH_DIR="board/nezha/patches"
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_14=y
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/nezha/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/nezha/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/smaeul/linux.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="012f5a3d01be6d44e32c74bb3637ec281790b297"

Here...

configs/nezha_defconfig line 21

Quoted 4 lines
configs/nezha_defconfig new file +4 -0
+BR2_TARGET_OPENSBI=y
+BR2_TARGET_OPENSBI_CUSTOM_GIT=y
+BR2_TARGET_OPENSBI_CUSTOM_REPO_URL="https://github.com/smaeul/opensbi"
+BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION="b9125c6f8909d1cc0417795737fc13cb6297ff11"

Here...

configs/nezha_defconfig line 29

Quoted 3 lines
configs/nezha_defconfig new file +3 -0
+BR2_TARGET_UBOOT_CUSTOM_GIT=y
+BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/smaeul/u-boot"
+BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="62392d3b8a624a80646c1876533336f90140088d"

.. and here

We normally use the github macro to download a tarball instead of a full Git repository.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH 2/2] configs/nezha_defconfig: new defconfig

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Howdy,
Thanks for this! It's obviously great, just a couple of nits, see below.

On Fri, 5 Nov 2021 13:38:47 +0100
Peter Korsgaard <[email protected]> wrote:

Quoted 15 lines

board/nezha/post-build.sh line 6

Quoted 12 lines
board/nezha/post-build.sh new file +6 -0
new file mode 100755
index 0000000000..9d38b13b84
@@ -0,0 +1,6 @@
+#!/bin/sh
+BOARD_DIR=$(dirname $0)
+
+# Bring the extlinux.conf file in
+install -D -m 0644 ${BOARD_DIR}/extlinux.conf \
+	${TARGET_DIR}/boot/extlinux/extlinux.conf

Probably you don't even need a post-build script here, the extlinux.conf could just be added to the rootfs using a rootfs overlay.

Sure, that works as well. As maybe is obvious I copied this from beaglev. I can change to a rootfs overlay if that is nicer.

Quoted 26 lines
Quoted 5 lines

new file mode 100644
index 0000000000..f04404b9a4

configs/nezha_defconfig line 10

Quoted 10 lines
configs/nezha_defconfig new file +10 -0
@@ -0,0 +1,36 @@
+BR2_riscv=y
+BR2_GLOBAL_PATCH_DIR="board/nezha/patches"
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_14=y
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/nezha/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/nezha/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/smaeul/linux.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="012f5a3d01be6d44e32c74bb3637ec281790b297"

Here...

configs/nezha_defconfig line 21

Quoted 4 lines
configs/nezha_defconfig new file +4 -0
+BR2_TARGET_OPENSBI=y
+BR2_TARGET_OPENSBI_CUSTOM_GIT=y
+BR2_TARGET_OPENSBI_CUSTOM_REPO_URL="https://github.com/smaeul/opensbi"
+BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION="b9125c6f8909d1cc0417795737fc13cb6297ff11"

Here...

Quoted 8 lines

configs/nezha_defconfig line 29

Quoted 3 lines
configs/nezha_defconfig new file +3 -0
+BR2_TARGET_UBOOT_CUSTOM_GIT=y
+BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/smaeul/u-boot"
+BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="62392d3b8a624a80646c1876533336f90140088d"

.. and here

We normally use the github macro to download a tarball instead of a full Git repository.

We could do that as well. I didn't do it as I'm expecting (hoping) to see quite some updates here, but I can change it for the defconfig.

I'll wait a bit to see if there is other feedback and then send a v2 changing the above.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Re: [Buildroot] [PATCH 2/2] configs/nezha_defconfig: new defconfig

In reply to Peter Korsgaard

Hello Peter, All,

Quoted 75 lines

Il giorno 5 nov 2021, alle ore 13:39, Peter Korsgaard <[email protected]> ha scritto:

Add a defconfig for the Allwinner Nezha, a raspberrypi-style board built around the RISC-V 64bit D1 SoC.

There is currently no upstream support, so use the git repos from Samuel Holland as explained on the linux-sunxi wiki:

https://linux-sunxi.org/Allwinner_Nezha

The U-Boot DTB is also used by opensbi, but the two branches are unfortunately not in sync at the moment, so add a patch to fix the compatible for the PLIC so opensbi makes it available to S-Mode (Linux).

The use of the sun20i-d1-spl SPL bootloader / TOC1 file format also makes it a bit more complicated to build the boot image. As this is expected to only be a temporary issue, add a U-Boot patch to build the TOC1 image as part of the build rather than adding explicit support in our U-Boot package to do it.

---

DEVELOPERS                                    |  2 +
board/nezha/extlinux.conf                     |  4 ++
board/nezha/genimage.cfg                      | 37 +++++++++++++
...un20i-d1.dtsi-adjust-plic-compatible.patch | 36 +++++++++++++
...pport-building-u-boot.toc1-for-nezda.patch | 54 +++++++++++++++++++
board/nezha/post-build.sh                     |  6 +++
board/nezha/readme.txt                        | 24 +++++++++
configs/nezha_defconfig                       | 36 +++++++++++++
8 files changed, 199 insertions(+)

create mode 100644 board/nezha/extlinux.conf
create mode 100644 board/nezha/genimage.cfg
create mode 100644 board/nezha/patches/uboot/0001-arch-riscv-dts-sun20i-d1.dtsi-adjust-plic-compatible.patch create mode 100644 board/nezha/patches/uboot/0002-Makefile-HACK-Support-building-u-boot.toc1-for-nezda.patch create mode 100755 board/nezha/post-build.sh
create mode 100644 board/nezha/readme.txt
create mode 100644 configs/nezha_defconfig

DEVELOPERS +0 -0
index c378270bb7..50be4e2367 100644
@@ -2101,6 +2101,7 @@ N:    Peter Korsgaard <[email protected]>
F:    board/arrow/avenger96/
F:    board/beagleboneai/
F:    board/minnowboard/
+F:    board/nezha/
F:    board/librecomputer/lafrite/
F:    board/nexbox/a95x/
F:    board/openblocks/a6/
DEVELOPERS +0 -0
@@ -2115,6 +2116,7 @@ F:    configs/lafrite_defconfig
F:    configs/minnowboard_max-graphical_defconfig
F:    configs/minnowboard_max_defconfig
F:    configs/nexbox_a95x_defconfig
+F:    configs/nezha_defconfig
F:    configs/openblocks_a6_defconfig
F:    configs/orangepi_pc_defconfig
F:    configs/orangepi_r1_defconfig
board/nezha/extlinux.conf new file +4 -0
new file mode 100644
index 0000000000..02232f4d16
@@ -0,0 +1,4 @@
+label linux
+  kernel /boot/Image
+  devicetree /boot/sun20i-d1-nezha.dtb
+  append console=ttyS0,115200 root=/dev/mmcblk0p1 ro rootwait
board/nezha/genimage.cfg new file +0 -0
new file mode 100644
index 0000000000..bf99e00824

board/nezha/genimage.cfg line 10

Quoted 10 lines
board/nezha/genimage.cfg new file +10 -0
@@ -0,0 +1,37 @@
+# Minimal SD card image for the Allwinner Nezha
+
+image sdcard.img {
+    hdimage {
+    }
+
+    partition boot0-1 {
+        in-partition-table = "no"
+        image = "boot0_sdcard_sun20iw1p1.bin"
+        offset = 8192

Can you please use 8K here ^^^

board/nezha/genimage.cfg line 16

Quoted 6 lines
board/nezha/genimage.cfg new file +6 -0
+    }
+
+    partition boot0-2 {
+        in-partition-table = "no"
+        image = "boot0_sdcard_sun20iw1p1.bin"
+        offset = 131072

128K here etc.

I find it to be easier to read.

I would go for changing every .cfg file in Buildroot and submit a patchset for this to improve readibility. What do you all think about this?

Giulio

Quoted 214 lines
board/nezha/genimage.cfg new file +21 -0
+    }
+
+    partition u-boot-1 {
+        in-partition-table = "no"
+        image = "u-boot.toc1"
+        offset = 12582912
+    }
+
+    partition u-boot-2 {
+        in-partition-table = "no"
+        image = "u-boot.toc1"
+        offset = 16793600
+    }
+
+    partition rootfs {
+        partition-type = 0x83
+        image = "rootfs.ext4"
+        bootable = "true"
+        offset = 18M
+    }
+}
board/nezha/patches/uboot/0001-arch-riscv-dts-sun20i-d1.dtsi-adjust-plic-compatible.patch new file +36 -0
new file mode 100644
index 0000000000..3524f44a61
@@ -0,0 +1,36 @@
+From 99cf8f37ceb1def9e7bbaccc395cf2275723e03d Mon Sep 17 00:00:00 2001
+From: Peter Korsgaard <[email protected]>
+Date: Thu, 4 Nov 2021 22:15:13 +0100
+Subject: [PATCH] arch/riscv/dts/sun20i-d1.dtsi: adjust plic compatible to
+ match opensbi
+
+The T-HEAD PLIC is by default not accessible from S-mode, and access must be
+enabled by opensbi to make it accessible to Linux.
+
+The DTB is used both by U-Boot and opensbi (but the PLIC node is ignored by
+U-Boot), so change the compatible to match what opensbi expects to fix a
+crash during Linux boot:
+
+https://github.com/riscv-software-src/opensbi/commit/78c2b19218bd
+
+Signed-off-by: Peter Korsgaard <[email protected]>
+---
+ arch/riscv/dts/sun20i-d1.dtsi | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/riscv/dts/sun20i-d1.dtsi b/arch/riscv/dts/sun20i-d1.dtsi
+index 280e0336d4..56d02c33b0 100644
+--- a/arch/riscv/dts/sun20i-d1.dtsi
++++ b/arch/riscv/dts/sun20i-d1.dtsi
+@@ -1136,7 +1136,7 @@
+ 
+        plic: interrupt-controller@10000000 {
+            compatible = "allwinner,sun20i-d1-plic",
+-                     "sifive,plic-1.0.0";
++                     "thead,c900-plic";
+            reg = <0x10000000 0x4000000>;
+            #address-cells = <0>;
+            interrupts-extended = <&cpu0_intc 11>,
+-- 
+2.20.1
+
board/nezha/patches/uboot/0002-Makefile-HACK-Support-building-u-boot.toc1-for-nezda.patch new file +54 -0
new file mode 100644
index 0000000000..6e89a921df
@@ -0,0 +1,54 @@
+From 4a923e0e4ef6d2b41cb89d658e269adada847573 Mon Sep 17 00:00:00 2001
+From: Peter Korsgaard <[email protected]>
+Date: Thu, 4 Nov 2021 22:32:04 +0100
+Subject: [PATCH] Makefile: HACK: Support building u-boot.toc1 for nezda board
+
+For easier integration into Buildroot.  The boot0 / toc1 logic is WIP until
+U-Boot gains SPL support for the D1, so add a hack to make it easier to
+integrate in Buildroot as-is.
+
+Signed-off-by: Peter Korsgaard <[email protected]>
+---
+ Makefile  | 9 +++++++++
+ nezha.cfg | 9 +++++++++
+ 2 files changed, 18 insertions(+)
+ create mode 100644 nezha.cfg
+
+diff --git a/Makefile b/Makefile
+index f911f70344..259d93bf80 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1084,6 +1084,15 @@ endif
+ .binman_stamp: FORCE
+    @touch $@
+ 
++fw_dynamic.bin: $(OPENSBI)
++    $(call if_changed,copy)
++
++MKIMAGEFLAGS_u-boot.toc1 = -T sunxi_toc1
++u-boot.toc1: nezha.cfg fw_dynamic.bin inputs
++    $(call if_changed,mkimage)
++
++all: u-boot.toc1
++
+ ifeq ($(CONFIG_DEPRECATED),y)
+    $(warning "You have deprecated configuration options enabled in your .config! Please check your configuration.")
+ endif
+diff --git a/nezha.cfg b/nezha.cfg
+new file mode 100644
+index 0000000000..2d23b9b388
+--- /dev/null
++++ b/nezha.cfg
+@@ -0,0 +1,9 @@
++[opensbi]
++file = fw_dynamic.bin
++addr = 0x40000000
++[dtb]
++file = arch/riscv/dts/sun20i-d1-nezha.dtb
++addr = 0x44000000
++[u-boot]
++file = u-boot-nodtb.bin
++addr = 0x4a000000
+-- 
+2.20.1
+
board/nezha/post-build.sh new file +6 -0
new file mode 100755
index 0000000000..9d38b13b84
@@ -0,0 +1,6 @@
+#!/bin/sh
+BOARD_DIR=$(dirname $0)
+
+# Bring the extlinux.conf file in
+install -D -m 0644 ${BOARD_DIR}/extlinux.conf \
+    ${TARGET_DIR}/boot/extlinux/extlinux.conf
board/nezha/readme.txt new file +24 -0
new file mode 100644
index 0000000000..fd4c6707de
@@ -0,0 +1,24 @@
+Allwinner Nezha
+===============
+
+Nezha is is a low-cost RISC-V 64-bit based platform, powered by an
+Allwinner D1 SoC.
+
+How to build
+============
+
+$ make nezha_defconfig
+$ make
+
+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
+
+Connect a TTL UART to the debug connector, insert the microSD card and
+plug in a USB-C cable to the PWR connector to boot the system.
configs/nezha_defconfig new file +36 -0
new file mode 100644
index 0000000000..f04404b9a4
@@ -0,0 +1,36 @@
+BR2_riscv=y
+BR2_GLOBAL_PATCH_DIR="board/nezha/patches"
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_14=y
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/nezha/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/nezha/genimage.cfg"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/smaeul/linux.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="012f5a3d01be6d44e32c74bb3637ec281790b297"
+BR2_LINUX_KERNEL_DEFCONFIG="nezha"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="allwinner/sun20i-d1-nezha"
+BR2_LINUX_KERNEL_INSTALL_TARGET=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_OPENSBI=y
+BR2_TARGET_OPENSBI_CUSTOM_GIT=y
+BR2_TARGET_OPENSBI_CUSTOM_REPO_URL="https://github.com/smaeul/opensbi"
+BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION="b9125c6f8909d1cc0417795737fc13cb6297ff11"
+BR2_TARGET_OPENSBI_PLAT="generic"
+# BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set
+BR2_TARGET_SUN20I_D1_SPL=y
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
+BR2_TARGET_UBOOT_CUSTOM_GIT=y
+BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/smaeul/u-boot"
+BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="62392d3b8a624a80646c1876533336f90140088d"
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="nezha"
+BR2_TARGET_UBOOT_NEEDS_DTC=y
+BR2_TARGET_UBOOT_NEEDS_OPENSBI=y
+# BR2_TARGET_UBOOT_FORMAT_BIN is not set
+BR2_TARGET_UBOOT_FORMAT_CUSTOM=y
+BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot.toc1"
+BR2_PACKAGE_HOST_GENIMAGE=y
Signature · 6 lines
2.20.1

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

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

#5 lore raw

Re: [Buildroot] [PATCH 2/2] configs/nezha_defconfig: new defconfig

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Giulio" == Giulio Benetti <[email protected]> writes:

Hi,

Quoted 18 lines

board/nezha/genimage.cfg line 10

Quoted 8 lines
board/nezha/genimage.cfg new file +8 -0
+image sdcard.img {
+    hdimage {
+    }
+
+    partition boot0-1 {
+        in-partition-table = "no"
+        image = "boot0_sdcard_sun20iw1p1.bin"
+        offset = 8192

Can you please use 8K here ^^^

board/nezha/genimage.cfg line 16

Quoted 6 lines
board/nezha/genimage.cfg new file +6 -0
+    }
+
+    partition boot0-2 {
+        in-partition-table = "no"
+        image = "boot0_sdcard_sun20iw1p1.bin"
+        offset = 131072
Quoted 3 lines

128K here etc.

I find it to be easier to read.

Ok. The "documentation" actually lists this in 512b sectors, but I don't think genimage has something nice to handle this:

https://linux-sunxi.org/Allwinner_Nezha

Quoted 3 lines

I would go for changing every .cfg file in Buildroot and submit a patchset for this to improve readibility. What do you all think about this?

Fine by me.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

Re: [Buildroot] [PATCH 2/2] configs/nezha_defconfig: new defconfig

Hi Peter,

Quoted 26 lines

Il giorno 5 nov 2021, alle ore 14:35, Peter Korsgaard <[email protected]> ha scritto:



Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"Giulio" == Giulio Benetti <[email protected]> writes:

Hi,

Quoted 17 lines

board/nezha/genimage.cfg line 10

Quoted 8 lines
board/nezha/genimage.cfg new file +8 -0
+image sdcard.img {
+    hdimage {
+    }
+
+    partition boot0-1 {
+        in-partition-table = "no"
+        image = "boot0_sdcard_sun20iw1p1.bin"
+        offset = 8192

Can you please use 8K here ^^^

Quoted 6 lines
board/nezha/genimage.cfg new file +6 -0
+    }
+
+    partition boot0-2 {
+        in-partition-table = "no"
+        image = "boot0_sdcard_sun20iw1p1.bin"
+        offset = 131072
Quoted 6 lines
Quoted 3 lines

128K here etc.

I find it to be easier to read.

Ok. The "documentation" actually lists this in 512b sectors, but I don't think genimage has something nice to handle this:

I don’t think it should matter the block size because we’re describing in bytes, not in block size, if we say 8K it’s 8KB, 128KB is 128KB and so on. Correct?

If we have a very particular value I can try if genimage handles a sum like 128K + 512B.

I let you know if this is needed for all .cfg files and if it works otherwise on those specific cases we can specify per byte. I find it more clear.

Is ok?

Giulio

Quoted 16 lines

https://linux-sunxi.org/Allwinner_Nezha

Quoted 3 lines

I would go for changing every .cfg file in Buildroot and submit a patchset for this to improve readibility. What do you all think about this?

Fine by me.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

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

#7 lore raw

Re: [Buildroot] [PATCH 2/2] configs/nezha_defconfig: new defconfig

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Giulio" == Giulio Benetti <[email protected]> writes:

Hi,

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I find it to be easier to read.

Ok. The "documentation" actually lists this in 512b sectors, but I don't think genimage has something nice to handle this:

I don’t think it should matter the block size because we’re describing in bytes, not in block size, if we say 8K it’s 8KB, 128KB is 128KB and so on. Correct?

Sure, just about readability - E.G. I don't know if 128K is a lot more readable than 131072 if you are looking at documentation that says sector 256, but OK.

Quoted 5 lines

I let you know if this is needed for all .cfg files and if it works otherwise on those specific cases we can specify per byte. I find it more clear.

Is ok?

For me it is, yes.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#8 lore raw

Re: [Buildroot] [PATCH 2/2] configs/nezha_defconfig: new defconfig

In reply to Peter Korsgaard

Hi Peter,

Quoted 22 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Giulio" == Giulio Benetti <[email protected]> writes:

Hi,

Quoted 17 lines

board/nezha/genimage.cfg line 10

Quoted 8 lines
board/nezha/genimage.cfg new file +8 -0
+image sdcard.img {
+    hdimage {
+    }
+
+    partition boot0-1 {
+        in-partition-table = "no"
+        image = "boot0_sdcard_sun20iw1p1.bin"
+        offset = 8192

Can you please use 8K here ^^^

Quoted 6 lines
board/nezha/genimage.cfg new file +6 -0
+    }
+
+    partition boot0-2 {
+        in-partition-table = "no"
+        image = "boot0_sdcard_sun20iw1p1.bin"
+        offset = 131072
Quoted 6 lines
Quoted 3 lines

128K here etc.

I find it to be easier to read.

Ok. The "documentation" actually lists this in 512b sectors, but I don't think genimage has something nice to handle this:

For curiosity I've checked genimage documentation:
https://github.com/pengutronix/genimage/blob/master/README.rst

And I've found that in master branch there is also the 's suffix that is used exactly for sector size of 512. BUT it will be available on V15 and we have instead V14 and V15 is still not released :-/ Anyway it can be useful in the near future.

It's been introduced on 26 March with this commit:
https://github.com/pengutronix/genimage/commit/bcd7fa662d0fdfb7b15a340ff42721cacc29bec9

Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 9 lines

https://linux-sunxi.org/Allwinner_Nezha

Quoted 3 lines

I would go for changing every .cfg file in Buildroot and submit a patchset for this to improve readibility. What do you all think about this?

Fine by me.

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