All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support
@ 2018-09-12 10:22 Mark Corbin
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 1/6] linux: add hash file Mark Corbin
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Mark Corbin @ 2018-09-12 10:22 UTC (permalink / raw)
  To: buildroot

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

-- 
2.17.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 1/6] linux: add hash file
  2018-09-12 10:22 [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Mark Corbin
@ 2018-09-12 10:22 ` Mark Corbin
  2018-09-23 19:21   ` Thomas Petazzoni
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 2/6] package/linux-headers: add support for custom headers Mark Corbin
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Mark Corbin @ 2018-09-12 10:22 UTC (permalink / raw)
  To: buildroot

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 <mark.corbin@embecosm.com>
---
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

diff --git a/linux/linux.hash b/linux/linux.hash
new file mode 100644
index 0000000000..84f5312cea
--- /dev/null
+++ b/linux/linux.hash
@@ -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
diff --git a/package/linux-headers/linux-headers.hash b/package/linux-headers/linux-headers.hash
new file mode 120000
index 0000000000..04970e97c1
--- /dev/null
+++ b/package/linux-headers/linux-headers.hash
@@ -0,0 +1 @@
+../../linux/linux.hash
\ No newline at end of file
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 2/6] package/linux-headers: add support for custom headers
  2018-09-12 10:22 [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Mark Corbin
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 1/6] linux: add hash file Mark Corbin
@ 2018-09-12 10:22 ` Mark Corbin
  2018-09-12 15:23   ` Thomas Petazzoni
  2018-09-23 20:12   ` Thomas Petazzoni
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 3/6] arch: allow GCC target options to be optionally overwritten Mark Corbin
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Mark Corbin @ 2018-09-12 10:22 UTC (permalink / raw)
  To: buildroot

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.

Signed-off-by: Mark Corbin <mark.corbin@embecosm.com>
---
 package/linux-headers/Config.in.host   | 40 ++++++++++-
 package/linux-headers/linux-headers.mk | 94 +++++++++++++++-----------
 2 files changed, 93 insertions(+), 41 deletions(-)

diff --git a/package/linux-headers/Config.in.host b/package/linux-headers/Config.in.host
index e11f07f0b0..4f79ccc991 100644
--- a/package/linux-headers/Config.in.host
+++ b/package/linux-headers/Config.in.host
@@ -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
diff --git a/package/linux-headers/linux-headers.mk b/package/linux-headers/linux-headers.mk
index 954c6b7978..6bc60d8d74 100644
--- a/package/linux-headers/linux-headers.mk
+++ b/package/linux-headers/linux-headers.mk
@@ -7,27 +7,50 @@
 # This package is used to provide Linux kernel headers for the
 # internal toolchain backend.
 
+# Set variables depending on whether we are using headers from a kernel
+# build or a standalone header package.
 ifeq ($(BR2_KERNEL_HEADERS_AS_KERNEL),y)
-
+LINUX_HEADERS_CUSTOM_TARBALL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL))
+LINUX_HEADERS_CUSTOM_GIT = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_GIT))
+LINUX_HEADERS_CUSTOM_HG = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_HG))
+LINUX_HEADERS_CUSTOM_SVN = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_SVN))
 LINUX_HEADERS_VERSION = $(call qstrip,$(BR2_LINUX_KERNEL_VERSION))
+LINUX_HEADERS_CUSTOM_TARBALL_LOCATION = \
+$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION))
+LINUX_HEADERS_REPO_URL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL))
+else # ! BR2_KERNEL_HEADERS_AS_KERNEL
+LINUX_HEADERS_CUSTOM_TARBALL = $(call qstrip,$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL))
+LINUX_HEADERS_CUSTOM_GIT = $(call qstrip,$(BR2_KERNEL_HEADERS_CUSTOM_GIT))
+LINUX_HEADERS_CUSTOM_HG =
+LINUX_HEADERS_CUSTOM_SVN =
+LINUX_HEADERS_VERSION = $(call qstrip,$(BR2_DEFAULT_KERNEL_HEADERS))
+LINUX_HEADERS_CUSTOM_TARBALL_LOCATION = \
+$(call qstrip,$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL_LOCATION))
+LINUX_HEADERS_REPO_URL = $(call qstrip,$(BR2_KERNEL_HEADERS_CUSTOM_REPO_URL))
+endif # BR2_KERNEL_HEADERS_AS_KERNEL
+
+# Configure tarball filenames.
+ifeq ($(LINUX_HEADERS_CUSTOM_TARBALL),y)
+LINUX_HEADERS_SOURCE = $(notdir $(LINUX_HEADERS_CUSTOM_TARBALL_LOCATION))
+else ifeq ($(LINUX_HEADERS_CUSTOM_GIT)$(LINUX_HEADERS_CUSTOM_HG)$(LINUX_HEADERS_CUSTOM_SVN),y)
+LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.gz
+else
+LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.xz
+endif
 
-# Compute LINUX_HEADERS_SOURCE and LINUX_HEADERS_SITE from the configuration
-ifeq ($(BR2_LINUX_KERNEL_CUSTOM_TARBALL),y)
-LINUX_HEADERS_TARBALL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION))
-LINUX_HEADERS_SITE = $(patsubst %/,%,$(dir $(LINUX_HEADERS_TARBALL)))
-LINUX_HEADERS_SOURCE = $(notdir $(LINUX_HEADERS_TARBALL))
-else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_GIT),y)
-LINUX_HEADERS_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL))
+# Configure the various kernel source locations.
+ifeq ($(LINUX_HEADERS_CUSTOM_TARBALL),y)
+LINUX_HEADERS_SITE = $(patsubst %/,%,$(dir $(LINUX_HEADERS_CUSTOM_TARBALL_LOCATION)))
+else ifeq ($(LINUX_HEADERS_CUSTOM_GIT),y)
+LINUX_HEADERS_SITE = $(LINUX_HEADERS_REPO_URL)
 LINUX_HEADERS_SITE_METHOD = git
-# use same git tarball as linux kernel
-LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.gz
-else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_HG),y)
-LINUX_HEADERS_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL))
+else ifeq ($(LINUX_HEADERS_CUSTOM_HG),y)
+LINUX_HEADERS_SITE = $(LINUX_HEADERS_REPO_URL)
 LINUX_HEADERS_SITE_METHOD = hg
-# use same hg tarball as linux kernel
-LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.gz
+else ifeq ($(LINUX_HEADERS_CUSTOM_SVN),y)
+LINUX_HEADERS_SITE = $(LINUX_HEADERS_REPO_URL)
+LINUX_HEADERS_SITE_METHOD = svn
 else
-LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.xz
 # In X.Y.Z, get X and Y. We replace dots and dashes by spaces in order
 # to use the $(word) function. We support versions such as 4.0, 3.1,
 # 2.6.32, 2.6.32-rc1, 3.0-rc6, etc.
@@ -37,13 +60,16 @@ else ifeq ($(findstring x3.,x$(LINUX_HEADERS_VERSION)),x3.)
 LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x
 else ifeq ($(findstring x4.,x$(LINUX_HEADERS_VERSION)),x4.)
 LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v4.x
-endif
+endif # x2.6
 # release candidates are in testing/ subdir
 ifneq ($(findstring -rc,$(LINUX_HEADERS_VERSION)),)
 LINUX_HEADERS_SITE := $(LINUX_HEADERS_SITE)/testing
 endif # -rc
-endif
+endif # LINUX_HEADERS_CUSTOM_TARBALL
 
+# Apply any necessary patches if we are using the headers from a kernel
+# build.
+ifeq ($(BR2_KERNEL_HEADERS_AS_KERNEL),y)
 LINUX_HEADERS_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH))
 
 # We rely on the generic package infrastructure to download and apply
@@ -53,35 +79,23 @@ LINUX_HEADERS_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH))
 LINUX_HEADERS_PATCH = $(filter ftp://% http://% https://%,$(LINUX_HEADERS_PATCHES))
 
 define LINUX_HEADERS_APPLY_LOCAL_PATCHES
-	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
+        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
 endef
 
 LINUX_HEADERS_POST_PATCH_HOOKS += LINUX_HEADERS_APPLY_LOCAL_PATCHES
+endif # BR2_KERNEL_HEADERS_AS_KERNEL
 
-else # ! BR2_KERNEL_HEADERS_AS_KERNEL
-
-LINUX_HEADERS_VERSION = $(call qstrip,$(BR2_DEFAULT_KERNEL_HEADERS))
-ifeq ($(findstring x2.6.,x$(LINUX_HEADERS_VERSION)),x2.6.)
-LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v2.6
-else ifeq ($(findstring x3.,x$(LINUX_HEADERS_VERSION)),x3.)
-LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x
-else ifeq ($(findstring x4.,x$(LINUX_HEADERS_VERSION)),x4.)
-LINUX_HEADERS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v4.x
-endif
-LINUX_HEADERS_SOURCE = linux-$(LINUX_HEADERS_VERSION).tar.xz
-
-ifeq ($(BR2_KERNEL_HEADERS_VERSION),y)
+# Skip hash checking for custom kernel headers.
+ifeq ($(BR2_KERNEL_HEADERS_VERSION)$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL)$(BR2_KERNEL_HEADERS_CUSTOM_GIT),y)
 BR_NO_CHECK_HASH_FOR += $(LINUX_HEADERS_SOURCE)
 endif
 
-endif # ! BR2_KERNEL_HEADERS_AS_KERNEL
-
 # linux-headers really is the same as the linux package
 LINUX_HEADERS_DL_SUBDIR = linux
 
@@ -125,7 +139,7 @@ define LINUX_HEADERS_INSTALL_STAGING_CMDS
 			headers_install)
 endef
 
-ifeq ($(BR2_KERNEL_HEADERS_VERSION)$(BR2_KERNEL_HEADERS_AS_KERNEL),y)
+ifeq ($(BR2_KERNEL_HEADERS_VERSION)$(BR2_KERNEL_HEADERS_AS_KERNEL)$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL)$(BR2_KERNEL_HEADERS_CUSTOM_GIT),y)
 define LINUX_HEADERS_CHECK_VERSION
 	$(call check_kernel_headers_version,\
 		$(STAGING_DIR),\
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 3/6] arch: allow GCC target options to be optionally overwritten
  2018-09-12 10:22 [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Mark Corbin
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 1/6] linux: add hash file Mark Corbin
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 2/6] package/linux-headers: add support for custom headers Mark Corbin
@ 2018-09-12 10:22 ` Mark Corbin
  2018-09-23 20:33   ` Thomas Petazzoni
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 4/6] arch: add support for RISC-V 64-bit (riscv64) architecture Mark Corbin
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Mark Corbin @ 2018-09-12 10:22 UTC (permalink / raw)
  To: buildroot

The 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.

Signed-off-by: Mark Corbin <mark.corbin@embecosm.com>
---
 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

diff --git a/Makefile b/Makefile
index 2c6af12989..d636aaeaae 100644
--- a/Makefile
+++ b/Makefile
@@ -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))
diff --git a/arch/arch.mk b/arch/arch.mk
new file mode 100644
index 0000000000..2429567b24
--- /dev/null
+++ b/arch/arch.mk
@@ -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.*))
diff --git a/package/ffmpeg/ffmpeg.mk b/package/ffmpeg/ffmpeg.mk
index cf9abeb102..b8cc696f83 100644
--- a/package/ffmpeg/ffmpeg.mk
+++ b/package/ffmpeg/ffmpeg.mk
@@ -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))
diff --git a/package/freerdp/freerdp.mk b/package/freerdp/freerdp.mk
index 48c407b6b5..91e4ae47ee 100644
--- a/package/freerdp/freerdp.mk
+++ b/package/freerdp/freerdp.mk
@@ -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
 
 #---------------------------------------
diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk
index 1ae9b7edd9..5f6d53f106 100644
--- a/package/gcc/gcc.mk
+++ b/package/gcc/gcc.mk
@@ -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
diff --git a/package/kodi/kodi.mk b/package/kodi/kodi.mk
index 8e8d53d6b0..8d2430ea55 100644
--- a/package/kodi/kodi.mk
+++ b/package/kodi/kodi.mk
@@ -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)
diff --git a/package/kvm-unit-tests/kvm-unit-tests.mk b/package/kvm-unit-tests/kvm-unit-tests.mk
index 54614e2643..92d67fb34b 100644
--- a/package/kvm-unit-tests/kvm-unit-tests.mk
+++ b/package/kvm-unit-tests/kvm-unit-tests.mk
@@ -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
diff --git a/package/meson/meson.mk b/package/meson/meson.mk
index d110e594f5..08e5c505c9 100644
--- a/package/meson/meson.mk
+++ b/package/meson/meson.mk
@@ -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)`)
diff --git a/package/nodejs/nodejs.mk b/package/nodejs/nodejs.mk
index 165f3f109a..4d57cf9010 100644
--- a/package/nodejs/nodejs.mk
+++ b/package/nodejs/nodejs.mk
@@ -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
diff --git a/package/tvheadend/tvheadend.mk b/package/tvheadend/tvheadend.mk
index 4c9cda4d9a..5ebb98b941 100644
--- a/package/tvheadend/tvheadend.mk
+++ b/package/tvheadend/tvheadend.mk
@@ -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 \
diff --git a/package/valgrind/valgrind.mk b/package/valgrind/valgrind.mk
index 11dec607dd..b1ab7e72fc 100644
--- a/package/valgrind/valgrind.mk
+++ b/package/valgrind/valgrind.mk
@@ -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)"
diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk
index 02d992531d..08e61af00b 100644
--- a/toolchain/toolchain-external/pkg-toolchain-external.mk
+++ b/toolchain/toolchain-external/pkg-toolchain-external.mk
@@ -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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 4/6] arch: add support for RISC-V 64-bit (riscv64) architecture
  2018-09-12 10:22 [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Mark Corbin
                   ` (2 preceding siblings ...)
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 3/6] arch: allow GCC target options to be optionally overwritten Mark Corbin
@ 2018-09-12 10:22 ` Mark Corbin
  2018-09-12 15:21   ` Thomas Petazzoni
  2018-09-25 20:06   ` Thomas Petazzoni
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 5/6] boot/riscv-pk: add bootloader for RISC-V architecture Mark Corbin
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Mark Corbin @ 2018-09-12 10:22 UTC (permalink / raw)
  To: buildroot

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 <mark.corbin@embecosm.com>
---
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

