Add RISC-V 64-bit architecture support
Subsystems (3)
v2 cover Add RISC-V 64-bit architecture support
This patch set adds support for the RISC-V 64-bit architecture.
Full RISC-V support is not expected in the upstream kernel until the 4.19 release. As a result the ability to select custom toolchain headers has been added. This allows a RISC-V toolchain to be built against kernel headers from a git repository without having to build a kernel.
A new method for overriding the BR2_GCC_TARGET_* settings has been added. These variables are copied to corresponding GCC_TARGET_* variables which may then be modified using architecture specific makefiles (arch/arch.mk.<arch>). This allows a custom architecture string to be built for the RISC-V from the various optional ISA extensions. All package makefiles that were using the BR2_GCC_TARGET_* variables have been updated to use the GCC_TARGET_* versions. Any new makefiles must use the new variables.
The default glibc library paths for RISC-V are /lib64/<abi> and /usr/lib64/<abi>. An architecture specific patch has been applied to glibc.mk to override these settings and allow shared libraries to be located by packages at runtime.
The riscv-pk (Proxy Kernel) package has been added to provide the Berkeley Boot Loader (BBL) for booting RISC-V kernels.
A new defconfig has been added which can build a qemu-bootable RISC-V 64-bit system.
Mark Corbin (6):
linux: add hash file
package/linux-headers: add support for custom headers
arch: allow GCC target options to be optionally overwritten
arch: add support for RISC-V 64-bit (riscv64) architecture boot/riscv-pk: add bootloader for RISC-V architecture configs/qemu: add qemu_riscv64_virt_defconfig
DEVELOPERS | 7 ++ Makefile | 5 +- arch/Config.in | 15 +++ arch/Config.in.riscv | 104 ++++++++++++++++++ arch/arch.mk | 17 +++ arch/arch.mk.riscv | 30 +++++ board/qemu/riscv64-virt/linux.config | 23 ++++ board/qemu/riscv64-virt/readme.txt | 7 ++ boot/Config.in | 1 + boot/riscv-pk/Config.in | 13 +++ boot/riscv-pk/riscv-pk.mk | 33 ++++++ configs/qemu_riscv64_virt_defconfig | 24 ++++ linux/linux.hash | 9 ++ package/binutils/Config.in.host | 2 + package/ffmpeg/ffmpeg.mk | 8 +- package/freerdp/freerdp.mk | 2 +- package/gcc/gcc.mk | 27 ++--- package/glibc/glibc.mk | 30 +++-- package/kodi/kodi.mk | 2 +- package/kvm-unit-tests/kvm-unit-tests.mk | 2 +- package/linux-headers/Config.in.host | 45 +++++++- package/linux-headers/linux-headers.hash | 1 + package/linux-headers/linux-headers.mk | 94 +++++++++------- package/meson/meson.mk | 2 +- package/nodejs/nodejs.mk | 2 +- package/tvheadend/tvheadend.mk | 2 +- package/valgrind/valgrind.mk | 2 +- toolchain/toolchain-buildroot/Config.in | 6 +- .../pkg-toolchain-external.mk | 22 ++-- 29 files changed, 447 insertions(+), 90 deletions(-) create mode 100644 arch/Config.in.riscv create mode 100644 arch/arch.mk create mode 100644 arch/arch.mk.riscv create mode 100644 board/qemu/riscv64-virt/linux.config create mode 100644 board/qemu/riscv64-virt/readme.txt create mode 100644 boot/riscv-pk/Config.in create mode 100644 boot/riscv-pk/riscv-pk.mk create mode 100644 configs/qemu_riscv64_virt_defconfig create mode 100644 linux/linux.hash create mode 120000 package/linux-headers/linux-headers.hash
Signature · 1 line
2.17.1
PATCH v2 1/6 linux: add hash file
Added a hash file for the Linux kernel. Hashes have been copied from the appropriate sha256sums.asc files on kernel.org. The Linux hash file is also shared with the linux-headers package via a symbolic link.
---
Changes v1 -> v2:
- update hashes for latest kernel versions
--- linux/linux.hash | 9 +++++++++ package/linux-headers/linux-headers.hash | 1 + 2 files changed, 10 insertions(+) create mode 100644 linux/linux.hash create mode 120000 package/linux-headers/linux-headers.hash
linux/linux.hash new file +9 -0
@@ -0,0 +1,9 @@ +# From https://www.kernel.org/pub/linux/kernel/v4.x/sha256sums.asc +sha256 f03b425e262a71e5079736706233a4e9afaf77c8462b552b4d6db2d33f5af731 linux-4.18.7.tar.xz +sha256 41026d713ba4f7a5e9d514b876ce4ed28a1d993c0c58b42b2a2597d6a0e83021 linux-4.16.18.tar.xz +sha256 61bdd5fbb0e33362d27476e7d8aade0aa1ad11ddb5959a27094c254cc03b19f0 linux-4.14.69.tar.xz +sha256 6d6a66c757d496460fbcb443063afd989eb5194521273720102e027318985bb5 linux-4.9.126.tar.xz +sha256 18098c4bae107d37f61474d38049a1ea7c718bcfc859f9b87382933a3a426dd9 linux-4.4.155.tar.xz +sha256 6ad9389e55e0ea57768eae173747058a4487fa3630e10a7999cfec9f945e559c linux-4.1.52.tar.xz +# From https://www.kernel.org/pub/linux/kernel/v3.x/sha256sums.asc +sha256 ad96d797571496c969aa71bf5d08e9d2a8c84458090d29a120f1b2981185a99e linux-3.2.102.tar.xz
package/linux-headers/linux-headers.hash new file +1 -0
@@ -0,0 +1 @@ +../../linux/linux.hash
Signature · 1 line
2.17.1
Thomas Petazzoni
AppliedPATCH v2 1/6 linux: add hash file
Hello Mark,
Fabio, Bernd: please see below.
Quoted 9 lines · Mark Corbin
Added a hash file for the Linux kernel. Hashes have been copied from the appropriate sha256sums.asc files on kernel.org. The Linux hash file is also shared with the linux-headers package via a symbolic link.
Signed-off-by Mark Corbin <[email protected]>---
Changes v1 -> v2:
- update hashes for latest kernel versions
Quoted 6 lines
--- linux/linux.hash | 9 +++++++++ package/linux-headers/linux-headers.hash | 1 + 2 files changed, 10 insertions(+) create mode 100644 linux/linux.hash create mode 120000 package/linux-headers/linux-headers.hash
Applied to master, thanks. I have adjusted the .hash file with the recent changes of the linux-headers package.
Bernd, Fabio: this commit means that there is some additional work to do know when you bump the kernel headers / kernel version: you need to adjust linux/linux.hash.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 1/6 linux: add hash file
Hi Thomas,
Quoted 3 lines · Thomas Petazzoni
Bernd, Fabio: this commit means that there is some additional work to do know when you bump the kernel headers / kernel version: you need to adjust linux/linux.hash.
Got it. Thanks for the heads up!
PATCH v2 2/6 package/linux-headers: add support for custom headers
In reply to Mark CorbinAdd support for building toolchains against custom headers. Allows the selection of a manual version, custom tarball or custom git repository for the kernel headers. This enables toolchains to be built against custom kernel headers without having to build a full kernel.
This is particularly useful for new architectures, such as RISC-V where updated kernel headers may not have made it into the mainline kernel yet.
--- package/linux-headers/Config.in.host | 40 ++++++++++- package/linux-headers/linux-headers.mk | 94 +++++++++++++++----------- 2 files changed, 93 insertions(+), 41 deletions(-)
package/linux-headers/Config.in.host +39 -1
@@ -70,6 +70,23 @@ config BR2_KERNEL_HEADERS_VERSION URL at kernel.org. Instead, select "Custom tarball" and specify the right URL directly. +config BR2_KERNEL_HEADERS_CUSTOM_TARBALL + bool "Custom tarball" + help + This option allows you to specify a URL pointing to a kernel + source tarball. This URL can use any protocol recognized by + Buildroot, like http://, ftp://, file:// or scp://. + + When pointing to a local tarball using file://, you may want + to use a make variable like $(TOPDIR) to reference the root of + the Buildroot tree. + +config BR2_KERNEL_HEADERS_CUSTOM_GIT + bool "Custom Git repository" + help + This option allows Buildroot to get the Linux kernel source + code from a Git repository. + endchoice config BR2_DEFAULT_KERNEL_VERSION
@@ -79,9 +96,27 @@ config BR2_DEFAULT_KERNEL_VERSION Specify the version you want to use. E.G.: 3.6.10 +config BR2_KERNEL_HEADERS_CUSTOM_TARBALL_LOCATION + string "URL of custom kernel tarball" + depends on BR2_KERNEL_HEADERS_CUSTOM_TARBALL + +if BR2_KERNEL_HEADERS_CUSTOM_GIT + +config BR2_KERNEL_HEADERS_CUSTOM_REPO_URL + string "URL of custom repository" + +config BR2_KERNEL_HEADERS_CUSTOM_REPO_VERSION + string "Custom repository version" + help + Revision to use in the typical format used by + Git/Mercurial/Subversion E.G. a sha id, a tag, branch, .. + +endif + choice bool "Custom kernel headers series" - depends on BR2_KERNEL_HEADERS_VERSION || BR2_KERNEL_HEADERS_AS_KERNEL + depends on BR2_KERNEL_HEADERS_VERSION || BR2_KERNEL_HEADERS_AS_KERNEL || \ + BR2_KERNEL_HEADERS_CUSTOM_TARBALL || BR2_KERNEL_HEADERS_CUSTOM_GIT help Specify the kernel headers series you manually selected, above.
@@ -260,3 +295,6 @@ config BR2_DEFAULT_KERNEL_HEADERS default "4.16.18" if BR2_KERNEL_HEADERS_4_16 default "4.18.7" if BR2_KERNEL_HEADERS_4_18 default BR2_DEFAULT_KERNEL_VERSION if BR2_KERNEL_HEADERS_VERSION + default "custom" if BR2_KERNEL_HEADERS_CUSTOM_TARBALL + default BR2_KERNEL_HEADERS_CUSTOM_REPO_VERSION \ + if BR2_KERNEL_HEADERS_CUSTOM_GIT
package/linux-headers/linux-headers.mk +54 -40
136 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 2/6 package/linux-headers: add support for custom headers
Hello,
Quoted 5 lines · Mark Corbin
define
LINUX_HEADERS_APPLY_LOCAL_PATCHESpackage/linux-headers/linux-headers.mk +0
-4- for p in $(filter-out ftp://% http://% https://%,$(LINUX_HEADERS_PATCHES)) ; do \ - if test -d $$p ; then \ - $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \ - else \
package/linux-headers/linux-headers.mk LINUX_HEADERS_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH)) · line 88
Quoted 10 lines
package/linux-headers/linux-headers.mk +7
-3- $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \ - fi \ - done + for p in $(filter-out ftp://% http://% https://%,$(LINUX_HEADERS_PATCHES)) ; do \ + if test -d $$p ; then \ + $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \ + else \ + $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \ + fi \ + done
This change is spurious: you just replaced the tab-based indentation by space-based indentation, which is not good.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 2/6 package/linux-headers: add support for custom headers
In reply to Mark CorbinHello,
Quoted 10 lines · Mark Corbin
Add support for building toolchains against custom headers. Allows the selection of a manual version, custom tarball or custom git repository for the kernel headers. This enables toolchains to be built against custom kernel headers without having to build a full kernel.
This is particularly useful for new architectures, such as RISC-V where updated kernel headers may not have made it into the mainline kernel yet.
Quoted 5 lines
Signed-off-by Mark Corbin <[email protected]>--- package/linux-headers/Config.in.host | 40 ++++++++++- package/linux-headers/linux-headers.mk | 94 +++++++++++++++----------- 2 files changed, 93 insertions(+), 41 deletions(-)
I have applied, but after doing two changes:
- Dropping the spurious change of indentation in the LINUX_HEADERS_APPLY_LOCAL_PATCHES hook.
- Splitting this commit into two. A first commit does just the reorganization of linux-headers.mk, another adds support for custom tarball/git in linux-headers.
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 3/6 arch: allow GCC target options to be optionally overwritten
In reply to Mark CorbinThe BR2_GCC_TARGET_* configuration variables are copied to corresponding GCC_TARGET_* variables which may then be optionally modified or overwritten by architecture specific makefiles.
All makefiles must use the new GCC_TARGET_* variables instead of the BR2_GCC_TARGET_* versions.
--- Makefile | 4 +-- arch/arch.mk | 17 ++++++++++++ package/ffmpeg/ffmpeg.mk | 8 +++--- package/freerdp/freerdp.mk | 2 +- package/gcc/gcc.mk | 27 +++++++++---------- package/kodi/kodi.mk | 2 +- package/kvm-unit-tests/kvm-unit-tests.mk | 2 +- package/meson/meson.mk | 2 +- package/nodejs/nodejs.mk | 2 +- package/tvheadend/tvheadend.mk | 2 +- package/valgrind/valgrind.mk | 2 +- .../pkg-toolchain-external.mk | 22 +++++++-------- 12 files changed, 53 insertions(+), 39 deletions(-) create mode 100644 arch/arch.mk
Makefile +2 -2
@@ -493,9 +493,9 @@ include Makefile.legacy include system/system.mk include package/Makefile.in -# arch/arch.mk.* must be after package/Makefile.in because it may need to +# arch/arch.mk must be after package/Makefile.in because it may need to # complement variables defined therein, like BR_NO_CHECK_HASH_FOR. --include $(sort $(wildcard arch/arch.mk.*)) +-include $(sort $(wildcard arch/arch.mk)) include support/dependencies/dependencies.mk include $(sort $(wildcard toolchain/*.mk))
arch/arch.mk new file +17 -0
@@ -0,0 +1,17 @@ +# Allow GCC target configuration settings to be optionally +# overwritten by architecture specific makefiles. + +# Makefiles must use the GCC_TARGET_* variables below instead +# of the BR2_GCC_TARGET_* versions. +GCC_TARGET_ARCH := $(call qstrip,$(BR2_GCC_TARGET_ARCH)) +GCC_TARGET_ABI := $(call qstrip,$(BR2_GCC_TARGET_ABI)) +GCC_TARGET_NAN := $(call qstrip,$(BR2_GCC_TARGET_NAN)) +GCC_TARGET_FP32_MODE := $(call qstrip,$(BR2_GCC_TARGET_FP32_MODE)) +GCC_TARGET_CPU := $(call qstrip,$(BR2_GCC_TARGET_CPU)) +GCC_TARGET_CPU_REVISION := $(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)) +GCC_TARGET_FPU := $(call qstrip,$(BR2_GCC_TARGET_FPU)) +GCC_TARGET_FLOAT_ABI := $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI)) +GCC_TARGET_MODE := $(call qstrip,$(BR2_GCC_TARGET_MODE)) + +# Include any architecture specific makefiles. +-include $(sort $(wildcard arch/arch.mk.*))
package/ffmpeg/ffmpeg.mk +4 -4
@@ -511,10 +511,10 @@ endif # warning from ffmpeg's configure script. ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y) FFMPEG_CONF_OPTS += --cpu=generic -else ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),) -FFMPEG_CONF_OPTS += --cpu=$(BR2_GCC_TARGET_CPU) -else ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),) -FFMPEG_CONF_OPTS += --cpu=$(BR2_GCC_TARGET_ARCH) +else ifneq ($(GCC_TARGET_CPU),) +FFMPEG_CONF_OPTS += --cpu="$(GCC_TARGET_CPU)" +else ifneq ($(GCC_TARGET_ARCH),) +FFMPEG_CONF_OPTS += --cpu="$(GCC_TARGET_ARCH)" endif FFMPEG_CONF_OPTS += $(call qstrip,$(BR2_PACKAGE_FFMPEG_EXTRACONF))
package/freerdp/freerdp.mk +1 -1
@@ -77,7 +77,7 @@ FREERDP_CONF_OPTS += -DWITH_SSE2=OFF endif ifeq ($(BR2_arm)$(BR2_armeb),y) -FREERDP_CONF_OPTS += -DARM_FP_ABI=$(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI)) +FREERDP_CONF_OPTS += -DARM_FP_ABI=$(GCC_TARGET_FLOAT_ABI) endif #---------------------------------------
package/gcc/gcc.mk +12 -15
@@ -200,39 +200,36 @@ HOST_GCC_COMMON_CONF_OPTS += --disable-decimal-float endif # Determine arch/tune/abi/cpu options -ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),) -HOST_GCC_COMMON_CONF_OPTS += --with-arch=$(BR2_GCC_TARGET_ARCH) +ifneq ($(GCC_TARGET_ARCH),) +HOST_GCC_COMMON_CONF_OPTS += --with-arch="$(GCC_TARGET_ARCH)" endif -ifneq ($(call qstrip,$(BR2_GCC_TARGET_ABI)),) -HOST_GCC_COMMON_CONF_OPTS += --with-abi=$(BR2_GCC_TARGET_ABI) +ifneq ($(GCC_TARGET_ABI),) +HOST_GCC_COMMON_CONF_OPTS += --with-abi="$(GCC_TARGET_ABI)" endif ifeq ($(BR2_TOOLCHAIN_HAS_MNAN_OPTION),y) -ifneq ($(call qstrip,$(BR2_GCC_TARGET_NAN)),) -HOST_GCC_COMMON_CONF_OPTS += --with-nan=$(BR2_GCC_TARGET_NAN) +ifneq ($(GCC_TARGET_NAN),) +HOST_GCC_COMMON_CONF_OPTS += --with-nan="$(GCC_TARGET_NAN)" endif endif -ifneq ($(call qstrip,$(BR2_GCC_TARGET_FP32_MODE)),) -HOST_GCC_COMMON_CONF_OPTS += --with-fp-32=$(BR2_GCC_TARGET_FP32_MODE) +ifneq ($(GCC_TARGET_FP32_MODE),) +HOST_GCC_COMMON_CONF_OPTS += --with-fp-32="$(GCC_TARGET_FP32_MODE)" endif -ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),) -ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),) -HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION)) +ifneq ($(GCC_TARGET_CPU),) +ifneq ($(GCC_TARGET_CPU_REVISION),) +HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(GCC_TARGET_CPU)-$(GCC_TARGET_CPU_REVISION) else -HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(call qstrip,$(BR2_GCC_TARGET_CPU)) +HOST_GCC_COMMON_CONF_OPTS += --with-cpu=$(GCC_TARGET_CPU) endif endif -GCC_TARGET_FPU = $(call qstrip,$(BR2_GCC_TARGET_FPU)) ifneq ($(GCC_TARGET_FPU),) HOST_GCC_COMMON_CONF_OPTS += --with-fpu=$(GCC_TARGET_FPU) endif -GCC_TARGET_FLOAT_ABI = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI)) ifneq ($(GCC_TARGET_FLOAT_ABI),) HOST_GCC_COMMON_CONF_OPTS += --with-float=$(GCC_TARGET_FLOAT_ABI) endif -GCC_TARGET_MODE = $(call qstrip,$(BR2_GCC_TARGET_MODE)) ifneq ($(GCC_TARGET_MODE),) HOST_GCC_COMMON_CONF_OPTS += --with-mode=$(GCC_TARGET_MODE) endif
package/kodi/kodi.mk +1 -1
@@ -88,7 +88,7 @@ KODI_DEPENDENCIES += rpi-userland # These CPU-specific options are only used on rbpi: # https://github.com/xbmc/xbmc/blob/Krypton/project/cmake/scripts/rbpi/ArchSetup.cmake#L13 ifeq ($(BR2_arm1176jzf_s)$(BR2_cortex_a7)$(BR2_cortex_a53),y) -KODI_CONF_OPTS += -DWITH_CPU=$(BR2_GCC_TARGET_CPU) +KODI_CONF_OPTS += -DWITH_CPU="$(GCC_TARGET_CPU)" endif else ifeq ($(BR2_arceb)$(BR2_arcle),y)
package/kvm-unit-tests/kvm-unit-tests.mk +1 -1
@@ -28,7 +28,7 @@ endif KVM_UNIT_TESTS_CONF_OPTS =\ --arch="$(KVM_UNIT_TESTS_ARCH)" \ - --processor="$(call qstrip,$(BR2_GCC_TARGET_CPU))" \ + --processor="$(GCC_TARGET_CPU)" \ --endian="$(KVM_UNIT_TESTS_ENDIAN)" # For all architectures but x86-64, we use the target
package/meson/meson.mk +1 -1
@@ -14,7 +14,7 @@ HOST_MESON_DEPENDENCIES = host-ninja HOST_MESON_NEEDS_HOST_PYTHON = python3 HOST_MESON_TARGET_ENDIAN = $(call LOWERCASE,$(BR2_ENDIAN)) -HOST_MESON_TARGET_CPU = $(call qstrip,$(BR2_GCC_TARGET_CPU)) +HOST_MESON_TARGET_CPU = $(GCC_TARGET_CPU) HOST_MESON_SED_CFLAGS = $(if $(TARGET_CFLAGS),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`) HOST_MESON_SED_LDFLAGS = $(if $(TARGET_LDFLAGS),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
package/nodejs/nodejs.mk +1 -1
@@ -96,7 +96,7 @@ NODEJS_CPU = arm else ifeq ($(BR2_aarch64),y) NODEJS_CPU = arm64 # V8 needs to know what floating point ABI the target is using. -NODEJS_ARM_FP = $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI)) +NODEJS_ARM_FP = $(GCC_TARGET_FLOAT_ABI) endif # MIPS architecture specific options
package/tvheadend/tvheadend.mk +1 -1
@@ -114,7 +114,7 @@ define TVHEADEND_CONFIGURE_CMDS ./configure \ --prefix=/usr \ --arch="$(ARCH)" \ - --cpu="$(BR2_GCC_TARGET_CPU)" \ + --cpu="$(GCC_TARGET_CPU)" \ --nowerror \ --python="$(HOST_DIR)/bin/python" \ --enable-dvbscan \
package/valgrind/valgrind.mk +1 -1
@@ -31,7 +31,7 @@ VALGRIND_CFLAGS = \ # and pass the right -march option, so they take precedence over # Valgrind's wrongfully detected value. ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y) -VALGRIND_CFLAGS += -march=$(BR2_GCC_TARGET_ARCH) +VALGRIND_CFLAGS += -march="$(GCC_TARGET_ARCH)" endif VALGRIND_CONF_ENV = CFLAGS="$(VALGRIND_CFLAGS)"
toolchain/toolchain-external/pkg-toolchain-external.mk +11 -11
@@ -151,18 +151,18 @@ TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS)) # Definition of the CFLAGS to use with the external toolchain, as well as the # common toolchain wrapper build arguments # -ifeq ($(call qstrip,$(BR2_GCC_TARGET_CPU_REVISION)),) -CC_TARGET_CPU_ := $(call qstrip,$(BR2_GCC_TARGET_CPU)) +ifeq ($(GCC_TARGET_CPU_REVISION),) +CC_TARGET_CPU_ := $(GCC_TARGET_CPU) else -CC_TARGET_CPU_ := $(call qstrip,$(BR2_GCC_TARGET_CPU)-$(BR2_GCC_TARGET_CPU_REVISION)) -endif -CC_TARGET_ARCH_ := $(call qstrip,$(BR2_GCC_TARGET_ARCH)) -CC_TARGET_ABI_ := $(call qstrip,$(BR2_GCC_TARGET_ABI)) -CC_TARGET_NAN_ := $(call qstrip,$(BR2_GCC_TARGET_NAN)) -CC_TARGET_FP32_MODE_ := $(call qstrip,$(BR2_GCC_TARGET_FP32_MODE)) -CC_TARGET_FPU_ := $(call qstrip,$(BR2_GCC_TARGET_FPU)) -CC_TARGET_FLOAT_ABI_ := $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI)) -CC_TARGET_MODE_ := $(call qstrip,$(BR2_GCC_TARGET_MODE)) +CC_TARGET_CPU_ := $(GCC_TARGET_CPU)-$(GCC_TARGET_CPU_REVISION) +endif +CC_TARGET_ARCH_ := $(GCC_TARGET_ARCH) +CC_TARGET_ABI_ := $(GCC_TARGET_ABI) +CC_TARGET_NAN_ := $(GCC_TARGET_NAN) +CC_TARGET_FP32_MODE_ := $(GCC_TARGET_FP32_MODE) +CC_TARGET_FPU_ := $(GCC_TARGET_FPU) +CC_TARGET_FLOAT_ABI_ := $(GCC_TARGET_FLOAT_ABI) +CC_TARGET_MODE_ := $(GCC_TARGET_MODE) # march/mtune/floating point mode needs to be passed to the external toolchain # to select the right multilib variant
Signature · 1 line
2.17.1
PATCH v2 3/6 arch: allow GCC target options to be optionally overwritten
Hello,
Makefile include Makefile.legacy · line 498
Quoted 7 lines · Mark Corbin
include
system/system.mk
include package/Makefile.inMakefile +2
-2-# arch/arch.mk.* must be after package/Makefile.in because it may need to +# arch/arch.mk must be after package/Makefile.in because it may need to # complement variables defined therein, like BR_NO_CHECK_HASH_FOR. --include $(sort $(wildcard arch/arch.mk.*)) +-include $(sort $(wildcard arch/arch.mk))
This sort + wildcard + conditional include was no longer needed, since we include a single file, and we know this file exists, so I've simplified this line to:
include arch/arch.mk
and then I've applied to master. Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 4/6 arch: add support for RISC-V 64-bit (riscv64) architecture
In reply to Mark CorbinThis enables a riscv64 system to be built with a Buildroot generated toolchain (gcc >= 7.x, binutils >= 2.30, glibc only).
This configuration has been used to successfully build a qemu-bootable riscv-linux-4.15 kernel (https://github.com/riscv/riscv-linux.git).
---
Changes v1 -> v2:
- updated DEVELOPERS file (Thomas P)
- changed BR2_riscv64 to BR2_riscv to match kernel architecture (Arnout)
- MMU now mandatory instead of optional (Thomas P)
- moved selection of minimum gcc version to BR2_riscv (Thomas P)
- forced selection of ISA atomic extensions as it is required for glibc (Thomas P)
- add blind BR2_RISCV_64 option for later use with a 32-bit option (Arnout)
- updated generation of GCC_TARGET_ARCH to use new override feature in arch/arch.mk (Thomas P)
- added library path override for glibc to avoid default paths that include the ABI
- disable selection of linux header versions for versions that don't support RISC-V (Arnout)
- removed explicit selection of default C library (Thomas P)
- removed comment relating to atomic instructions with glibc (Arnout)
- removed explicit selection of default binutils version (Thomas P)
--- DEVELOPERS | 4 + Makefile | 1 + arch/Config.in | 15 ++++ arch/Config.in.riscv | 104 ++++++++++++++++++++++++ arch/arch.mk.riscv | 30 +++++++ package/binutils/Config.in.host | 2 + package/glibc/glibc.mk | 30 +++++-- package/linux-headers/Config.in.host | 5 ++ toolchain/toolchain-buildroot/Config.in | 6 +- 9 files changed, 187 insertions(+), 10 deletions(-) create mode 100644 arch/Config.in.riscv create mode 100644 arch/arch.mk.riscv
DEVELOPERS +4 -0
@@ -1286,6 +1286,10 @@ F: package/lynx/ N: Mario Rugiero <[email protected]> F: package/ratpoison/ +N: Mark Corbin <[email protected]> +F: arch/arch.mk.riscv +F: arch/Config.in.riscv + N: Markos Chandras <[email protected]> F: package/harfbuzz/ F: package/libsecret/
Makefile +1 -0
@@ -433,6 +433,7 @@ KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \ -e s/parisc64/parisc/ \ -e s/powerpc64.*/powerpc/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/riscv.*/riscv/ \ -e s/sh.*/sh/ \ -e s/microblazeel/microblaze/)
arch/Config.in +15 -0
@@ -198,6 +198,17 @@ config BR2_powerpc64le http://www.power.org/ http://en.wikipedia.org/wiki/Powerpc +config BR2_riscv + bool "RISCV" + select BR2_ARCH_HAS_MMU_MANDATORY + select BR2_ARCH_NEEDS_GCC_AT_LEAST_7 + help + RISC-V is an open, free Instruction Set Architecture created + by the UC Berkeley Architecture Research group and supported + and promoted by RISC-V Foundation. + https://riscv.org/ + https://en.wikipedia.org/wiki/RISC-V + config BR2_sh bool "SuperH" select BR2_ARCH_HAS_MMU_OPTIONAL
@@ -423,6 +434,10 @@ if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le source "arch/Config.in.powerpc" endif +if BR2_riscv +source "arch/Config.in.riscv" +endif + if BR2_sh source "arch/Config.in.sh" endif
arch/Config.in.riscv new file +104 -0
104 lines not on this page · raw message
arch/arch.mk.riscv new file +30 -0
@@ -0,0 +1,30 @@ +# +# Configure the GCC_TARGET_ARCH variable and append the +# appropriate RISC-V ISA extensions. +# + +ifeq ($(BR2_riscv),y) + +ifeq ($(BR2_ARCH_IS_64),y) +RISCV_GCC_ARCH = rv64i +endif + +ifeq ($(BR2_RISCV_ISA_RVM),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)m +endif +ifeq ($(BR2_RISCV_ISA_RVA),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)a +endif +ifeq ($(BR2_RISCV_ISA_RVF),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)f +endif +ifeq ($(BR2_RISCV_ISA_RVD),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)d +endif +ifeq ($(BR2_RISCV_ISA_RVC),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)c +endif + +GCC_TARGET_ARCH := $(RISCV_GCC_ARCH) + +endif
package/binutils/Config.in.host +2 -0
@@ -12,9 +12,11 @@ choice config BR2_BINUTILS_VERSION_2_28_X bool "binutils 2.28.1" depends on !BR2_arc + depends on !BR2_riscv config BR2_BINUTILS_VERSION_2_29_X bool "binutils 2.29.1" + depends on !BR2_riscv config BR2_BINUTILS_VERSION_2_30_X bool "binutils 2.30"
package/glibc/glibc.mk +22 -8
@@ -82,6 +82,26 @@ endif # Note that as mentionned in # http://patches.openembedded.org/patch/38849/, glibc must be # built with -O2, so we pass our own CFLAGS and CXXFLAGS below. + +GLIBC_CONF_OPTS = \ + --with-pkgversion="Buildroot" \ + --without-cvs \ + --disable-profile \ + --without-gd \ + --enable-obsolete-rpc \ + --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)) \ + --with-headers=$(STAGING_DIR)/usr/include + +ifeq ($(BR2_x86_64),y) +GLIBC_CONF_OPTS += --enable-lock-elision +endif + +# Override the default library locations of /lib64/<abi> and +# /usr/lib64/<abi>/ for RISC-V. +ifeq ($(BR2_riscv),y) +GLIBC_CONF_OPTS += libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib +endif + define GLIBC_CONFIGURE_CMDS mkdir -p $(@D)/build # Do the configuration
@@ -98,14 +118,8 @@ define GLIBC_CONFIGURE_CMDS --build=$(GNU_HOST_NAME) \ --prefix=/usr \ --enable-shared \ - $(if $(BR2_x86_64),--enable-lock-elision) \ - --with-pkgversion="Buildroot" \ - --without-cvs \ - --disable-profile \ - --without-gd \ - --enable-obsolete-rpc \ - --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)) \ - --with-headers=$(STAGING_DIR)/usr/include) + $(GLIBC_CONF_OPTS) \ + ) $(GLIBC_ADD_MISSING_STUB_H) endef
package/linux-headers/Config.in.host +5 -0
@@ -29,22 +29,27 @@ config BR2_KERNEL_HEADERS_AS_KERNEL config BR2_KERNEL_HEADERS_3_2 bool "Linux 3.2.x kernel headers" depends on !BR2_aarch64 && !BR2_arc && !BR2_nios2 + depends on !BR2_riscv select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_2 config BR2_KERNEL_HEADERS_4_1 bool "Linux 4.1.x kernel headers" + depends on !BR2_riscv select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_1 config BR2_KERNEL_HEADERS_4_4 bool "Linux 4.4.x kernel headers" + depends on !BR2_riscv select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_4 config BR2_KERNEL_HEADERS_4_9 bool "Linux 4.9.x kernel headers" + depends on !BR2_riscv select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_9 config BR2_KERNEL_HEADERS_4_14 bool "Linux 4.14.x kernel headers" + depends on !BR2_riscv select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_14 config BR2_KERNEL_HEADERS_4_16
toolchain/toolchain-buildroot/Config.in +4 -2
@@ -46,14 +46,16 @@ config BR2_TOOLCHAIN_BUILDROOT_GLIBC BR2_aarch64_be || BR2_i386 || BR2_mips || \ BR2_mipsel || BR2_mips64 || BR2_mips64el|| \ BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le || \ - BR2_sh || BR2_sparc64 || BR2_x86_64 || \ - BR2_microblaze || BR2_nios2 || BR2_archs38 + BR2_riscv || BR2_sh || BR2_sparc64 || \ + BR2_x86_64 || BR2_microblaze || BR2_nios2 || \ + BR2_archs38 depends on BR2_USE_MMU depends on !BR2_STATIC_LIBS depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_2 depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10 || !BR2_powerpc64le depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_5 || !BR2_MIPS_NAN_2008 depends on !BR2_powerpc_SPE + depends on BR2_RISCV_ISA_RVA || !BR2_riscv select BR2_TOOLCHAIN_USES_GLIBC # our glibc.mk enables RPC support select BR2_TOOLCHAIN_HAS_NATIVE_RPC
Signature · 1 line
2.17.1
PATCH v2 4/6 arch: add support for RISC-V 64-bit (riscv64) architecture
Hello,
Quoted 26 lines · Mark Corbin
package/glibc/glibc.mk +19
-0+GLIBC_CONF_OPTS = \ + --with-pkgversion="Buildroot" \ + --without-cvs \ + --disable-profile \ + --without-gd \ + --enable-obsolete-rpc \ + --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)) \ + --with-headers=$(STAGING_DIR)/usr/include + +ifeq ($(BR2_x86_64),y) +GLIBC_CONF_OPTS += --enable-lock-elision +endif + +# Override the default library locations of /lib64/<abi> and +# /usr/lib64/<abi>/ for RISC-V. +ifeq ($(BR2_riscv),y) +GLIBC_CONF_OPTS += libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib +endif + define GLIBC_CONFIGURE_CMDS mkdir -p $(@D)/build # Do the configuration@@ -98,14 +118,8 @@ define GLIBC_CONFIGURE_CMDS --build=$(GNU_HOST_NAME) \ --prefix=/usr \ --enable-shared \
package/glibc/glibc.mk define GLIBC_CONFIGURE_CMDS · line 122
Quoted 10 lines
package/glibc/glibc.mk +2
-8- $(if $(BR2_x86_64),--enable-lock-elision) \ - --with-pkgversion="Buildroot" \ - --without-cvs \ - --disable-profile \ - --without-gd \ - --enable-obsolete-rpc \ - --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)) \ - --with-headers=$(STAGING_DIR)/usr/include) + $(GLIBC_CONF_OPTS) \ + )
This refactor of GLIBC_CONF_OPTS should have been a preparatory patch, so that the small addition of GLIBC_CONF_OPTS specifically related to RISC-V is the only portion part of the RISC-V architecture patch.
However, I think those variables lib_cv_* should not go in GLIBC_CONF_OPTS, but in GLIBC_CONF_ENV, since that's how we do it in all other autotools-based packages. But we indeed have a bunch of such variables already:
ac_cv_path_BASH_SHELL=/bin/bash \
libc_cv_forced_unwind=yes \
libc_cv_ssp=no \So perhaps we need a first preparatory patch that move these to GLIBC_CONF_ENV, and then your RISC-V architecture patch.
At this point, no need to resend such for this, this is the sort of thing that we can fixup while applying. We'll see if there are more comments on the rest of the series that require a new iteration.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 4/6 arch: add support for RISC-V 64-bit (riscv64) architecture
In reply to Mark CorbinHello,
Quoted 7 lines · Mark Corbin
This enables a riscv64 system to be built with a Buildroot generated toolchain (gcc >= 7.x, binutils >= 2.30, glibc only).
This configuration has been used to successfully build a qemu-bootable riscv-linux-4.15 kernel (https://github.com/riscv/riscv-linux.git).
Signed-off-by Mark Corbin <[email protected]>
I have applied this commit, after doing a few changes, see below.
Quoted 13 lines
arch/arch.mk.riscv new file +13
-0+ifeq ($(BR2_riscv),y) + +ifeq ($(BR2_ARCH_IS_64),y) +RISCV_GCC_ARCH = rv64i +endif + +ifeq ($(BR2_RISCV_ISA_RVM),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)m +endif +ifeq ($(BR2_RISCV_ISA_RVA),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)a +endif +ifeq ($(BR2_RISCV_ISA_RVF),y)
arch/arch.mk.riscv line 28
Quoted 10 lines
arch/arch.mk.riscv new file +10
-0+RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)f +endif +ifeq ($(BR2_RISCV_ISA_RVD),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)d +endif +ifeq ($(BR2_RISCV_ISA_RVC),y) +RISCV_GCC_ARCH := $(RISCV_GCC_ARCH)c +endif + +GCC_TARGET_ARCH := $(RISCV_GCC_ARCH)
In this file, I didn't see the point of the intermediate RISCV_GCC_ARCH variable. So I've changed to use GCC_TARGET_ARCH directly.
Quoted 26 lines
package/glibc/glibc.mk +19
-0+GLIBC_CONF_OPTS = \ + --with-pkgversion="Buildroot" \ + --without-cvs \ + --disable-profile \ + --without-gd \ + --enable-obsolete-rpc \ + --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)) \ + --with-headers=$(STAGING_DIR)/usr/include + +ifeq ($(BR2_x86_64),y) +GLIBC_CONF_OPTS += --enable-lock-elision +endif + +# Override the default library locations of /lib64/<abi> and +# /usr/lib64/<abi>/ for RISC-V. +ifeq ($(BR2_riscv),y) +GLIBC_CONF_OPTS += libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib +endif + define GLIBC_CONFIGURE_CMDS mkdir -p $(@D)/build # Do the configuration@@ -98,14 +118,8 @@ define GLIBC_CONFIGURE_CMDS --build=$(GNU_HOST_NAME) \ --prefix=/usr \ --enable-shared \
package/glibc/glibc.mk define GLIBC_CONFIGURE_CMDS · line 122
Quoted 10 lines
package/glibc/glibc.mk +2
-8- $(if $(BR2_x86_64),--enable-lock-elision) \ - --with-pkgversion="Buildroot" \ - --without-cvs \ - --disable-profile \ - --without-gd \ - --enable-obsolete-rpc \ - --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)) \ - --with-headers=$(STAGING_DIR)/usr/include) + $(GLIBC_CONF_OPTS) \ + )
As I commented in an earlier review, libc_cv_* should be passed in the environment, like other autoconf cache variables. So I did a preliminary commit that creates a GLIBC_CONF_ENV variable, passed in the glibc ./configure script environment, and that contains the existing autoconf cache variables we were passing.
Then I adjusted your commit to simply add those libc_cv_* variables to GLIBC_CONF_ENV:
+# Override the default library locations of /lib64/<abi> and +# /usr/lib64/<abi>/ for RISC-V.
+ifeq ($(BR2_riscv),y)
+GLIBC_CONF_ENV += libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib +endif
Thanks a lot for this contribution!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 5/6 boot/riscv-pk: add bootloader for RISC-V architecture
In reply to Mark CorbinAdd the RISC-V Proxy Kernel (pk) package which provides the Berkeley Boot Loader for booting RISC-V kernel images.
--- DEVELOPERS | 1 + boot/Config.in | 1 + boot/riscv-pk/Config.in | 13 +++++++++++++ boot/riscv-pk/riscv-pk.mk | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 boot/riscv-pk/Config.in create mode 100644 boot/riscv-pk/riscv-pk.mk
DEVELOPERS +1 -0
@@ -1289,6 +1289,7 @@ F: package/ratpoison/ N: Mark Corbin <[email protected]> F: arch/arch.mk.riscv F: arch/Config.in.riscv +F: boot/riscv-pk/ N: Markos Chandras <[email protected]> F: package/harfbuzz/
boot/Config.in +1 -0
@@ -13,6 +13,7 @@ source "boot/gummiboot/Config.in" source "boot/lpc32xxcdl/Config.in" source "boot/mv-ddr-marvell/Config.in" source "boot/mxs-bootlets/Config.in" +source "boot/riscv-pk/Config.in" source "boot/s500-bootloader/Config.in" source "boot/syslinux/Config.in" source "boot/ts4800-mbrboot/Config.in"
boot/riscv-pk/Config.in new file +13 -0
@@ -0,0 +1,13 @@ +comment "riscv-pk (BBL) needs a Linux kernel to be built" + depends on BR2_riscv + depends on !BR2_LINUX_KERNEL + +config BR2_TARGET_RISCV_PK + bool "riscv-pk (BBL)" + depends on BR2_riscv + depends on BR2_LINUX_KERNEL + help + The RISC-V Proxy Kernel (pk) package contains the Berkeley + Boot Loader (BBL) which has been designed to boot a Linux + kernel on a RISC-V processor. + https://github.com/riscv/riscv-pk.git
boot/riscv-pk/riscv-pk.mk new file +33 -0
@@ -0,0 +1,33 @@ +################################################################################ +# +# riscv-pk (BBL) +# +################################################################################ + +RISCV_PK_VERSION = 706cc77c369fd3e4734b5a6aa813d421347f1814 +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_IMAGES = YES + +define RISCV_PK_CONFIGURE_CMDS + mkdir -p $(@D)/build + (cd $(@D)/build; \ + $(TARGET_CONFIGURE_OPTS) ../configure \ + --host=$(GNU_TARGET_NAME) \ + --with-payload=$(BINARIES_DIR)/vmlinux \ + ) +endef + +define RISCV_PK_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) \ + -C $(@D)/build bbl +endef + +define RISCV_PK_INSTALL_IMAGES_CMDS + cp $(@D)/build/bbl $(BINARIES_DIR) +endef + +$(eval $(generic-package))
Signature · 1 line
2.17.1
PATCH v2 5/6 boot/riscv-pk: add bootloader for RISC-V architecture
Hello,
Quoted 4 lines · Mark Corbin
Add the RISC-V Proxy Kernel (pk) package which provides the Berkeley Boot Loader for booting RISC-V kernel images.
Signed-off-by Mark Corbin <[email protected]>
I have applied, after doing some minor changes, see below.
boot/riscv-pk/Config.in line 1
Quoted 7 lines
boot/riscv-pk/Config.in new file +1
-0@@ -0,0 +1,13 @@ +comment "riscv-pk (BBL) needs a Linux kernel to be built"
Changed to just "riscv-pk needs ..."
boot/riscv-pk/Config.in line 6
Quoted 5 lines
boot/riscv-pk/Config.in new file +5
-0+ depends on BR2_riscv + depends on !BR2_LINUX_KERNEL + +config BR2_TARGET_RISCV_PK + bool "riscv-pk (BBL)"
Changed to just "riscv-pk"
For both changes: our policy is to try to stick to the upstream package name in the Config.in prompt and comments.
boot/riscv-pk/Config.in line 12
Quoted 6 lines
boot/riscv-pk/Config.in new file +6
-0+ depends on BR2_riscv + depends on BR2_LINUX_KERNEL + help + The RISC-V Proxy Kernel (pk) package contains the Berkeley + Boot Loader (BBL) which has been designed to boot a Linux + kernel on a RISC-V processor.
I've added a missing blank line here.
boot/riscv-pk/Config.in
Quoted 8 lines
boot/riscv-pk/Config.in new file +7
-0+ https://github.com/riscv/riscv-pk.git +define RISCV_PK_CONFIGURE_CMDS + mkdir -p $(@D)/build + (cd $(@D)/build; \ + $(TARGET_CONFIGURE_OPTS) ../configure \ + --host=$(GNU_TARGET_NAME) \ + --with-payload=$(BINARIES_DIR)/vmlinux \
I fixed a bit the indentation here.
boot/riscv-pk/Config.in
Quoted 6 lines
boot/riscv-pk/Config.in new file +6
-0+ ) +endef + +define RISCV_PK_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) \ + -C $(@D)/build bbl
Changed this to be on one single line.
boot/riscv-pk/Config.in
Quoted 4 lines
boot/riscv-pk/Config.in new file +4
-0+endef + +define RISCV_PK_INSTALL_IMAGES_CMDS + cp $(@D)/build/bbl $(BINARIES_DIR)
And changed to:
$(INSTALL) -D -m 0755 $(@D)/build/bbl $(BINARIES_DIR)/bbl
Thanks again for this contribution!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 6/6 configs/qemu: add qemu_riscv64_virt_defconfig
In reply to Mark CorbinAdd RISC-V 64-bit defconfig for QEMU virt machine.
Tested with QEMU 2.12.1
---
Changes v1 -> v2:
- updated DEVELOPERS file (Thomas P)
- removed typo from readme.txt and updated text to remove BBL instructions now that it has been integrated as a package (Thomas P)
- selected a specific kernel commit rather than a branch (Thomas P)
- removed explicit selection of BR2_BINUTILS_VERSION_2_30_X (Thomas P)
- added selection of riscv-pk package
--- DEVELOPERS | 2 ++ board/qemu/riscv64-virt/linux.config | 23 +++++++++++++++++++++++ board/qemu/riscv64-virt/readme.txt | 7 +++++++ configs/qemu_riscv64_virt_defconfig | 24 ++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 board/qemu/riscv64-virt/linux.config create mode 100644 board/qemu/riscv64-virt/readme.txt create mode 100644 configs/qemu_riscv64_virt_defconfig
DEVELOPERS +2 -0
@@ -1289,7 +1289,9 @@ F: package/ratpoison/ N: Mark Corbin <[email protected]> F: arch/arch.mk.riscv F: arch/Config.in.riscv +F: board/qemu/riscv64-virt/ F: boot/riscv-pk/ +F: configs/qemu_riscv64_virt_defconfig N: Markos Chandras <[email protected]> F: package/harfbuzz/
board/qemu/riscv64-virt/linux.config new file +23 -0
@@ -0,0 +1,23 @@ +CONFIG_ARCH_RV64I=y +CONFIG_SMP=y +CONFIG_NR_CPUS=8 +CONFIG_PCI=y +CONFIG_SYSVIPC=y +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +# CONFIG_WIRELESS is not set +CONFIG_VIRTIO_BLK=y +CONFIG_NETDEVICES=y +CONFIG_VIRTIO_NET=y +# CONFIG_ETHERNET is not set +# CONFIG_WLAN is not set +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_VIRT_DRIVERS=y +CONFIG_VIRTIO_MMIO=y +CONFIG_EXT2_FS=y +CONFIG_EXT4_FS=y +CONFIG_TMPFS=y
board/qemu/riscv64-virt/readme.txt new file +7 -0
@@ -0,0 +1,7 @@ +Run the emulation with: + + qemu-system-riscv64 -M virt -kernel output/images/bbl -append "root=/dev/vda ro console=ttyS0" -drive file=output/images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic + +The login prompt will appear in the terminal that started Qemu. + +Tested with QEMU 2.12.1
configs/qemu_riscv64_virt_defconfig new file +24 -0
@@ -0,0 +1,24 @@ +# Architecture +BR2_riscv=y + +# System +BR2_SYSTEM_DHCP="eth0" + +# Filesystem +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_GENERIC_GETTY=y +BR2_TARGET_GENERIC_GETTY_PORT="ttyS0" + +# Linux headers same as kernel, a 4.15 series +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_15=y + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_GIT=y +BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/riscv/riscv-linux.git" +BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="fe92d7905c6ea0ebeabeb725b8040754ede7c220" +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/riscv64-virt/linux.config" + +# Bootloader +BR2_TARGET_RISCV_PK=y
Signature · 1 line
2.17.1
Thomas Petazzoni
AppliedPATCH v2 6/6 configs/qemu: add qemu_riscv64_virt_defconfig
Hello,
Quoted 16 lines · Mark Corbin
Add RISC-V 64-bit defconfig for QEMU virt machine.
Tested with QEMU 2.12.1
Signed-off-by Mark Corbin <[email protected]>---
Changes v1 -> v2:
- updated DEVELOPERS file (Thomas P)
- removed typo from readme.txt and updated text to remove BBL instructions now that it has been integrated as a package (Thomas P)
- selected a specific kernel commit rather than a branch (Thomas P)
- removed explicit selection ofBR2_BINUTILS_VERSION_2_30_X(Thomas P)
- added selection of riscv-pk package
Quoted 9 lines
--- DEVELOPERS | 2 ++ board/qemu/riscv64-virt/linux.config | 23 +++++++++++++++++++++++ board/qemu/riscv64-virt/readme.txt | 7 +++++++ configs/qemu_riscv64_virt_defconfig | 24 ++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 board/qemu/riscv64-virt/linux.config create mode 100644 board/qemu/riscv64-virt/readme.txt create mode 100644 configs/qemu_riscv64_virt_defconfig
I've applied to master, thanks! The only thing I did is regenerate .gitlab-ci.yml to include this new defconfig.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
v2 cover Add RISC-V 64-bit architecture support
In reply to Mark CorbinHello,
Quoted 7 lines · Mark Corbin
Mark Corbin (6):
linux: add hash file
package/linux-headers: add support for custom headers
arch: allow GCC target options to be optionally overwritten
arch: add support for RISC-V 64-bit (riscv64) architecture boot/riscv-pk: add bootloader for RISC-V architecture configs/qemu: addqemu_riscv64_virt_defconfig
Thanks a lot for this new version! From a quick look it looks pretty good! I'll comment on each patch separately.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
v2 cover Add RISC-V 64-bit architecture support
Hello Thomas
Quoted 11 lines · Thomas Petazzoni
Hello,
Quoted 7 lines · Mark Corbin
Mark Corbin (6):
linux: add hash file
package/linux-headers: add support for custom headers
arch: allow GCC target options to be optionally overwritten
arch: add support for RISC-V 64-bit (riscv64) architecture boot/riscv-pk: add bootloader for RISC-V architecture configs/qemu: addqemu_riscv64_virt_defconfig
Quoted 2 lines
Thanks a lot for this new version! From a quick look it looks pretty good! I'll comment on each patch separately.
Just let me know which ones, if any, need re-spinning.
Thanks
Mark
Quoted 4 lines
Best regards,
Thomas
Signature · 3 lines
Mark Corbin Embecosm Ltd. https://www.embecosm.com