Skip to contentSkip to conversation

newlib-bare-metal-nano: add new package

PATCH New Steven J. Hill 1 participant 3 messages Oct 5 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 newlib-bare-metal-nano: add new package

Add new package for building of the nano C-runtime used by bare metal toolchains wanting C++ language support. Building of the package will be enabled in future patches.

---
 package/newlib-bare-metal-nano/Config.in      | 10 ++
 .../newlib-bare-metal-nano.hash               |  1 +
 .../newlib-bare-metal-nano.mk                 | 98 +++++++++++++++++++
 package/newlib-bare-metal/Config.in           | 10 ++
 .../toolchain-bare-metal-buildroot/Config.in  | 11 +++
 .../toolchain-bare-metal-buildroot.mk         |  3 +
 6 files changed, 133 insertions(+)
 create mode 100644 package/newlib-bare-metal-nano/Config.in
 create mode 120000 package/newlib-bare-metal-nano/newlib-bare-metal-nano.hash
 create mode 100644 package/newlib-bare-metal-nano/newlib-bare-metal-nano.mk
package/newlib-bare-metal-nano/Config.in new file +10 -0
new file mode 100644
index 0000000000..04e6325917
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_NEWLIB_BARE_METAL_NANO
+	bool
+	default y if BR2_PACKAGE_NEWLIB_BARE_METAL
+	help
+	  newlib-nano is an open source C library (libc) targeting
+	  embedded microcontrollers (MCU). Implementation focus is on
+	  code and data size reduction through optimization and removal
+	  of non-MCU features.
+
+	  https://github.com/32bitmicro/newlib-nano-1.0
package/newlib-bare-metal-nano/newlib-bare-metal-nano.hash new file +1 -0
new file mode 120000
index 0000000000..f5ffcdfaba
@@ -0,0 +1 @@
+../newlib-bare-metal/newlib-bare-metal.hash
\ No newline at end of file
package/newlib-bare-metal-nano/newlib-bare-metal-nano.mk new file +98 -0

98 lines not on this page · raw message

package/newlib-bare-metal/Config.in +10 -0
index 1ff3d5d8ec..33dd57b905 100644
@@ -1,2 +1,12 @@
 config BR2_PACKAGE_NEWLIB_BARE_METAL
 	bool
+	default y if BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
+	help
+	  Newlib is a C library intended for use on embedded systems.
+
+	  Newlib is a C standard library implementation intended for use
+	  on embedded systems. It is a conglomeration of several library
+	  parts, all under free software licenses that make them easily
+	  usable on embedded products.
+
+	  https://sourceware.org/git/newlib-cygwin.git
toolchain/toolchain-bare-metal-buildroot/Config.in +11 -0
index 7ba579b570..65b49d36aa 100644
@@ -26,6 +26,17 @@ config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_MULTILIB
 	  When enabled, this option will apply to all architecture
 	  tuples in the list.
 
+config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_NANO
+	bool "Enable nano"
+	select BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_MULTILIB
+	select BR2_PACKAGE_NEWLIB_BARE_METAL_NANO
+	help
+	  Build the nano newlib libraries to allow support for
+	  other languages like c++ and FORTRAN.
+
+	  When enabled, this option will apply to all architecture
+	  tuples in the list.
+
 source "package/newlib-bare-metal/Config.in"
 
 endif # BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
toolchain/toolchain-bare-metal-buildroot/toolchain-bare-metal-buildroot.mk +3 -0
index 71063fcee4..f261333fcd 100644
@@ -5,6 +5,9 @@
 ################################################################################
 
 TOOLCHAIN_BARE_METAL_BUILDROOT_DEPENDENCIES = newlib-bare-metal
+ifeq ($(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_NANO),y)
+TOOLCHAIN_BARE_METAL_BUILDROOT_DEPENDENCIES += host-gcc-bare-metal-final
+endif
 TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE = $(call qstrip,$(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH))
 TOOLCHAIN_BARE_METAL_BUILDROOT_ADD_TOOLCHAIN_DEPENDENCY = NO
 
Signature · 6 lines
2.47.3

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

PATCH 2/3 bare-metal-toolchain: add support for config options directory

This patch adds the BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_CONFIG_DIR option. The directory holds individual config files with options for all build stages of the toolchain on a per-target basis. For further information on using this, see the documentation file at toolchain/toolchain-bare-metal-buildroot/configs/README.md

---
 .../binutils-bare-metal.mk                    |  5 ++
 package/gcc-bare-metal/gcc-bare-metal.mk      |  5 ++
 .../newlib-bare-metal/newlib-bare-metal.mk    |  5 ++
 .../toolchain-bare-metal-buildroot/Config.in  | 16 +++++++
 .../configs/README.md                         | 47 +++++++++++++++++++
 .../configs/riscv64-unknown-elf.config        | 35 ++++++++++++++
 6 files changed, 113 insertions(+)
 create mode 100755 toolchain/toolchain-bare-metal-buildroot/configs/README.md
 create mode 100644 toolchain/toolchain-bare-metal-buildroot/configs/riscv64-unknown-elf.config
