Add support for HiFive Unleashed board
Subsystems (2)
v2 cover Add support for HiFive Unleashed board
Hello
I've regenerated the patches to add support for the SiFive HiFive Unleashed board. I tried to add support for a 5.0 series kernel, but couldn't get the system to boot. This needs further investigation, so I've gone with my original plan to use the 4.20.17 kernel. I've created a new github repository for the patched kernel. This will eventually be deprecated in favour of a 5.0 or 5.1 series kernel.
Changes v1 -> v2:
- moved generation of bbl binary file in riscv-pk.mk from INSTALL_CMDS to BUILD_CMDS (Arnout)
- added new patch to modify riscv-pk build scripts to remove hardcoding of ABI.
- removed the large kernel patch and replaced it with a custom git repository (Arnout)
- reduced the kernel config fragment to a minimum (Arnout)
- use a separate root filesystem instead of a linked-in initramfs image (Arnout)
- changed naming convention from sifive-u540* to sifive_hifive* (Arnout)
- added post-image script to generate a complete SD card image file (Arnout)
- updated the default configuration to make use of compressed instructions and the lp64d ABI for builds.
- updated the DEVELOPERS file.
Regards
Mark
Mark Corbin (3):
boot/riscv-pk: add generation of binary bbl file boot/riscv-pk: remove hardcoding of the ABI board/sifive: add support for the HiFive Unleashed board
DEVELOPERS | 1 + .../hifive-unleashed/linux.config.fragment | 14 ++++ board/sifive/hifive-unleashed/post-image.sh | 37 ++++++++++ board/sifive/hifive-unleashed/readme.txt | 65 +++++++++++++++++ ...-specify-ABI-or-use-compiler-default.patch | 72 +++++++++++++++++++ boot/riscv-pk/riscv-pk.mk | 7 +- configs/sifive_hifive_unleashed_defconfig | 31 ++++++++ 7 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 board/sifive/hifive-unleashed/linux.config.fragment create mode 100755 board/sifive/hifive-unleashed/post-image.sh create mode 100644 board/sifive/hifive-unleashed/readme.txt create mode 100644 boot/riscv-pk/0001-Add-ability-to-specify-ABI-or-use-compiler-default.patch create mode 100644 configs/sifive_hifive_unleashed_defconfig
Signature · 1 line
2.19.1
PATCH v2 1/3 boot/riscv-pk: add generation of binary bbl file
In order to support the SiFive HiFive Unleashed board we need to generate a binary bootloader file ready for writing to an SD card.
---
Changes v1 -> v2:
- moved generation of bbl binary file in riscv-pk.mk from INSTALL_CMDS to BUILD_CMDS (Arnout)
--- boot/riscv-pk/riscv-pk.mk | 2 ++ 1 file changed, 2 insertions(+)
boot/riscv-pk/riscv-pk.mk +2 -0
@@ -23,10 +23,12 @@ endef define RISCV_PK_BUILD_CMDS $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build bbl + $(TARGET_OBJCOPY) -S -O binary $(@D)/build/bbl $(@D)/build/bbl.bin endef define RISCV_PK_INSTALL_IMAGES_CMDS $(INSTALL) -D -m 0755 $(@D)/build/bbl $(BINARIES_DIR)/bbl + $(INSTALL) -D -m 0755 $(@D)/build/bbl.bin $(BINARIES_DIR)/bbl.bin endef $(eval $(generic-package))
Signature · 1 line
2.19.1
PATCH v2 2/3 boot/riscv-pk: remove hardcoding of the ABI
In reply to Mark CorbinThe riscv-pk package is currently hardcoded to always use the softfloat ABI when compiling, i.e. ilp32 for 32-bit and lp64 for 64-bit. The SiFive HiFive Unleashed board has hardware floating point support, so we need to be able to build riscv-pk with both softfloat and hardfloat toolchains.
This patch adds the ability to specify the ABI via --with-abi when configuring riscv-pk. If this option is not provided then the compiler default ABI setting will be used instead.
--- ...-specify-ABI-or-use-compiler-default.patch | 72 +++++++++++++++++++ boot/riscv-pk/riscv-pk.mk | 5 +- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 boot/riscv-pk/0001-Add-ability-to-specify-ABI-or-use-compiler-default.patch
boot/riscv-pk/0001-Add-ability-to-specify-ABI-or-use-compiler-default.patch new file +72 -0
@@ -0,0 +1,72 @@ +From 0f7e2c2f61c6bb36a33733e89ec8d79f89d618ae Mon Sep 17 00:00:00 2001 +From: Mark Corbin <[email protected]> +Date: Thu, 18 Apr 2019 12:07:02 +0100 +Subject: [PATCH] Add ability to specify ABI or use compiler default + +Allow the ABI to be defined using --with-abi. If this option is +not provided then the compiler default ABI setting will be used. + +Signed-off-by: Mark Corbin <[email protected]> +--- + Makefile.in | 15 +++++++++++---- + configure.ac | 4 ++++ + 2 files changed, 15 insertions(+), 4 deletions(-) + +diff --git a/Makefile.in b/Makefile.in +index aeabdc2..d6b988f 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -51,8 +51,7 @@ else + endif + + # If --with-arch is not specified, it defaults to whatever the compiler's +-# default is. The -with-abi is not necessary for this project. Unconditionally +-# compile it with a no-float ABI. i.e., ilp32 for 32-bit and lp64 for 64-bit. ++# default is. + + ifeq (@WITH_ARCH@,) + march := -march=$(shell @CC@ -v 2>&1 | \ +@@ -60,8 +59,16 @@ ifeq (@WITH_ARCH@,) + else + march := -march=@WITH_ARCH@ + endif +-is_32bit := $(findstring 32,$(march)) +-mabi := -mabi=$(if $(is_32bit),ilp32,lp64) ++ ++# If --with-abi is not specified, it defaults to whatever the compiler's ++# default is. ++ ++ifeq (@WITH_ABI@,) ++ mabi := -mabi=$(shell @CC@ -v 2>&1 | \ ++ sed 's/ /\n/g' | grep with-abi | awk -F= '{print $$2}') ++else ++ mabi := -mabi=@WITH_ABI@ ++endif + + # Installation directories + +diff --git a/configure.ac b/configure.ac +index 917179f..180a8db 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -83,6 +83,9 @@ AC_ARG_VAR(RISCV, [top-level RISC-V install directory]) + AC_ARG_WITH([arch], AS_HELP_STRING([--with-arch], [Set the RISC-V architecture]), + [AC_SUBST([WITH_ARCH], $with_arch, [Specify architecture to build the project])]) + ++AC_ARG_WITH([abi], AS_HELP_STRING([--with-abi], [Set the RISC-V ABI]), ++ [AC_SUBST([WITH_ABI], $with_abi, [Specify ABI to build the project])]) ++ + AC_ARG_ENABLE([print-device-tree], AS_HELP_STRING([--enable-print-device-tree], [Print DTS when booting])) + AS_IF([test "x$enable_print_device_tree" == "xyes"], [ + AC_DEFINE([PK_PRINT_DEVICE_TREE],,[Define if the DTS is to be displayed]) +@@ -95,6 +98,7 @@ AC_SUBST(CFLAGS) + AC_SUBST(LDFLAGS) + AC_SUBST([LIBS], ["-lgcc"]) + AC_SUBST(WITH_ARCH) ++AC_SUBST(WITH_ABI) + AC_SUBST(host_alias) + + #------------------------------------------------------------------------- +-- +2.19.1 +
boot/riscv-pk/riscv-pk.mk +3 -2
@@ -9,8 +9,9 @@ RISCV_PK_SITE = git://github.com/riscv/riscv-pk.git RISCV_PK_LICENSE = BSD-3-Clause RISCV_PK_LICENSE_FILES = LICENSE RISCV_PK_DEPENDENCIES = linux -RISCV_PK_SUBDIR = build +RISCV_PK_INSTALL_TARGET = NO RISCV_PK_INSTALL_IMAGES = YES +RISCV_PK_AUTORECONF = YES define RISCV_PK_CONFIGURE_CMDS mkdir -p $(@D)/build
@@ -31,4 +32,4 @@ define RISCV_PK_INSTALL_IMAGES_CMDS $(INSTALL) -D -m 0755 $(@D)/build/bbl.bin $(BINARIES_DIR)/bbl.bin endef -$(eval $(generic-package)) +$(eval $(autotools-package))
Signature · 1 line
2.19.1
PATCH v2 3/3 board/sifive: add support for the HiFive Unleashed board
In reply to Mark CorbinThis patch adds basic support for the SiFive HiFive Unleashed board.
---
Changes v1 -> v2:
- removed the large kernel patch and replaced it with a custom git repository (Arnout)
- reduced the kernel config fragment to a minimum (Arnout)
- use a separate root filesystem instead of a linked-in initramfs image (Arnout)
- changed naming convention from sifive-u540* to sifive_hifive* (Arnout)
- added post-image script to generate a complete SD card image file (Arnout)
- updated the default configuration to make use of compressed instructions and the lp64d ABI for builds.
- updated the DEVELOPERS file.
--- DEVELOPERS | 1 + .../hifive-unleashed/linux.config.fragment | 14 ++++ board/sifive/hifive-unleashed/post-image.sh | 37 +++++++++++ board/sifive/hifive-unleashed/readme.txt | 65 +++++++++++++++++++ configs/sifive_hifive_unleashed_defconfig | 31 +++++++++ 5 files changed, 148 insertions(+) create mode 100644 board/sifive/hifive-unleashed/linux.config.fragment create mode 100755 board/sifive/hifive-unleashed/post-image.sh create mode 100644 board/sifive/hifive-unleashed/readme.txt create mode 100644 configs/sifive_hifive_unleashed_defconfig
DEVELOPERS +1 -0
@@ -1417,6 +1417,7 @@ F: arch/arch.mk.riscv F: arch/Config.in.riscv F: board/qemu/riscv32-virt/ F: board/qemu/riscv64-virt/ +F: board/sifive/ F: boot/riscv-pk/ F: configs/qemu_riscv32_virt_defconfig F: configs/qemu_riscv64_virt_defconfig
board/sifive/hifive-unleashed/linux.config.fragment new file +14 -0
@@ -0,0 +1,14 @@ +CONFIG_CMDLINE_BOOL=y +CONFIG_CMDLINE="earlyprintk console=ttySIF0,115200 root=/dev/mmcblk0p2 rootwait" +CONFIG_SERIAL_SIFIVE=y +CONFIG_SERIAL_SIFIVE_CONSOLE=y +# CONFIG_HVC_RISCV_SBI is not set +CONFIG_SPI=y +CONFIG_SPI_SIFIVE=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SIFIVE=y +CONFIG_MMC=y +CONFIG_MMC_SPI=y +CONFIG_CLK_U54_PRCI=y +CONFIG_CLK_GEMGXL_MGMT=y +CONFIG_SIFIVE_PLIC=y
board/sifive/hifive-unleashed/post-image.sh new file +37 -0
@@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + +cd ${BINARIES_DIR} + +# GPT partition codes +KERNEL=2E54B353-1271-4842-806F-E436D6AF6985 +ROOTFS=0FC63DAF-8483-4772-8E79-3D69D8477DE4 + +# Partition offsets and sizes +KERNEL_PART_START=2048 +KERNEL_PART_SIZE=65536 +KERNEL_PART_END=$(( KERNEL_PART_START + KERNEL_PART_SIZE - 1 )) +ROOTFS_PART_START=$(( KERNEL_PART_END + 1 )) +ROOTFS_PART_SIZE=$(( $(stat -c %s rootfs.ext2) / 512 )) +ROOTFS_PART_END=$(( ROOTFS_PART_START + ROOTFS_PART_SIZE - 1 )) +GPT_SIZE=34 + +# Disk image size +IMAGE_SIZE=$(( GPT_SIZE + ROOTFS_PART_END + 1 )) + +# Create an empty SD image +dd if=/dev/zero of=sdcard.img bs=512 count=0 seek=$IMAGE_SIZE + +sgdisk --clear \ + --new=1:${KERNEL_PART_START}:${KERNEL_PART_END} \ + --change-name=1:kernel \ + --typecode=1:${KERNEL} \ + --new=2:${ROOTFS_PART_START}:${ROOTFS_PART_END} \ + --change-name=2:rootfs \ + --typecode=2:${ROOTFS} \ + sdcard.img + +dd if=bbl.bin of=sdcard.img bs=512 count=$KERNEL_PART_SIZE seek=$KERNEL_PART_START conv=notrunc +dd if=rootfs.ext2 of=sdcard.img bs=512 count=$ROOTFS_PART_SIZE seek=$ROOTFS_PART_START conv=notrunc +
board/sifive/hifive-unleashed/readme.txt new file +65 -0
65 lines not on this page · raw message
configs/sifive_hifive_unleashed_defconfig new file +31 -0
@@ -0,0 +1,31 @@ +# Architecture +BR2_riscv=y +BR2_riscv_custom=y +BR2_RISCV_ISA_CUSTOM_RVM=y +BR2_RISCV_ISA_CUSTOM_RVF=y +BR2_RISCV_ISA_CUSTOM_RVD=y +BR2_RISCV_ISA_CUSTOM_RVC=y +BR2_RISCV_64=y +BR2_RISCV_ABI_LP64D=y + +# Linux headers same as kernel, a 4.20 series +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_20=y + +# System +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/sifive/hifive-unleashed/post-image.sh" + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_GIT=y +BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/markcorbinuk/linux.git" +BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="hifive-4.20.17" +BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y +BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/sifive/hifive-unleashed/linux.config.fragment" +BR2_LINUX_KERNEL_VMLINUX=y + +# Bootloader +BR2_TARGET_RISCV_PK=y + +# Filesystem +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_ROOTFS_EXT2_4=y
Signature · 1 line
2.19.1