Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12603 Discussions

uClinux 20100621 - conneting NIOS HW with linux

Altera_Forum
Honored Contributor II
1,441 Views

Hi  

 

I can not connect NIOS hardware with uClinux kernel. I successfully did it when uClinux support make vendor_hwselect. But when I have to build my custom header file with command sopc-create-header-files --single my_nios2_fpga.h I dont't know where exactly put it and how to configure make menuconfig.  

 

This is happen with new kernel like 20100621
0 Kudos
21 Replies
Altera_Forum
Honored Contributor II
622 Views

Hi, 

 

I am trying to import/use uClinux on NIOS on the DE2-70 Board. I see by your comment that you have already done this.  

 

Could you please help me regarding this. 

 

Thanks, 

 

Baishun
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

 

--- Quote Start ---  

Hi  

 

I can not connect NIOS hardware with uClinux kernel. I successfully did it when uClinux support make vendor_hwselect. But when I have to build my custom header file with command sopc-create-header-files --single my_nios2_fpga.h I dont't know where exactly put it and how to configure make menuconfig.  

 

This is happen with new kernel like 20100621 

--- Quote End ---  

 

 

Hi Texblues, 

 

this is strange, because I also made the step with "make vendor_hwselect ..." on the distribution 20100621. I use the "test-nios2" branch for the nommu version.  

But if the mmu version really needs this step I think you have to put your "my_nios2_fpga.h" into the folder "linux-2.6x/arch/nios/include/asm" or something similiar. 

 

@baishunwu: 

It is better to open a new to topic and then tell us what steps you already made on getting uClinux to work. By the way the alterawiki has many sections about getting it started. 

 

Urmel
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

 

--- Quote Start ---  

 

But when I have to build my custom header file with command sopc-create-header-files --single my_nios2_fpga.h I dont't know where exactly put it and how to configure make menuconfig.  

 

--- Quote End ---  

 

 

I you are using the mmu version, take a look on the steps 

http://www.alterawiki.com/wiki/creating_a_nios_ii_design_with_an_mmu 

about adding the files, copying the folders in arch/nios2/ and so on
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Yes. all the things what I do, I do from this website.  

 

I added new board by copying 3c120 to 2c35. Changed Kconfig and Makefile in boards(adding few lines to my new 2c35 board). Changed Kconfig in 2c35 folder. For one try I did not changed 2c35/include/asm for my board and leaved it without change.  

I leave number 2 from the tut: 2. add a new board to uClinux-dist using nios2 as a template. Beaceuse I think this is not usefull. 

I tried compile kernel with my "new" board 2c35(which is old actually) and success.  

Now I want to change parameters for my real board 2c35. And i changed nios.h: 

 

# ifndef _ASM_NIOS2_H__ 

# define _ASM_NIOS2_H__ 

 

# if defined(CONFIG_NIOS2_MMU) 

# include <asm/default_mmu.h> 

 

/* Added compability mode with macro names from "old" design... 

* FIXME: we should really fix drivers instead. but this makes it 

* easier to switch between old and new design... 

*/ 

//#define CONFIG_ALTERA_CYCLONE_III 

# define DDR2_TOP_BASE DDR_SDRAM_BASE 

# define DDR2_TOP_SPAN DDR_SDRAM_SPAN 

# define EXT_FLASH_BASE FLASH_BASE 

# define EXT_FLASH_SPAN FLASH_SPAN 

# define TIMER_1MS_FREQ SYS_CLK_TIMER_FREQ 

# define TIMER_1MS_BASE SYS_CLK_TIMER_BASE 

# define TIMER_1MS_SPAN SYS_CLK_TIMER_SPAN 

# define TIMER_1MS_IRQ SYS_CLK_TIMER_IRQ 

//#define GPIO_LED1 0 

 

DDR_SDRAM, FLASH, SYS_CLK_TIMER - those are my names in nios sopc. I dont have yet GPIO so I comment define GPIO_LED1 0. Actually I dont know what for it is.  

 

I generated: sopc-create-header-files --single default_mmu.h and copied it to 2c35/include/asm overwriting the old one.  

 

