Skip to contentSkip to conversation

board/sifive: Update hifive_unleashed_defconfig and genimage.cfg

PATCH New Bin Meng 2 participants 2 messages Jan 29, 2021 – Jan 31, 2021 SiFive drivers

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH v2 1/1 board/sifive: Update hifive_unleashed_defconfig and genimage.cfg

From: Bin Meng <[email protected]>

Update to use the official linux kernel v5.10 instead of an out-of-tree kernel, and use the official U-Boot v2021.01 as the bootloader. Provide two configuration files of genimage for different boot flows:

- Boot from SD card (default)
- Boot from SPI flash

A boot script is generated to automatically boot the distro.

---

Changes in v2:
- Remove rootfs partition in the SPI flash genimage.cfg file
- Use U-Boot v2021.01 release

 board/sifive/hifive-unleashed/boot.cmd        |  4 ++
 .../{genimage.cfg => genimage_sdcard.cfg}     | 14 ++--
 .../hifive-unleashed/genimage_spi-nor.cfg     | 19 ++++++
 .../hifive-unleashed/linux.config.fragment    | 14 ++--
 board/sifive/hifive-unleashed/post-build.sh   |  2 +
 board/sifive/hifive-unleashed/readme.txt      | 68 +++++++++++++++----
 configs/hifive_unleashed_defconfig            | 31 ++++++---
 7 files changed, 116 insertions(+), 36 deletions(-)
 create mode 100644 board/sifive/hifive-unleashed/boot.cmd
 rename board/sifive/hifive-unleashed/{genimage.cfg => genimage_sdcard.cfg} (51%)
 create mode 100644 board/sifive/hifive-unleashed/genimage_spi-nor.cfg
 create mode 100755 board/sifive/hifive-unleashed/post-build.sh
board/sifive/hifive-unleashed/boot.cmd new file +4 -0
new file mode 100644
index 0000000000..7b5137d22c
@@ -0,0 +1,4 @@
+setenv bootargs earlycon=sbi root=/dev/mmcblk0p3 rootwait
+load mmc 0:3 ${kernel_addr_r} boot/Image
+load mmc 0:3 ${fdt_addr_r} boot/hifive-unleashed-a00.dtb
+booti ${kernel_addr_r} - ${fdt_addr_r}
board/sifive/hifive-unleashed/genimage_sdcard.cfg renamed from board/sifive/hifive-unleashed/genimage.cfg +10 -4
similarity index 51%
rename from board/sifive/hifive-unleashed/genimage.cfg
rename to board/sifive/hifive-unleashed/genimage_sdcard.cfg
index 8eebc52355..e7f98a47ce 100644
@@ -3,15 +3,21 @@ image sdcard.img {
 		gpt = true
 	}
 
-	partition bootloader {
-		image = "fw_payload.bin"
-		offset = 1M
-		size = 32M
+	partition u-boot-spl {
+		image = "u-boot-spl.bin"
+		offset = 17K
+		partition-type-uuid = 5B193300-FC78-40CD-8002-E86C45580B47
+	}
+
+	partition u-boot {
+		image = "u-boot.itb"
+		offset = 1041K
 		partition-type-uuid = 2E54B353-1271-4842-806F-E436D6AF6985
 	}
 
 	partition rootfs {
 		image = "rootfs.ext4"
 		partition-type-uuid = 0FC63DAF-8483-4772-8E79-3D69D8477DE4
+		bootable = true
 	}
 }
board/sifive/hifive-unleashed/genimage_spi-nor.cfg new file +19 -0
new file mode 100644
index 0000000000..2e5d89bfe8
@@ -0,0 +1,19 @@
+image spi-nor.img {
+	size = 32M
+
+	hdimage {
+		gpt = true
+	}
+
+	partition u-boot-spl {
+		image = "u-boot-spl.bin"
+		offset = 20K
+		partition-type-uuid = 5B193300-FC78-40CD-8002-E86C45580B47
+	}
+
+	partition u-boot {
+		image = "u-boot.itb"
+		offset = 1044K
+		partition-type-uuid = 2E54B353-1271-4842-806F-E436D6AF6985
+	}
+}
board/sifive/hifive-unleashed/linux.config.fragment +4 -10
index f4f384088a..385a961dd4 100644
@@ -1,16 +1,10 @@
 CONFIG_HZ_100=y
