Skip to contentSkip to conversation

Build a Nios-II internal toolchain

PATCH New Ezequiel Garcia 2 participants 9 messages Feb 17, 2015 – Feb 19, 2015

lore
Share & tools
lore
#0 lore raw

cover Build a Nios-II internal toolchain

Now that Linux, GCC, glibc, and binutils have gained a Nios-II port we can build an internal toolchain.

This series mostly makes sure only the right versions of the components are chosen when building a toolchain. The last patch merely enables the internal toolchain.

I would like to prepare a defconfig, along with support for some real life board, but unfortunately I'm unable to do so.

First, all the publicly available design examples for the boards I have are outdated and won't work with mainline kernel (unless we apply nasty patches).

Second, when working on this, the board I was using died and I'm not sure when I'll be able to replace it.

Still, before the board died, I managed to build a toolchain, and boot U-Boot, Linux (a patched v3.19) and get to userspace. Maybe someone can give this a shot and report how it goes.

Or maybe we can just merge it :)

Ezequiel Garcia (6):
gcc: 4.9.2: Add patch to remove a wrong header
binutils: nios2: Prevent selecting unsupported versions
gcc: nios2: Prevent selecting unsupported versions
glibc: nios2: Prevent selecting unsupported versions
linux-headers: nios2: Prevent selecting unsupported versions
toolchain: Enable the internal toolchain for nios2

 package/binutils/Config.in.host                         |  7 +++++--
 package/gcc/4.9.2/920-libgcc-remove-unistd-header.patch | 12 ++++++++++++
 package/gcc/Config.in.host                              |  6 +++---
 package/glibc/Config.in                                 |  1 +
 package/linux-headers/Config.in.host                    | 15 ++++++++++++---
 toolchain/Config.in                                     |  1 -
 toolchain/toolchain-buildroot/Config.in                 |  2 +-
 7 files changed, 34 insertions(+), 10 deletions(-)
 create mode 100644 package/gcc/4.9.2/920-libgcc-remove-unistd-header.patch
Signature · 1 line
2.3.0
#1 lore raw

PATCH 1/6 gcc: 4.9.2: Add patch to remove a wrong header

This commit adds a patch to gcc removing a unistd.h header include in libgcc/config/nios2/linux-atomic.c

The file is built as part of GCC first stage (host-gcc-initial), and so the header is not accesible. Given the header is not needed it's fine to simply remove it.

---
 package/gcc/4.9.2/920-libgcc-remove-unistd-header.patch | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 package/gcc/4.9.2/920-libgcc-remove-unistd-header.patch
package/gcc/4.9.2/920-libgcc-remove-unistd-header.patch new file +12 -0
new file mode 100644
index 0000000..df5372b
@@ -0,0 +1,12 @@
+Upstream status: In progress
+
+--- a/libgcc/config/nios2/linux-atomic.c
++++ b/libgcc/config/nios2/linux-atomic.c
+@@ -20,7 +20,6 @@
+ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+ <http://www.gnu.org/licenses/>.  */
+ 
+-#include <asm/unistd.h>
+ #define EFAULT  14
+ #define EBUSY   16
+ #define ENOSYS  38
Signature · 1 line
2.3.0
#2 lore raw

PATCH 2/6 binutils: nios2: Prevent selecting unsupported versions

In reply to Ezequiel Garcia

Versions previous to binutils v2.25 do not support the Nios-II architecture, so disable them.

---
 package/binutils/Config.in.host | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
package/binutils/Config.in.host +5 -2
index 504e9ca..d0ed84e 100644
@@ -8,17 +8,20 @@ choice
 	  Select the version of binutils you wish to use.
 
 	config BR2_BINUTILS_VERSION_2_22
-		depends on !BR2_aarch64 && !BR2_microblaze && !BR2_powerpc64le
+		depends on !BR2_aarch64 && !BR2_microblaze && \
+			   !BR2_powerpc64le && !BR2_nios2
 		bool "binutils 2.22"
 
 	# bfin disabled for newer binutils due to
 	# https://sourceware.org/bugzilla/show_bug.cgi?id=17334
 	config BR2_BINUTILS_VERSION_2_23_2