diff --git a/DEVELOPERS b/DEVELOPERS
index 8c43ce1b17..1c29da4038 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1286,6 +1286,10 @@ F:	package/lynx/
 N:	Mario Rugiero <mrugiero@gmail.com>
 F:	package/ratpoison/
 
+N:	Mark Corbin <mark.corbin@embecosm.com>
+F:	arch/arch.mk.riscv
+F:	arch/Config.in.riscv
+
 N:	Markos Chandras <markos.chandras@imgtec.com>
 F:	package/harfbuzz/
 F:	package/libsecret/
diff --git a/Makefile b/Makefile
index d636aaeaae..8cec717cdd 100644
--- a/Makefile
+++ b/Makefile
@@ -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/)
 
diff --git a/arch/Config.in b/arch/Config.in
index 7d1aeb2174..8bd57fe1cc 100644
--- a/arch/Config.in
+++ b/arch/Config.in
@@ -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
diff --git a/arch/Config.in.riscv b/arch/Config.in.riscv
new file mode 100644
index 0000000000..8889f81e9b
--- /dev/null
+++ b/arch/Config.in.riscv
@@ -0,0 +1,104 @@
+# RISC-V CPU ISA extensions.
+
+config BR2_RISCV_ISA_RVI
+	bool
+
+config BR2_RISCV_ISA_RVM
+	bool
+
+config BR2_RISCV_ISA_RVA
+	bool
+
+config BR2_RISCV_ISA_RVF
+	bool
+
+config BR2_RISCV_ISA_RVD
+	bool
+
+config BR2_RISCV_ISA_RVC
+	bool
+
+
+choice
+	prompt "Target Architecture Variant"
+	default BR2_riscv_g
+
+config BR2_riscv_g
+	bool "General purpose (G)"
+	select BR2_RISCV_ISA_RVI
+	select BR2_RISCV_ISA_RVM
+	select BR2_RISCV_ISA_RVA
+	select BR2_RISCV_ISA_RVF
+	select BR2_RISCV_ISA_RVD
+	help
+	  General purpose (G) is equivalent to IMAFD.
+
+config BR2_riscv_custom
+	bool "Custom architecture"
+	select BR2_RISCV_ISA_RVI
+	select BR2_RISCV_ISA_CUSTOM_RVA
+
+endchoice
+
+if BR2_riscv_custom
+
+comment "Instruction Set Extensions"
+
+config BR2_RISCV_ISA_CUSTOM_RVM
+	bool "Integer Multiplication and Division (M)"
+	select BR2_RISCV_ISA_RVM
+
+config BR2_RISCV_ISA_CUSTOM_RVA
+	bool "Atomic Instructions (A)"
+	select BR2_RISCV_ISA_RVA
+
+config BR2_RISCV_ISA_CUSTOM_RVF
+	bool "Single-precision Floating-point (F)"
+	select BR2_RISCV_ISA_RVF
+
+config BR2_RISCV_ISA_CUSTOM_RVD
+	bool "Double-precision Floating-point (D)"
+	depends on BR2_RISCV_ISA_RVF
+	select BR2_RISCV_ISA_RVD
+
+config BR2_RISCV_ISA_CUSTOM_RVC
+	bool "Compressed Instructions (C)"
+	select BR2_RISCV_ISA_RVC
+endif
+
+config BR2_RISCV_64
+	bool
+	default y
+	select BR2_ARCH_IS_64
+
+choice
+	prompt "Target ABI"
+	default BR2_RISCV_ABI_LP64
+
+config BR2_RISCV_ABI_LP64
+	bool "lp64"
+	depends on BR2_ARCH_IS_64
+
+config BR2_RISCV_ABI_LP64F
+	bool "lp64f"
+	depends on BR2_ARCH_IS_64 && BR2_RISCV_ISA_RVF
+
+config BR2_RISCV_ABI_LP64D
+	bool "lp64d"
+	depends on BR2_ARCH_IS_64 && BR2_RISCV_ISA_RVD
+endchoice
+
+config BR2_ARCH
+	default "riscv64" if BR2_ARCH_IS_64
+
+config BR2_ENDIAN
+	default "LITTLE"
+
+config BR2_GCC_TARGET_ABI
+	default "lp64" if BR2_RISCV_ABI_LP64
+	default "lp64f" if BR2_RISCV_ABI_LP64F
+	default "lp64d" if BR2_RISCV_ABI_LP64D
+
+config BR2_READELF_ARCH_NAME
+	default "RISC-V"
+
diff --git a/arch/arch.mk.riscv b/arch/arch.mk.riscv
new file mode 100644
index 0000000000..dded5a5943
--- /dev/null
+++ b/arch/arch.mk.riscv
@@ -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
diff --git a/package/binutils/Config.in.host b/package/binutils/Config.in.host
index 21dc84e498..c8c02bca77 100644
--- a/package/binutils/Config.in.host
+++ b/package/binutils/Config.in.host
@@ -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"
diff --git a/package/glibc/glibc.mk b/package/glibc/glibc.mk
index a2eb8714b1..ad5d79cee0 100644
--- a/package/glibc/glibc.mk
+++ b/package/glibc/glibc.mk
@@ -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
 
