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

Problem rebooting Nios II from uClinux

Altera_Forum
Honored Contributor II
1,841 Views

Dear all, 

 

I need to reset Nios II from uClinux. I tried to use "reboot" app from sash but it didn't work. The response is 

 

Restarting system 

 

and then system freezes. I'm working on a Stratix II EP2S60. I tried to reset using "CPU RESET" button, but with the same result. I tested the button on a simple program without OS and it works, so it's a uClinux problem.  

 

I hope you can help me, thanks in advance 

 

Marco
0 Kudos
14 Replies
Altera_Forum
Honored Contributor II
447 Views

Is your uClinux system flashed on the board or do you upload it through jtag each time? 

When you release the reset button, the CPU will jump to it's reset address. Depending on the hardware configuration this may be a flash, a bootloader or the RAM. It may try to run a different software than the one you expect.
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

I upload it through jtag each time. The reset vector is located in RAM. Is it possible than this issue depends from the fact that a decompression of the kernel when i run "nios2-terminal" overwrite something?  

I mean: "nios2-download -g zImage" loads the compressed image of the kernel in RAM and "nios2-terminal" decompress it before execute. What happens when i press CPU reset? I think that CPU tries to decompress one more time the kernel, but zImage is already decompressed and CPU can't find it. Am i right? 

Probably i can resolve the problem if i put uClinux on flash.
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Hi, 

 

correct me if i am false, but i don't think that this will work on RAM. 

I don't know exactly what the reboot command does, but after its execution the RAM probably gets erased. 

 

It definitely works when having the image in flash. 

 

Urmel
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Yes I agree. Putting a system in flash and having the CPU's reset vector to the flash should make it work after a reset. 

Also note that even if the CPU's reset vector is on flash, you can still upload a software image through jtag and run it on the CPU. But if you reset it it will revert to the flash image.
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Ok, thanks guys. I will put the system on the flash. 

 

Best regards 

 

Marco
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Sorry guys, but there's something strange. I'm not sure, but i think that soft cpu reset using reboot can't erase RAM. I'm sure that it doesn't happen with CPU Reset button. So put the system on flash is the solution, but i'm curious to know how reset doesn't work with the actual configuration.

0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Instead of "reboot", try "shutdown -r now". I've also found random problems trying to reboot with the "reboot" application. 

 

Cheers, 

 

Ricardo.
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Already done, same problem.

0 Kudos
Altera_Forum
Honored Contributor II
447 Views

When you load the kernel image via JTAG, it loads the compressed image to the link address offset in RAM. Then the image decompresses itself to the beginning of RAM and the jumps there. The compressed image is then erased or overwritten (or at least so I assume, it'd be a horrible waste of memory otherwise). So if you have the processor reset at the link address, that won't work. I don't know if it's possible to get it to reset from the same place the image decompresses to or if there is some other code that needs to be at reset that is not preserved.

0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Yes I agree, this is must probably be happening. For the software reset to work you would need to jump to the cade after the kernel decompression, and I don't know if this is possible

0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Ok guys, thanks for your replies, I agree with you. Now I'm focusing on how to run uClinux from flash. I followed the wiki's article "Flash Programmer", but it doesn't work. I was able to store .sof in flash and it works. The problem is when i try to store zImage.  

 

Step followed: 

 

1. nios2-configure-sof <file>.sof 

2. sof2flash --offset=0xC00000 --input=<file>.sof --output=<file>.flash 

3. nios2-flash-programmer --base=0x02000000 <file>.flash 

4. elf2flash --base=0x02000000 --end=0x02ffffff --reset=0x02000000 --input=zImage --output=ext_flash.flash --boot =SOPC_KIT_NIOS2/components/altera_nios2/boot_loader_cfi.srec 

5. nios2-flash-programmer --base=0x02000000 ext_flash.flash 

 

My Flash base address is 0x02000000 and its size is 16 MBytes. In vendor_hwselect i selected sdram in "Please select device to execute kernel from", the Reset Vector is located in ext_flash at the base address (0x02000000), exception vector in sdram (0x00000020).  

 

The problem is that kernel doesn't start. If i press CPU reset botton i can see the LEDs on the LAN turn off and on again after a certain period, so it seems to be right because i set up LAN in rc file, but i can't ping the board and i cannot see anything on hyperterminal.
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Finally it works. I made some mistakes, but the most important was in "Link Address offset for booting", i had to change it to a bigger value. Thanks a lot for your support. 

 

Marco
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Ok fine. 

But the steps 1-5 you described above were right? 

Because I couldn't see any mistake in the commands. 

 

Urmel
0 Kudos
Altera_Forum
Honored Contributor II
447 Views

Yes they were right, but initially I had the wrong address reset (0x00000000 instead of 0x02000000, i've edit a previous post).

0 Kudos
Reply