Forum Discussion
Altera_Forum
Honored Contributor
13 years agoProblems with installing Nios2 Linux
I am attempting to install the Nios2 Linux development tools on a Centos 6.3 based system.
I am somewhat confused by the instructions (on alteras wiki: Install_Nios_II_Linux). They indicate that the test-nios2 branch is the current branch of the kernel, but the nios2-linux-20100621.tar doesn't come automatically configured for this branch. The instructions also indicate that the current kernel uses the Devicetree approach to configuring the kernel for hardware, though, if I build with the test-nios2 branch, I have to use the vendor_hwselect mechanism Can someone tell me what the current branch is (test-nios2 or nios2mmu under linux-2.6 and test-nios2 or trunk under uClinux-dist) and what the current hardware customization mechanism is (vendor_hwselect, devicetree or sopc generated header)? Also, assuming that the current hardware customization is something other than vendor_hwselect, how do I configure things to get it? Thanks in advance. I'm trying to get ready to use this in a college class that starts at the end of September. D.W. Lynn For reference, Here is what I did, working from the Install_Nios_II_Linux instructions on the wiki, specifically using nios2-linux-20100621.tar. The tool-chain build step first complained: /home/lynnd/nios2-linux/toolchain-build/u-boot.mk:11: Board not defined! Using EP1S10 as default. and later fails with the following: ... home/lynnd/nios2-linux/uClibc' make[2]: `conf' is up to date. CC libpthread/linuxthreads.old/cancel.o In file included from ./include/sys/syscall.h:34, from libpthread/linuxthreads.old/restart.h:16, from libpthread/linuxthreads.old/cancel.c:23: ./include/bits/syscalls.h:10:23: asm/traps.h: No such file or directory make[1]: *** [libpthread/linuxthreads.old/cancel.o] Error 1 make[1]: Leaving directory `/home/lynnd/nios2-linux/uClibc' make: *** [/home/lynnd/nios2-linux/toolchain-build/../uClibc/lib/libc.a] Error 2 So, I switched to the prebuild binary toolchain, which worked. Then I attempted to make the kernel per the instructions using the make menuconfig process. There were lots of undefaulted options. On the final kernel make, I had to do "make CROSS-COMPILE=nios2-linux- since the default CROSS_COMPILE was nios2-linux-gnu- and that's not how the binary toolchain installed and I couldn't find the CROSS_COMPILE option in make menuconfig kernel customization. However, I still got the following error: /home/lynnd/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S: Assembler messages: /home/lynnd/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:542: Error: expecting control register /home/lynnd/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:542: Error: unknown register r6 make[3]: *** [arch/nios2/kernel/entry.o] Error 1 Following some hints elsewhere in the forum, I removed the nios2-linux/ directory completely and untarred nios2-linux-20100621.tar again (to start fresh). Then, before doing the ./checkout step, I did "git checkout test-nios2 -f" in both the uClinux and the linux-2.6 directories. Now the kernel make process succeeds even though it uses the vendor_hwselect mechanism. Note that the documentation for Devicetree (linux-2.6/Documentation/devicetree) does not exist in the test-nios2 branch and make menuconfig in this branch does not give options for using the Device tree approach (that I could find).32 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- Hi, Please add -D name option switches like
. Some include files are used as mixed C and assembly codes. So there is the# ifndef __ASSEMBLY__ macro likenios2-linux-uclibc-gcc -c -D __ASSEMBLY__ -D __KERNEL__ -I/home/developer/altera/nios2-linux/linux-2.6/include -I/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include -I/home/developer/altera/nios2-linux/uClinux-dist/linux-2.6.x/include /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S
. Kazu --- Quote End --- That takes me back where I started:14# define _ASM_NIOS2_PTRACE_H 15 16# include <uapi/asm/ptrace.h> 17 18 /* This struct defines the way the registers are stored on the 19 stack during a system call. */ 20 21# ifndef __ASSEMBLY__ 22 struct pt_regs { 23 unsigned long r8; /* r8-r15 Caller-saved GP registers */ 24 unsigned long r9; 25 unsigned long r10; 26 unsigned long r11; 27 unsigned long r12; 28 unsigned long r13;$ nios2-linux-uclibc-gcc -c -D __ASSEMBLY__ -D __KERNEL__ -I/home/developer/altera/nios2-linux/linux-2.6/include -I/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include -I/home/developer/altera/nios2-linux/uClinux-dist/linux-2.6.x/include /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S: Assembler messages: /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:138: Error: expecting control register /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:138: Error: unknown register r5 /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:546: Error: expecting control register /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:546: Error: unknown register r6 - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- That takes me back where I started:
--- Quote End --- This means that there is no problem around the search path. So what code do you have at line 138 and 546 of 'entry.S' ? Kazu$ nios2-linux-uclibc-gcc -c -D __ASSEMBLY__ -D __KERNEL__ -I/home/developer/altera/nios2-linux/linux-2.6/include -I/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include -I/home/developer/altera/nios2-linux/uClinux-dist/linux-2.6.x/include /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S: Assembler messages: /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:138: Error: expecting control register /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:138: Error: unknown register r5 /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:546: Error: expecting control register /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S:546: Error: unknown register r6 - Altera_Forum
Honored Contributor
--- Quote Start --- Hi, This means that there is no problem around the search path. So what code do you have at line 138 and 546 of 'entry.S' ? Kazu --- Quote End --- It's use of the rdctl register. 138:
546:rdctl r5,exception
The whole file is pasted at http://stackoverflow.com/questions/42778812/error-unknown-register-when-building-uclinuxrdctl r6,badaddr - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- It's use of the rdctl register. 138:
546:rdctl r5,exception
The whole file is pasted at http://stackoverflow.com/questions/42778812/error-unknown-register-when-building-uclinux --- Quote End --- Please try to preprocess the 'entry.S' with -E switch instead of -c, likerdctl r6,badaddr
and check the output file by your editor whether the code 'rdctl r5,exception' and 'rdctl r6,badaddr' are transferd invariantly. Note that with the -E switch, the compiler uses the standard output for its output. If the preprocessing is normal, then make a test file likenios2-linux-uclibc-gcc -E -D __ASSEMBLY__ -D __KERNEL__ -I/home/developer/altera/nios2-linux/linux-2.6/include -I/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include -I/home/developer/altera/nios2-linux/uClinux-dist/linux-2.6.x/include /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S > entry.txt
and compile it.// test.S rdctl r5,exception rdctl r6,badaddr
Does it genarate errors? Kazunios2-linux-uclibc-gcc -c test.S - Altera_Forum
Honored Contributor
--- Quote Start --- Hi, Please try to preprocess the 'entry.S' with -E switch instead of -c, like
and check the output file by your editor whether the code 'rdctl r5,exception' and 'rdctl r6,badaddr' are transferd invariantly. Note that with the -E switch, the compiler uses the standard output for its output. If the preprocessing is normal, then make a test file likenios2-linux-uclibc-gcc -E -D __ASSEMBLY__ -D __KERNEL__ -I/home/developer/altera/nios2-linux/linux-2.6/include -I/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include -I/home/developer/altera/nios2-linux/uClinux-dist/linux-2.6.x/include /home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S > entry.txt
and compile it.// test.S rdctl r5,exception rdctl r6,badaddr
Does it genarate errors? Kazu --- Quote End --- Yes, the file test.S generates the same errors. Using the -E switch generated output difficult for me to understandnios2-linux-uclibc-gcc -c test.S# 1 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S"# 1 "<built-in>"# 1 "<command line>"# 1 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S"# 35 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S"# 1 "/home/developer/altera/nios2-linux/linux-2.6/include/linux/sys.h" 1# 36 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S" 2# 1 "/home/developer/altera/nios2-linux/linux-2.6/include/linux/linkage.h" 1 # 1 "/home/developer/altera/nios2-linux/linux-2.6/include/linux/compiler.h" 1# 5 "/home/developer/altera/nios2-linux/linux-2.6/include/linux/linkage.h" 2# 1 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include/asm/linkage.h" 1# 6 "/home/developer/altera/nios2-linux/linux-2.6/include/linux/linkage.h" 2# 37 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S" 2# 1 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include/asm/asm-offsets.h" 1# 1 "/home/developer/altera/nios2-linux/uClinux-dist/linux-2.6.x/include/generated/asm-offsets.h" 1# 2 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include/asm/asm-offsets.h" 2# 38 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/kernel/entry.S" 2# 1 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include/asm/asm-macros.h" 1# 33 "/home/developer/altera/nios2-linux/linux-2.6/arch/nios2/include/asm/asm-macros.h" .macro ANDI32 reg1,reg2,mask .if \mask & 0xffff .if \mask & 0xffff0000 movhi \reg1,%hi(\mask) movui \reg1,%lo(\mask) and \reg1,\reg1,\reg2 .else andi \reg1,\reg2,%lo(\mask) .endif .else andhi \reg1,\reg2,%hi(\mask) .endif .endm .macro ORI32 reg1,reg2,mask .if \mask & 0xffff .if \mask & 0xffff0000 orhi \reg1,\reg2,%hi(\mask) ori \reg1,\reg2,%lo(\mask) .else ori \reg1,\reg2,%lo(\mask) .endif .else orhi \reg1,\reg2,%hi(\mask) .endif .endm - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- Yes, the file test.S generates the same errors. Using the -E switch generated output difficult for me to understand --- Quote End --- Please try to compile the next code.
The names 'exception' and 'badaddr' are alias of control registers 'ctl7' and 'ctl12'. Kazu// test_ctl.S rdctl r5,ctl7 rdctl r6,ctl12 - Altera_Forum
Honored Contributor
--- Quote Start --- Hi, Please try to compile the next code.
The names 'exception' and 'badaddr' are alias of control registers 'ctl7' and 'ctl12'. Kazu --- Quote End --- That seemed to compile:// test_ctl.S rdctl r5,ctl7 rdctl r6,ctl12$ nios2-linux-uclibc-gcc -c ctl.S developer@1604:~/altera/nios2-linux/uClinux-dist$ ls auto.conf config Documentation lib README test.S autoconf.h config.arch entry.txt linux-2.6.x release_notes testsuites bfin_patch COPYING freeswan MAKEALL romfs tools bin ctl.o images Makefile SOURCE user ccache ctl.S Kconfig openswan staging vendors - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- That seemed to compile:
--- Quote End --- It seems a compiler's bug. So please rewrite the control registers of 'entry.S' with ctl7 and ctl12. Kazu$ nios2-linux-uclibc-gcc -c ctl.S developer@1604:~/altera/nios2-linux/uClinux-dist$ ls auto.conf config Documentation lib README test.S autoconf.h config.arch entry.txt linux-2.6.x release_notes testsuites bfin_patch COPYING freeswan MAKEALL romfs tools bin ctl.o images Makefile SOURCE user ccache ctl.S Kconfig openswan staging vendors - Altera_Forum
Honored Contributor
--- Quote Start --- Hi, It seems a compiler's bug. So please rewrite the control registers of 'entry.S' with ctl7 and ctl12. Kazu --- Quote End --- Thanks. It compiles now until the next bug:kernel/built-in.o(.text+0x2ea40): In function `get_update_sysctl_factor': : undefined reference to `____ilog2_NaN' kernel/built-in.o(.text+0x2ea40): In function `get_update_sysctl_factor': : relocation truncated to fit: R_NIOS2_CALL26 ____ilog2_NaN make: *** Error 1 make: *** Error 2 make: Leaving directory `/home/developer/altera/nios2-linux/linux-2.6' make: *** Error 1 - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- Thanks. It compiles now until the next bug:
--- Quote End --- This is a long term bug which is caused by using the compiler optimization algorithm. ____ilog2_NaN is inserted to check the sanity of variable, and this function is eliminated during the optimization in normal situations, so the kernal will not call it actually. But it seems that they have finally given up this doubtful method. http://www.mail-archive.com/[email protected]/msg1340693.html So, please try to delete the function ____ilog2_NaN from the file 'include/linux/log2.h' according to the diff contents which is written in the last part of its mail. Kazukernel/built-in.o(.text+0x2ea40): In function `get_update_sysctl_factor': : undefined reference to `____ilog2_NaN' kernel/built-in.o(.text+0x2ea40): In function `get_update_sysctl_factor': : relocation truncated to fit: R_NIOS2_CALL26 ____ilog2_NaN make: *** Error 1 make: *** Error 2 make: Leaving directory `/home/developer/altera/nios2-linux/linux-2.6' make: *** Error 1