Now in uClinux-dist: make menuconfig (I set: Altera, nios2. In kernel selection: default all settings nad customize kernel settings)  

 

I get:  

 

* Restart config... 

* NiosII board configuration 

board configuration 

> 1. 3C120 dev board (3C120) 

2. 2C35 dev board (2C35) (NEW) 

3. Nios Embedded Evaluation Kit (NEEK) 

choice[1-3]: 2 

 

And now: make 

 

I get errors like  

 

 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:87: error: 'USER_LED_PIO_8OUT_BASE' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:88: error: 'USER_DIPSW_PIO_8IN_BASE' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:89: error: 'USER_PB_PIO_4IN_BASE' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:108: error: 'GPIO_LED1' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:108: error: initializer element is not constant 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:108: error: (near initialization for 'nios2_led_pins[0].gpio') 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1157: error: 'TSE_MAC_BASE' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1157: error: initializer element is not constant 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1157: error: (near initialization for 'alt_tse_resource[0].start') 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1158: error: initializer element is not constant 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1158: error: (near initialization for 'alt_tse_resource[0].end') 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1163: error: 'SGDMA_RX_BASE' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1163: error: initializer element is not constant 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1163: error: (near initialization for 'alt_tse_resource[1].start') 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1164: error: initializer element is not constant 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1164: error: (near initialization for 'alt_tse_resource[1].end') 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1169: error: 'SGDMA_TX_BASE' undeclared here (not in a function) 

 

I think the problem is in config.c but how to change it to my nios?
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

have you tried giving a make menuconfig and go down to the devices deselecting the Altera Triple Speed Ethernet and leds?  

I had some problems with the GPIO, I found the selection for it in the menuconfig under Customize Kernel settings > Linux/NiosII Configuration > Additional NiosII Device Drivers. 

 

Not sure this helps you.
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Yes it helped. Now I have less error like: 

 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1157: error: 'TSE_MAC_BASE' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1163: error: 'SGDMA_RX_BASE' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1169: error: 'SGDMA_TX_BASE' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1175: error: 'SGDMA_RX_IRQ' undeclared here (not in a function) 

/util/Altera_soft/workspace/nios2-linux/linux-2.6/arch/nios2/boards/2c35/config.c:1181: error: 'SGDMA_TX_IRQ' undeclared here (not in a function) 

 

Where can I switch it off?
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Do you want networking/ethernet in your system? If so, then you'll have to resolve this. If not, then I think you can safely remove and/or switch these flags off. Just make sure you've also disabled the TSE (and related) in make menuconfig. 

 

Cheers, 

 

slacker
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

guess! 

Take a tour in kernel configuration > device drivers> Network device support> Ethernet (1000) 

