Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,309 Views

Altera Cyclone IV Programming .elf file to flash?

I am working on a DE2-115 dev board and have finished my design.  

 

Now i need to program Flash memories so that my code will be non-viotile.  

I have successfully converted the .sof file to .pof and programmed a Active Serial device EPS64. 

 

However I cannot get the .elf file programmed in the ISSI 8MB Flash correctly. I followed the tutorial on terasic http://www.terasic.com.tw/cgi-bin/page/archive.pl?language=english&categoryno=49&no=656 

 

 

by creating a CFI flash controller ,creating a tri-state bus and setting the reset vector to cfi_flash. I am able to program the flash and everything seems ok, but the code is not running correctly. 

 

Any idea why this could be happening? If i run as 'Nios II hardware' in eclipse the program works great, but if i flash the .elf file and recycle power I get strange things like half of the program works. My LCD display works, but the UART doesn't. 

 

Any ideas?
0 Kudos
6 Replies
Altera_Forum
Honored Contributor I
58 Views

hi  

 

You can find many topics with the same doubts here at forum  

 

 

cheers
Altera_Forum
Honored Contributor I
58 Views

can someone at least tell me,  

 

when i hit the 'Run as NIOS II Hardware' in the eclipse IDE, what exactly is this doing?  

 

This can be a clue for me to fix my issue.
Altera_Forum
Honored Contributor I
58 Views

when you hit run the nios 2 download your software to your sopc ram............ 

 

if you want to boot your sopc from flash you need to convert your .elf file to .flash file and write to flash ........ 

 

your exception vector need to point to ram and reset vector to flash  

 

you are use epcs and cfi flash at your design?
Altera_Forum
Honored Contributor I
58 Views

Yes.  

 

I converted the .sof file to be programmed on the EPCS flash. This looks to be good. 

 

I converted the .elf file to be programmed on CFI FLash. This also seems good, and verification comes back with a successful result. 

 

I have pointed Reset vector to CFI flash and Exception vector to op-chip memory. 

 

 

I am thinking the problem may have something to do with the code running much quicker in RAM than it does in Flash? I thought I read that the boot process automatically takes the Code from Flash and puts it into RAM before its starts to execute the program? Is this true, Do i need to do anything to make this happen?
Altera_Forum
Honored Contributor I
58 Views

I am using NIOS Economy

Altera_Forum
Honored Contributor I
58 Views

ok  

 

 

why you dont use only the epcs flash........... you put the .sof and .elf in epcs  

 

 

put .sof and .elf at same directory .....at command shell enter in this directory  

 

convert the .sof 

 

sof2flash --input=(your.sof) --output=(yoursof.flash) --epcs --verbose --offset=0x0 

 

write the yoursof.flash 

 

nios2-flash-programmer --epcs --debug --base=(yourepcsaddress) yoursof.flash 

 

yourepcsaddess = epcs base address + pipeline bridge(if you use) + clock crossing bridge (if you use) 

 

to convert .elf type 

 

elf2flash --after=(yoursof.flash) --input=(your.elf) --output=yourelf.flash --epcs --boot=/home/altera/11/ip/altera/nios2_ip/altera_nios2/boot_loader_epcs.srec 

 

write the yourelf.flash 

 

nios2-flash-programmer --epcs --debug --base=(yourepcsaddress) yourelf.flash 

 

 

reboot your system (reset vector =>epcs_controller exception vector => ram)