diff --git a/package/linux-headers/Config.in.host b/package/linux-headers/Config.in.host
index 4f79ccc991..817ad2c57a 100644
--- a/package/linux-headers/Config.in.host
+++ b/package/linux-headers/Config.in.host
@@ -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
diff --git a/toolchain/toolchain-buildroot/Config.in b/toolchain/toolchain-buildroot/Config.in
index 75e8191f46..7d9428c70e 100644
--- a/toolchain/toolchain-buildroot/Config.in
+++ b/toolchain/toolchain-buildroot/Config.in
@@ -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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 5/6] boot/riscv-pk: add bootloader for RISC-V architecture
  2018-09-12 10:22 [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Mark Corbin
                   ` (3 preceding siblings ...)
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 4/6] arch: add support for RISC-V 64-bit (riscv64) architecture Mark Corbin
@ 2018-09-12 10:22 ` Mark Corbin
  2018-09-25 20:08   ` Thomas Petazzoni
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 6/6] configs/qemu: add qemu_riscv64_virt_defconfig Mark Corbin
  2018-09-12 15:18 ` [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Thomas Petazzoni
  6 siblings, 1 reply; 18+ messages in thread
From: Mark Corbin @ 2018-09-12 10:22 UTC (permalink / raw)
  To: buildroot

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 <mark.corbin@embecosm.com>
---
 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

diff --git a/DEVELOPERS b/DEVELOPERS
index 1c29da4038..4d6c599aea 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1289,6 +1289,7 @@ F:	package/ratpoison/
 N:	Mark Corbin <mark.corbin@embecosm.com>
 F:	arch/arch.mk.riscv
 F:	arch/Config.in.riscv
+F:	boot/riscv-pk/
 
 N:	Markos Chandras <markos.chandras@imgtec.com>
 F:	package/harfbuzz/
diff --git a/boot/Config.in b/boot/Config.in
index 3687c41a2c..945168bf37 100644
--- a/boot/Config.in
+++ b/boot/Config.in
@@ -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"
diff --git a/boot/riscv-pk/Config.in b/boot/riscv-pk/Config.in
new file mode 100644
index 0000000000..ec49f6aa6d
--- /dev/null
+++ b/boot/riscv-pk/Config.in
@@ -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
diff --git a/boot/riscv-pk/riscv-pk.mk b/boot/riscv-pk/riscv-pk.mk
new file mode 100644
index 0000000000..9eee7e0a82
--- /dev/null
+++ b/boot/riscv-pk/riscv-pk.mk
@@ -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))
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 6/6] configs/qemu: add qemu_riscv64_virt_defconfig
  2018-09-12 10:22 [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Mark Corbin
                   ` (4 preceding siblings ...)
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 5/6] boot/riscv-pk: add bootloader for RISC-V architecture Mark Corbin
@ 2018-09-12 10:22 ` Mark Corbin
  2018-09-25 20:10   ` Thomas Petazzoni
  2018-09-12 15:18 ` [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Thomas Petazzoni
  6 siblings, 1 reply; 18+ messages in thread
From: Mark Corbin @ 2018-09-12 10:22 UTC (permalink / raw)
  To: buildroot

Add RISC-V 64-bit defconfig for QEMU virt machine.

Tested with QEMU 2.12.1

Signed-off-by: Mark Corbin <mark.corbin@embecosm.com>
---
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

diff --git a/DEVELOPERS b/DEVELOPERS
index 4d6c599aea..afd24853c6 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1289,7 +1289,9 @@ F:	package/ratpoison/
 N:	Mark Corbin <mark.corbin@embecosm.com>
 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 <markos.chandras@imgtec.com>
 F:	package/harfbuzz/
diff --git a/board/qemu/riscv64-virt/linux.config b/board/qemu/riscv64-virt/linux.config
new file mode 100644
index 0000000000..d09e8b3bb1
--- /dev/null
+++ b/board/qemu/riscv64-virt/linux.config
@@ -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
diff --git a/board/qemu/riscv64-virt/readme.txt b/board/qemu/riscv64-virt/readme.txt
new file mode 100644
index 0000000000..9f6e35c867
--- /dev/null
+++ b/board/qemu/riscv64-virt/readme.txt
@@ -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
diff --git a/configs/qemu_riscv64_virt_defconfig b/configs/qemu_riscv64_virt_defconfig
new file mode 100644
index 0000000000..59343ee98f
--- /dev/null
+++ b/configs/qemu_riscv64_virt_defconfig
@@ -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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support
  2018-09-12 10:22 [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Mark Corbin
                   ` (5 preceding siblings ...)
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 6/6] configs/qemu: add qemu_riscv64_virt_defconfig Mark Corbin
@ 2018-09-12 15:18 ` Thomas Petazzoni
  2018-09-12 16:14   ` Mark Corbin
  6 siblings, 1 reply; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-12 15:18 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 12 Sep 2018 11:22:50 +0100, Mark Corbin wrote:

> 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

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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 4/6] arch: add support for RISC-V 64-bit (riscv64) architecture
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 4/6] arch: add support for RISC-V 64-bit (riscv64) architecture Mark Corbin
@ 2018-09-12 15:21   ` Thomas Petazzoni
  2018-09-25 20:06   ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-12 15:21 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 12 Sep 2018 11:22:54 +0100, Mark Corbin wrote:

> +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) \
> +	)

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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 2/6] package/linux-headers: add support for custom headers
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 2/6] package/linux-headers: add support for custom headers Mark Corbin
@ 2018-09-12 15:23   ` Thomas Petazzoni
  2018-09-23 20:12   ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-12 15:23 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 12 Sep 2018 11:22:52 +0100, Mark Corbin wrote:

>  define LINUX_HEADERS_APPLY_LOCAL_PATCHES
> -	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
> +        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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support
  2018-09-12 15:18 ` [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Thomas Petazzoni
@ 2018-09-12 16:14   ` Mark Corbin
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Corbin @ 2018-09-12 16:14 UTC (permalink / raw)
  To: buildroot

Hello Thomas

On 12/09/18 16:18, Thomas Petazzoni wrote:
> Hello,
>
> On Wed, 12 Sep 2018 11:22:50 +0100, Mark Corbin wrote:
>
>> 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
> 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

>
> Best regards,
>
> Thomas

-- 
Mark Corbin
Embecosm Ltd.
https://www.embecosm.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 1/6] linux: add hash file
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 1/6] linux: add hash file Mark Corbin
@ 2018-09-23 19:21   ` Thomas Petazzoni
  2018-09-23 19:39     ` Fabio Estevam
  0 siblings, 1 reply; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-23 19:21 UTC (permalink / raw)
  To: buildroot

Hello Mark,

Fabio, Bernd: please see below.

On Wed, 12 Sep 2018 11:22:51 +0100, Mark Corbin wrote:
> 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 <mark.corbin@embecosm.com>
> ---
> 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

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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 1/6] linux: add hash file
  2018-09-23 19:21   ` Thomas Petazzoni
@ 2018-09-23 19:39     ` Fabio Estevam
  0 siblings, 0 replies; 18+ messages in thread
From: Fabio Estevam @ 2018-09-23 19:39 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

On Sun, Sep 23, 2018 at 4:21 PM, Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:

> 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!

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 2/6] package/linux-headers: add support for custom headers
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 2/6] package/linux-headers: add support for custom headers Mark Corbin
  2018-09-12 15:23   ` Thomas Petazzoni
@ 2018-09-23 20:12   ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-23 20:12 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 12 Sep 2018 11:22:52 +0100, Mark Corbin wrote:
> 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.
> 
> Signed-off-by: Mark Corbin <mark.corbin@embecosm.com>
> ---
>  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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 3/6] arch: allow GCC target options to be optionally overwritten
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 3/6] arch: allow GCC target options to be optionally overwritten Mark Corbin
@ 2018-09-23 20:33   ` Thomas Petazzoni
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-23 20:33 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 12 Sep 2018 11:22:53 +0100, Mark Corbin wrote:

>  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))

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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 4/6] arch: add support for RISC-V 64-bit (riscv64) architecture
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 4/6] arch: add support for RISC-V 64-bit (riscv64) architecture Mark Corbin
  2018-09-12 15:21   ` Thomas Petazzoni