-		depends on !BR2_aarch64 && !BR2_bfin && !BR2_microblaze && !BR2_powerpc64le
+		depends on !BR2_aarch64 && !BR2_bfin && !BR2_microblaze && \
+			   !BR2_powerpc64le && !BR2_nios2
 		bool "binutils 2.23.2"
 
 	config BR2_BINUTILS_VERSION_2_24
 		depends on !BR2_bfin
+		depends on !BR2_nios2 # supported, but broken on Nios-II
 		bool "binutils 2.24"
 
 	config BR2_BINUTILS_VERSION_2_25
Signature · 1 line
2.3.0
#3 lore raw

PATCH 3/6 gcc: nios2: Prevent selecting unsupported versions

In reply to Ezequiel Garcia

Versions older than GCC v4.9 do not support the Nios-II architecture so disable them.

---
 package/gcc/Config.in.host | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
package/gcc/Config.in.host +3 -3
index 567f66a..dd61f51 100644
@@ -19,7 +19,7 @@ choice
 		bool "gcc 4.5.x"
 		# Broken or unsupported architectures
 		depends on !BR2_microblaze && !BR2_aarch64 && !BR2_arc \
-			&& !BR2_powerpc64le
+			&& !BR2_powerpc64le && !BR2_nios2
 		# Broken or unsupported ARM cores
 		depends on !BR2_cortex_a7 && !BR2_cortex_a12 && \
 			!BR2_cortex_a15 && !BR2_fa526 && !BR2_pj4
@@ -40,7 +40,7 @@ choice
 		bool "gcc 4.7.x"
 		# Broken or unsupported architectures
 		depends on !BR2_microblaze && !BR2_aarch64 && !BR2_arc \
-			&& !BR2_bfin && !BR2_powerpc64le
+			&& !BR2_bfin && !BR2_powerpc64le && !BR2_nios2
 		# Broken or unsupported ARM cores
 		depends on !BR2_cortex_a12 && !BR2_pj4
 		# Broken or unsupported PPC cores
@@ -56,7 +56,7 @@ choice
 		bool "gcc 4.8.x"
 		# Broken or unsupported architectures
 		depends on !BR2_microblaze && !BR2_arc \
-			&& !BR2_bfin && !BR2_powerpc64le
+			&& !BR2_bfin && !BR2_powerpc64le && !BR2_nios2
 		# Broken or unsupported ARM cores
 		depends on !BR2_cortex_a12
 		# Broken or unsupported PPC cores
Signature · 1 line
2.3.0
#4 lore raw

PATCH 4/6 glibc: nios2: Prevent selecting unsupported versions

In reply to Ezequiel Garcia

Versions previous to glibc v2.21 do not support the Nios-II architecture so disable them.

---
 package/glibc/Config.in | 1 +
 1 file changed, 1 insertion(+)
package/glibc/Config.in +1 -0
index 3038b27..8001491 100644
@@ -33,6 +33,7 @@ choice
 	default BR2_GLIBC_VERSION_2_20
 
 config BR2_GLIBC_VERSION_2_20
+	depends on !BR2_nios2
 	bool "2.20"
 
 config BR2_GLIBC_VERSION_2_21
Signature · 1 line
2.3.0
#5 lore raw

PATCH 5/6 linux-headers: nios2: Prevent selecting unsupported versions

In reply to Ezequiel Garcia

Versions older than Linux v3.19 do not support the Nios-II architecture so disable them.

---
 package/linux-headers/Config.in.host | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
package/linux-headers/Config.in.host +12 -3
index 4f0a211..1e206ce 100644
@@ -14,57 +14,66 @@ choice
 	config BR2_KERNEL_HEADERS_3_0
 		bool "Linux 3.0.x kernel headers"
 		depends on BR2_DEPRECATED_SINCE_2014_08
-		depends on !BR2_arc
+		depends on !BR2_arc && !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0
 
 	config BR2_KERNEL_HEADERS_3_2
 		bool "Linux 3.2.x kernel headers"
-		depends on !BR2_arc
+		depends on !BR2_arc && !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_2
 
 	config BR2_KERNEL_HEADERS_3_4
 		bool "Linux 3.4.x kernel headers"