Check also the other ethernet options.
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Found it and switched off. Now compilation ends with success. Unfortunataly I get error while downloading Image:( 

 

 

nios2-download -g images/zImage 

Using cable "USB-Blaster [USB 1-1.3.3]", device 1, instance 0x00 

Pausing target processor: not responding. 

Resetting and trying again: OK 

Initializing CPU cache (if present) 

OK 

Downloaded 3529KB in 20.7s (170.4KB/s) 

Verifying C1800000 ( 0%) 

Verify failed between address 0xC1800000 and 0xC180FFFF 

Leaving target processor paused 

 

 

http://aix.vot.pl/nios/nios_config.jpeg  

http://aix.vot.pl/nios/cpu.jpeg  

 

 

MMU setting are default 

 

 

When I run on the same project uClinux but cpu without MMU and dual port onchip memory I run uClinux with success.
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Information about the system from .h file: 

 

 

# define CPU_IMPLEMENTATION "fast" 

# define BIG_ENDIAN 0 

# define CPU_FREQ 50000000 

# define ICACHE_LINE_SIZE 32 

# define ICACHE_LINE_SIZE_LOG2 5 

# define ICACHE_SIZE 4096 

# define DCACHE_LINE_SIZE 32 

# define DCACHE_LINE_SIZE_LOG2 5 

# define DCACHE_SIZE 2048 

# define INITDA_SUPPORTED  

# define FLUSHDA_SUPPORTED  

# define HAS_JMPI_INSTRUCTION  

# define MMU_PRESENT  

# define KERNEL_REGION_BASE 0xc0000000 

# define IO_REGION_BASE 0xe0000000 

# define KERNEL_MMU_REGION_BASE 0x80000000 

# define USER_REGION_BASE 0x0 

# define PROCESS_ID_NUM_BITS 8 

# define TLB_NUM_WAYS 16 

# define TLB_NUM_WAYS_LOG2 4 

# define TLB_PTR_SZ 7 

# define TLB_NUM_ENTRIES 128 

# define FAST_TLB_MISS_EXCEPTION_ADDR 0xc1800000 

# define EXCEPTION_ADDR 0xc0800020 

# define RESET_ADDR 0xc0800000 

# define BREAK_ADDR 0xc1804820 

# define HAS_DEBUG_STUB  

# define HAS_DEBUG_CORE 1 

# define HAS_ILLEGAL_INSTRUCTION_EXCEPTION  

# define HAS_ILLEGAL_MEMORY_ACCESS_EXCEPTION  

# define HAS_EXTRA_EXCEPTION_INFO  

# define CPU_ID_SIZE 1 

# define CPU_ID_VALUE 0x0 

# define HARDWARE_DIVIDE_PRESENT 0 

# define HARDWARE_MULTIPLY_PRESENT 1 

# define HARDWARE_MULX_PRESENT 0 

# define INST_ADDR_WIDTH 25 

# define DATA_ADDR_WIDTH 25 

# define NUM_OF_SHADOW_REG_SETS 0
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

seems the download process tries to download the image to the tigthly coupled memory. 

 

Please check this: 

arch/nios2/kernel/vmlinux.lds.S: . = DDR2_TOP_BASE | KERNEL_REGION_BASE; 

 

 

This means that the image will be built to load at the DDR2_TOP_BASE in my desing. Try to bring it to the ddr_sdram. You may also check nios.h
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

When I compile the kernel I see something like this: 

 

 

UIMAGE arch/nios2/boot/vmImage 

Image Name: Linux-2.6.34-00692-g5bc7853-dirt 

Created: Fri Mar 25 12:05:26 2011 

Image Type: NIOS II Linux Kernel Image (gzip compressed) 

Data Size: 1187727 Bytes = 1159.89 kB = 1.13 MB 

Load Address: 0xC0800000 

Entry Point: 0xC0800000 

Kernel: arch/nios2/boot/vmImage is ready 

 

Load address is 0xC0800000 

 

But when try download image the load address is different : 

 

 

ios2-download -g images/zImage 

Using cable "USB-Blaster [USB 1-1.3.3]", device 1, instance 0x00 

Pausing target processor: OK 

Initializing CPU cache (if present) 

OK 

Downloaded 3529KB in 19.3s (182.8KB/s) 

Verifying C1800000 ( 0%) 

Verify failed between address 0xC1800000 and 0xC180FFFF 

Leaving target processor paused 

 

He's trying load to address C1800000. Why? :( 

 

Addresses are: 

# define RESET_ADDR 0xc0800000 

# define FAST_TLB_MISS_EXCEPTION_ADDR 0xc1800000 

 

Is my nios_sopc bad created? 

 

arch/nios2/kernel/vmlinux.lds.S: . = DDR2_TOP_BASE | KERNEL_REGION_BASE; 

@gabrigob: I have the same.  

in nios.h I have: 

 

# if defined(CONFIG_NIOS2_MMU) 

# include <asm/default_mmu.h> 

 

/* Added compability mode with macro names from "old" design... 

* FIXME: we should really fix drivers instead. but this makes it 

* easier to switch between old and new design... 

*/ 

# define CONFIG_ALTERA_CYCLONE_II 

# define DDR2_TOP_BASE DDR_SDRAM_BASE 

# define DDR2_TOP_SPAN DDR_SDRAM_SPAN 

# define EXT_FLASH_BASE FLASH_BASE 

# define EXT_FLASH_SPAN FLASH_SPAN 

# define TIMER_1MS_FREQ SYS_CLK_TIMER_FREQ 

# define TIMER_1MS_BASE SYS_CLK_TIMER_BASE 

# define TIMER_1MS_SPAN SYS_CLK_TIMER_SPAN 

# define TIMER_1MS_IRQ SYS_CLK_TIMER_IRQ 

 

# else 

# error "No FPGA configuration selected" 

# endif
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Sorry, the thing I told you are working for me but in you situation I am confused as you are. If somethings comes out of my memory, I'll tell you.

0 Kudos
Altera_Forum
Honored Contributor II
622 Views

I found where is the problem. Here it is: http://www.alterawiki.com/wiki/linux_config 

 

"The zImage load address is ( your sdram base address + link address offset ). The boot loader will uncompress the code to the beginning of sdram. If the uncompressed code is bigger than the default 5M, the two area will overlap and corrupt. The compressed image offset should be adjusted to a higher value when the kernel image is big, eg, large files in romfs dir. You can change this value to about 2/3 of the size of your sdram, eg, 20M out fo 32M. I suggest 2/3 because the gzip compression ratio is about 1:2. The zImage boot loader does not relocate/move itself." 

 

In Kernel Settings I can set the offset value. My kernel size is: 3529KB.  

My sdram is 8MB only. Addresses are: 0x00800000 - 0x00FFFFFF 

 

I gave the biggest offset I could: 0x00480000 to make a space for uncompressed kernel but it is still to few:( I have to make the kernel smaller.  

 

This is how it looks like: 

nios2-download -g images/zImage 

Using cable "USB-Blaster [USB 1-1.3.3]", device 1, instance 0x00 

Pausing target processor: OK 

Initializing CPU cache (if present) 

OK 

Downloaded 3529KB in 19.5s (180.9KB/s) 

Verified OK  

Starting processor at address 0xC0C80000 

 

In nios2-terminal: 

nios2-terminal: connected to hardware target using JTAG UART on cable 

nios2-terminal: "USB-Blaster [USB 1-1.3.3]", device 1, instance 0 

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

 

Uncompressing Linux...  

 

And silence.. 

 

Wenn offset is smaller: 

Uncompressing Linux... &#65533;&#9618;&#65533;&#65533;&#65533; 

 

In my case two area overlap and corrupt.
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

good you've found the offset, I completely forgot about it. To deflate the image dimension, try eliminating some applets/applications from Library/Application settings.

0 Kudos
Altera_Forum
Honored Contributor II
622 Views

A thing you may omit (if you undestand how, at the moment I couldn't) is the libstdc++.so if you don't need c++ is about 800K uncompressed. Deflating the image would also help you with the oom_killer in the other thread you opened. 

The oom_killer is someone who takes care of freeing memory for the kernel by means od killing the other processes. If there are no processes to kill the system will run out of memory.
0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Do you think if I would have bigger sdram memory i.e. 16MB it would help?

0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Reducing the things in the intiramfs would also help (without changing the memory). I use a board with a bigger memory chip and a kernel image as big as your and I boot. I have problems with FTP server but this is another matter.

0 Kudos
Altera_Forum
Honored Contributor II
622 Views

Hi Texblues, 

 

the problem could be due to different things. 

One thing you should definitely check is the setting "optimize for size" in "menuconfig". You mustn't turn on this option. My Board didn't start at all with this setting on. 

 

8MB of SDRAM should be enough. I have also 8MB and my uncompressed image is about 3MB. But as I see your compressed image is that big. I don't know how you made it so big. But this is probably not the problem.  

Have you checked the uncompressed image "vmlinux". It is located in uClinux-dist/linux-2.6.x/.  

If this image works than it is likely a problem with the offset. Apart from that your problem could be the "optimize for size" setting. 

 

Urmel
0 Kudos
Altera_Forum
Honored Contributor II
568 Views

I did not have the "optimize for size" set. Actually I changed board to de2-70 with more memory and now I can boot. Now I try to learn how can I use PIO from linux. I created new topic about that. Maybe You can help me or show the way. Thanks for replay

0 Kudos
Reply