@ 2018-09-25 20:06   ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-25 20:06 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 12 Sep 2018 11:22:54 +0100, Mark Corbin wrote:
> 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 <mark.corbin@embecosm.com>

I have applied this commit, after doing a few changes, see below.


> +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)

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.

> +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) \
> +	)

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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 5/6] boot/riscv-pk: add bootloader for RISC-V architecture
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 5/6] boot/riscv-pk: add bootloader for RISC-V architecture Mark Corbin
@ 2018-09-25 20:08   ` Thomas Petazzoni
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-25 20:08 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 12 Sep 2018 11:22:55 +0100, Mark Corbin wrote:
> 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 <mark.corbin@embecosm.com>

I have applied, after doing some minor changes, see below.

> diff --git a/boot/riscv-pk/Config.in b/boot/riscv-pk/Config.in
> new file mode 100644
> index 0000000000..ec49f6aa6d
> --- /dev/null
> +++ b/boot/riscv-pk/Config.in
> @@ -0,0 +1,13 @@
> +comment "riscv-pk (BBL) needs a Linux kernel to be built"

Changed to just "riscv-pk needs ..."

> +	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.

> +	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.

> +	  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.

> +	)
> +endef
> +
> +define RISCV_PK_BUILD_CMDS
> +	$(TARGET_MAKE_ENV) $(MAKE) \
> +		-C $(@D)/build bbl

Changed this to be on one single line.

> +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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v2 6/6] configs/qemu: add qemu_riscv64_virt_defconfig
  2018-09-12 10:22 ` [Buildroot] [PATCH v2 6/6] configs/qemu: add qemu_riscv64_virt_defconfig Mark Corbin
