Altera_Forum
Honored Contributor
19 years agoProgram goes back to reset address
Hello all,
I wrote my own boot loader based on Altera's example boot loader. The biggest differences are that my boot loader uses a defined address to load the program code and I use ldw instead of ldbuio. When the program is loaded into SDRAM, the boot loader jumps to it and start executing the program code. I stepped through the code with the debugger and this seems to work. But after a couple of instructions (don't know where exactly) the CPU jumps to the reset address or is resetted somehow. It looks like the program is running the initialisation (default alt_main()) and craches somewhere in a interrupt routine. I don't know the exact address because when I step through the code everything works fine, but when I run the program it jumps to the reset address. The address to the call which doesn't return when I run it is 0x02427ac (call 0x0203cfde). I don't know the code is the same for every program using the default alt_main(). I use nios2-flash-programmer to program the flash with the srec files I created. I used elf2flash and nios2-elf-objcopy to create the srec file of the program. These are the commands and there options: elf2flash --input=program.elf --base=0 --end=0xFFFFFF --reset=0 --boot=flash_header.srec --output=temp.srec nios2-elf-objcopy -I srec -O srec --srec-forceS3 --srec-len 32 --change-addresses 0x480000 --temp.srec --final_program.srec As you can see I used a different boot loader srec file to create temp.srec. This is because I have my own boot loader and this file contains some header information and is 32 bytes long. I checked the srec file and this all looks fine to me. I have to change the addresses of the temp.srec file because the program must be programmed at offset 0x480000 in the flash. So it looks like everthing should work fine, but it does not and I don't know where to look for the problem. So does anybody have any suggestions about where to look for the problem? Regards Ronald