-CONFIG_CMDLINE="earlycon=sbi root=/dev/mmcblk0p2 rootwait"
-CONFIG_DEVTMPFS_MOUNT=y
-CONFIG_SERIAL_SIFIVE=y
-CONFIG_SERIAL_SIFIVE_CONSOLE=y
-CONFIG_SPI=y
-CONFIG_SPI_SIFIVE=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_SYSFS=y
 CONFIG_GPIO_SIFIVE=y
-CONFIG_MMC=y
-CONFIG_MMC_SPI=y
-CONFIG_CLK_U54_PRCI=y
-CONFIG_CLK_GEMGXL_MGMT=y
+CONFIG_POWER_RESET_GPIO_RESTART=y
+CONFIG_MTD=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_SPI_NOR=y
 CONFIG_PWM=y
 CONFIG_PWM_SIFIVE=y
board/sifive/hifive-unleashed/post-build.sh new file +2 -0
new file mode 100755
index 0000000000..b418120652
@@ -0,0 +1,2 @@
+#!/bin/sh
+cp $BINARIES_DIR/boot.scr $TARGET_DIR/boot/boot.scr
board/sifive/hifive-unleashed/readme.txt +54 -14

100 lines not on this page · raw message

configs/hifive_unleashed_defconfig +23 -8
index 24576570da..0b87f2588f 100644
@@ -12,29 +12,44 @@ BR2_RISCV_ABI_LP64D=y
 BR2_SYSTEM_DHCP="eth0"
 BR2_TARGET_GENERIC_GETTY=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttySIF0"
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/sifive/hifive-unleashed/post-build.sh"
 BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
-BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/sifive/hifive-unleashed/genimage.cfg"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/sifive/hifive-unleashed/genimage_sdcard.cfg"
 
 # Filesystem
+BR2_TARGET_ROOTFS_CPIO=y
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 
-# Linux headers same as kernel, a 5.1 series
-BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_1=y
+# Linux headers same as kernel, a 5.10 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_10=y
 
 # Kernel
 BR2_LINUX_KERNEL=y
-BR2_LINUX_KERNEL_CUSTOM_GIT=y
-BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/alistair23/linux.git"
-BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="hifive-unleashed-5.1"
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.10"
 BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
 BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/sifive/hifive-unleashed/linux.config.fragment"
 BR2_LINUX_KERNEL_IMAGE=y
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="sifive/hifive-unleashed-a00"
+BR2_LINUX_KERNEL_INSTALL_TARGET=y
 
 # Bootloader
 BR2_TARGET_OPENSBI=y
-BR2_TARGET_OPENSBI_PLAT="sifive/fu540"
-BR2_TARGET_OPENSBI_LINUX_PAYLOAD=y
+BR2_TARGET_OPENSBI_PLAT="generic"
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_CUSTOM_VERSION=y
+BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2021.01"
+BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="sifive_fu540"
+BR2_TARGET_UBOOT_NEEDS_DTC=y
+BR2_TARGET_UBOOT_NEEDS_OPENSBI=y
+BR2_TARGET_UBOOT_FORMAT_ITB=y
+BR2_TARGET_UBOOT_SPL=y
 
 # Host tools
 BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_UBOOT_TOOLS=y
+BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT=y
+BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT_SOURCE="board/sifive/hifive-unleashed/boot.cmd"
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 board/sifive: Update hifive_unleashed_defconfig and genimage.cfg

Quoted 7 lines · On Fri, 29 Jan 2021 12:50:06 +0800 Bin Meng <[email protected]> wrote:

From: Bin Meng <[email protected]>

Update to use the official linux kernel v5.10 instead of an out-of-tree kernel, and use the official U-Boot v2021.01 as the bootloader. Provide two configuration files of genimage for different boot flows:

Quoted 8 lines

- Boot from SD card (default)
- Boot from SPI flash

A boot script is generated to automatically boot the distro.

---

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com