@ 2018-09-25 20:10   ` Thomas Petazzoni
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2018-09-25 20:10 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 12 Sep 2018 11:22:56 +0100, Mark Corbin wrote:
> Add RISC-V 64-bit defconfig for QEMU virt machine.
> 
> Tested with QEMU 2.12.1
> 
> Signed-off-by: Mark Corbin <mark.corbin@embecosm.com>
> ---
> 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

I've applied to master, thanks! The only thing I did is
regenerate .gitlab-ci.yml to include this new defconfig.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-09-25 20:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12 10:22 [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Mark Corbin
2018-09-12 10:22 ` [Buildroot] [PATCH v2 1/6] linux: add hash file Mark Corbin
2018-09-23 19:21   ` Thomas Petazzoni
2018-09-23 19:39     ` Fabio Estevam
2018-09-12 10:22 ` [Buildroot] [PATCH v2 2/6] package/linux-headers: add support for custom headers Mark Corbin
2018-09-12 15:23   ` Thomas Petazzoni
2018-09-23 20:12   ` Thomas Petazzoni
2018-09-12 10:22 ` [Buildroot] [PATCH v2 3/6] arch: allow GCC target options to be optionally overwritten Mark Corbin
2018-09-23 20:33   ` Thomas Petazzoni
2018-09-12 10:22 ` [Buildroot] [PATCH v2 4/6] arch: add support for RISC-V 64-bit (riscv64) architecture Mark Corbin
2018-09-12 15:21   ` Thomas Petazzoni
2018-09-25 20:06   ` Thomas Petazzoni
2018-09-12 10:22 ` [Buildroot] [PATCH v2 5/6] boot/riscv-pk: add bootloader for RISC-V architecture Mark Corbin
2018-09-25 20:08   ` Thomas Petazzoni
2018-09-12 10:22 ` [Buildroot] [PATCH v2 6/6] configs/qemu: add qemu_riscv64_virt_defconfig Mark Corbin
2018-09-25 20:10   ` Thomas Petazzoni
2018-09-12 15:18 ` [Buildroot] [PATCH v2 0/6] Add RISC-V 64-bit architecture support Thomas Petazzoni
2018-09-12 16:14   ` Mark Corbin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.