-		depends on !BR2_arc
+		depends on !BR2_arc && !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_4
 
 	config BR2_KERNEL_HEADERS_3_10
 		bool "Linux 3.10.x kernel headers"
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 
 	config BR2_KERNEL_HEADERS_3_11
 		bool "Linux 3.11.x kernel headers"
 		depends on BR2_DEPRECATED_SINCE_2014_08
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_11
 
 	config BR2_KERNEL_HEADERS_3_12
 		bool "Linux 3.12.x kernel headers"
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12
 
 	config BR2_KERNEL_HEADERS_3_13
 		bool "Linux 3.13.x kernel headers"
 		depends on BR2_DEPRECATED_SINCE_2014_08
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_13
 
 	config BR2_KERNEL_HEADERS_3_14
 		bool "Linux 3.14.x kernel headers"
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_14
 
 	config BR2_KERNEL_HEADERS_3_15
 		bool "Linux 3.15.x kernel headers"
 		depends on BR2_DEPRECATED_SINCE_2014_08
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
 
 	config BR2_KERNEL_HEADERS_3_16
 		bool "Linux 3.16.x kernel headers"
 		depends on BR2_DEPRECATED_SINCE_2015_02
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_16
 
 	config BR2_KERNEL_HEADERS_3_17
 		bool "Linux 3.17.x kernel headers"
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17
 
 	config BR2_KERNEL_HEADERS_3_18
 		bool "Linux 3.18.x kernel headers"
+		depends on !BR2_nios2
 		select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_18
 
 	config BR2_KERNEL_HEADERS_3_19
Signature · 1 line
2.3.0
#6 lore raw

PATCH 6/6 toolchain: Enable the internal toolchain for nios2

In reply to Ezequiel Garcia

For now we can only support glibc.

---
 toolchain/Config.in                     | 1 -
 toolchain/toolchain-buildroot/Config.in | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
toolchain/Config.in +0 -1
index 54b5d17..b039ee2 100644
@@ -43,7 +43,6 @@ choice
 
 config BR2_TOOLCHAIN_BUILDROOT
 	bool "Buildroot toolchain"
-	depends on !BR2_nios2
 	select BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
 
 config BR2_TOOLCHAIN_EXTERNAL
toolchain/toolchain-buildroot/Config.in +1 -1
index a69013f..1b9f3a3 100644
@@ -64,7 +64,7 @@ config BR2_TOOLCHAIN_BUILDROOT_GLIBC
 		   BR2_mips64      || BR2_mips64el || BR2_powerpc || \
 		   BR2_powerpc64   || BR2_powerpc64le || BR2_sh   || \
 		   BR2_sh64        || BR2_sparc    || BR2_x86_64  || \
-		   BR2_microblaze
+		   BR2_microblaze  || BR2_nios2
 	depends on BR2_USE_MMU
 	depends on !BR2_STATIC_LIBS
 	depends on !BR2_powerpc_SPE
Signature · 1 line
2.3.0
#7 lore raw

cover Build a Nios-II internal toolchain

In reply to Ezequiel Garcia

Dear Ezequiel Garcia,

Quoted 7 lines · Ezequiel Garcia

Ezequiel Garcia (6):
gcc: 4.9.2: Add patch to remove a wrong header
binutils: nios2: Prevent selecting unsupported versions
gcc: nios2: Prevent selecting unsupported versions
glibc: nios2: Prevent selecting unsupported versions
linux-headers: nios2: Prevent selecting unsupported versions
toolchain: Enable the internal toolchain for nios2

I did a test build, which went all fine and the patches look simple enough. Applied to next, thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#8 lore raw

cover Build a Nios-II internal toolchain

Quoted 12 lines · Thomas Petazzoni

Dear Ezequiel Garcia,

Quoted 7 lines · Ezequiel Garcia

Ezequiel Garcia (6):
gcc: 4.9.2: Add patch to remove a wrong header
binutils: nios2: Prevent selecting unsupported versions
gcc: nios2: Prevent selecting unsupported versions
glibc: nios2: Prevent selecting unsupported versions
linux-headers: nios2: Prevent selecting unsupported versions
toolchain: Enable the internal toolchain for nios2

Quoted 3 lines

I did a test build, which went all fine and the patches look simple enough. Applied to next, thanks!

Hoorray!

Signature · 2 lines
Ezequiel Garcia, VanguardiaSur
www.vanguardiasur.com.ar