package/binutils-bare-metal/binutils-bare-metal.mk +5 -0
index 343bf44c4d..e3746e0146 100644
@@ -49,6 +49,7 @@ define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
 		CONFIG_SITE=/dev/null \
 		$(@D)/configure \
 			$(HOST_BINUTILS_BARE_METAL_CONF_OPTS) \
+			$(BINUTILS_BARE_METAL_EXTRA_CONF_OPTS_$(arch_tuple)) \
 			--target=$(arch_tuple)
 	)
 endef
@@ -70,3 +71,7 @@ define HOST_BINUTILS_BARE_METAL_INSTALL_CMDS
 endef
 
 $(eval $(host-autotools-package))
+
+ifneq ($(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_CONFIG_DIR),)
+include $(wildcard $(subst ",,$(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_CONFIGS))/*)
+endif
package/gcc-bare-metal/gcc-bare-metal.mk +5 -0
index 4ec154bb53..ab38436d0d 100644
@@ -70,6 +70,7 @@ define HOST_GCC_BARE_METAL_CONFIGURE_CMDS
 		CONFIG_SITE=/dev/null \
 		$(@D)/configure \
 			$(HOST_GCC_BARE_METAL_CONF_OPTS) \
+			$(GCC_INITIAL_BARE_METAL_EXTRA_CONF_OPTS_$(arch_tuple))\
 			--target=$(arch_tuple) \
 			--with-sysroot=$(HOST_DIR)/$(arch_tuple)/sysroot \
 			AR_FOR_TARGET=$(HOST_DIR)/bin/$(arch_tuple)-ar \
@@ -93,4 +94,8 @@ define HOST_GCC_BARE_METAL_INSTALL_CMDS
 	)
 endef
 
+ifneq ($(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_CONFIG_DIR),)
+include $(wildcard $(subst ",,$(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_CONFIGS))/*)
+endif
+
 $(eval $(host-autotools-package))
package/newlib-bare-metal/newlib-bare-metal.mk +5 -0
index 5881993d3a..9fd3ef4637 100644
@@ -52,6 +52,7 @@ define NEWLIB_BARE_METAL_CONFIGURE_CMDS
 		CONFIG_SITE=/dev/null \
 		$(@D)/configure \
 			$(NEWLIB_BARE_METAL_CONF_OPTS) \
+			$(NEWLIB_BARE_METAL_CONF_OPTS_$(arch_tuple)) \
 			--target=$(arch_tuple)
 	)
 endef
@@ -74,3 +75,7 @@ define NEWLIB_BARE_METAL_INSTALL_STAGING_CMDS
 endef
 
 $(eval $(generic-package))
+
+ifneq ($(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_CONFIG_DIR),)
+include $(wildcard $(subst ",,$(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_CONFIGS))/*)
+endif
toolchain/toolchain-bare-metal-buildroot/Config.in +16 -0
index 65b49d36aa..b909238587 100644
@@ -37,6 +37,22 @@ config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_NANO
 	  When enabled, this option will apply to all architecture
 	  tuples in the list.
 
+config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_CONFIGS
+	string "Additional config options"
+	help
+	  Search the specified directory for tuple config files with
+	  additional options for the toolchain build stages. For
+	  example, if the user specified two bare metal toolchains to be
+	  built:
+
+	  > BARE_METAL_BUILDROOT_ARCH="microblazeel-buildroot-elf \
+	  >     riscv64-unknown-elf"
+
+	  The CONFIG_DIR directory would have invidual config files:
+
+	  > microblazeel-buildroot-elf.config
+	  > riscv64-unknown-elf.config
+
 source "package/newlib-bare-metal/Config.in"
 
 endif # BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
toolchain/toolchain-bare-metal-buildroot/configs/README.md new file +47 -0

47 lines not on this page · raw message

toolchain/toolchain-bare-metal-buildroot/configs/riscv64-unknown-elf.config new file +35 -0
new file mode 100644
index 0000000000..0daabd76a3
@@ -0,0 +1,35 @@
+# Copyright 2026 Rockwell Collins
+
+BINUTILS_BARE_METAL_EXTRA_CONF_OPTS_riscv64-unknown-elf = \
+	--with-abi=lp64d \
+	--with-arch=rv64gc \
+	--with-isa-spec=20191213
+
+GCC_INITIAL_BARE_METAL_EXTRA_CONF_OPTS_riscv64-unknown-elf = \
+	--with-abi=lp64d \
+	--with-arch=rv64gc \
+	--with-isa-spec=20191213 \
+	--with-system-zlib \
+	CFLAGS_FOR_TARGET="-Os -mcmodel=medlow" \
+	CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow"
+
+GCC_FINAL_BARE_METAL_EXTRA_CONF_OPTS_riscv64-unknown-elf = \
+	--with-abi=lp64d \
+	--with-arch=rv64gc \
+	--with-isa-spec=20191213 \
+	--with-system-zlib \
+	--without-zstd \
+	--with-specs='%{!mcmodel*:-mcmodel=medlow}' \
+	CFLAGS_FOR_TARGET="-Os -mcmodel=medlow" \
+	CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow"
+
+NEWLIB_BARE_METAL_CONF_OPTS_riscv64-unknown-elf = \
+	--enable-newlib-register-fini \
+	--disable-nls \
+	CFLAGS_FOR_TARGET="-Os -D_POSIX_MODE -ffunction-sections -fdata-sections    -mcmodel=medlow" \
+	CXXFLAGS_FOR_TARGET="-Os -D_POSIX_MODE -ffunction-sections -fdata-sections    -mcmodel=medlow"
+
+NEWLIB_BARE_METAL_NANO_CONF_OPTS_riscv64-unknown-elf = \
+	--disable-nls \
+	CFLAGS_FOR_TARGET="-Os -D_POSIX_MODE -ffunction-sections -fdata-sections    -mcmodel=medlow" \
+	CXXFLAGS_FOR_TARGET="-Os -D_POSIX_MODE -ffunction-sections -fdata-sections    -mcmodel=medlow"
Signature · 6 lines
2.47.3

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

PATCH 3/3 gcc-bare-metal: add directories for second stage GCC.

In reply to Steven J. Hill

Add directories which will be used for building a bare metal toolchain capable of supporting C++ and other languages. The support will be enabled in future patches.

---
 .../gcc-bare-metal-final.hash                 |  8 ++
 .../gcc-bare-metal-final.mk                   | 96 +++++++++++++++++++
 .../gcc-bare-metal-initial.hash               |  8 ++
 .../gcc-bare-metal-initial.mk                 | 70 ++++++++++++++
 4 files changed, 182 insertions(+)
 create mode 100644 package/gcc-bare-metal/gcc-bare-metal-final/gcc-bare-metal-final.hash
 create mode 100644 package/gcc-bare-metal/gcc-bare-metal-final/gcc-bare-metal-final.mk
 create mode 100644 package/gcc-bare-metal/gcc-bare-metal-initial/gcc-bare-metal-initial.hash
 create mode 100644 package/gcc-bare-metal/gcc-bare-metal-initial/gcc-bare-metal-initial.mk
package/gcc-bare-metal/gcc-bare-metal-final/gcc-bare-metal-final.hash new file +8 -0
new file mode 100644
index 0000000000..1e1003eec9
@@ -0,0 +1,8 @@
+# From https://gcc.gnu.org/pub/gcc/releases/gcc-16.2.0/sha512.sum
+sha512  c51c30ca7422d0cbecf504b2e0f33c3aca31e0f90a76b65217f465163fa6fa17b3f5de39e145c47e5bab90ac0ce7fff3b03c8d553ae36e01faaea5a50f8648d1  gcc-16.2.0.tar.xz
+
+# Locally calculated
+sha256  231f7edcc7352d7734a96eef0b8030f77982678c516876fcb81e25b32d68564c  COPYING
+sha256  8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903  COPYING3
+sha256  a853c2ffec17057872340eee242ae4d96cbf2b520ae27d903e1b2fef1a5f9d1c  COPYING3.LIB
+sha256  a9bdde5616ecdd1e980b44f360600ee8783b1f99b8cc83a2beb163a0a390e861  COPYING.LIB
package/gcc-bare-metal/gcc-bare-metal-final/gcc-bare-metal-final.mk new file +96 -0

96 lines not on this page · raw message

package/gcc-bare-metal/gcc-bare-metal-initial/gcc-bare-metal-initial.hash new file +8 -0
new file mode 100644
index 0000000000..1e1003eec9
@@ -0,0 +1,8 @@
+# From https://gcc.gnu.org/pub/gcc/releases/gcc-16.2.0/sha512.sum
+sha512  c51c30ca7422d0cbecf504b2e0f33c3aca31e0f90a76b65217f465163fa6fa17b3f5de39e145c47e5bab90ac0ce7fff3b03c8d553ae36e01faaea5a50f8648d1  gcc-16.2.0.tar.xz
+
+# Locally calculated
+sha256  231f7edcc7352d7734a96eef0b8030f77982678c516876fcb81e25b32d68564c  COPYING
+sha256  8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903  COPYING3
+sha256  a853c2ffec17057872340eee242ae4d96cbf2b520ae27d903e1b2fef1a5f9d1c  COPYING3.LIB
+sha256  a9bdde5616ecdd1e980b44f360600ee8783b1f99b8cc83a2beb163a0a390e861  COPYING.LIB
package/gcc-bare-metal/gcc-bare-metal-initial/gcc-bare-metal-initial.mk new file +70 -0

70 lines not on this page · raw message

Signature · 6 lines
2.47.3

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