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++
공지
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

JMP to flash after boot

Altera_Forum
명예로운 기여자 II
1,980 조회수

This is my application : 

 

- I have a custom bootloader in my flash : address 0x00000000 - 0x00010000 

 

- I program via PCI an application.flash to my flash : address 0x00010000 - 0x00080000 

 

- When my programation is completed I do a asm("JMP 0x00010000"). 

 

I was expecting the application to start !. 

 

Unfortunatly, NIOS IDE inserts a piece of code before my application in the application.flash. 

For intance, my application is set to work in flash, so the ALTERA boot_loader_CFI.S is inserted 

in front of my application. 

 

The problem is : I don t know to which address I must do my JMP, to reach the main() of my application !. 

If I use global data in my application, the JMP address is different. If I declare functions before the main(), 

the main() address is again different !. 

 

I am really stucked now. Please Help !.
0 포인트
5 응답
Altera_Forum
명예로운 기여자 II
698 조회수

You could take a look at an object dump or map file to help you determine where main() resides. To turn on objdump generation, go to Windows->Preferences->Nios II and you'll see an option. 

 

Cheers, 

 

- slacker
0 포인트
Altera_Forum
명예로운 기여자 II
698 조회수

You probably want to jump to _start instead of main. You can find the address manually with: nm program.out | grep _start 

 

Regards,
0 포인트
Altera_Forum
명예로운 기여자 II
698 조회수

Thanks for your answer but in fact, i already have the main adress. I found it in the project map generated with the Nios IDE compiler.  

 

Meanwhile, i have resolve some parts of my problem but the functions call don't work with my changes. 

 

My infos : 

------------ 

I have a "boot" program in flash which never change and a "download" program which can be changed (adress 0x10000). 

 

After Boot, the "boot" program make a jump to the adress of the "download" program. 

 

If i jump to 0x10000, the program stuck and don't execute. 

 

If i jump to 0x10058, the program execute. 0x10058 is the adress of the main() function. 

 

My changes : 

----------------- 

If i modified the crt0.s program which is add at the beginning of my application, i can add a 'call main' as the first command of my file.  

So i can jump to the main function without knowing the real adress. It could be good if i want to add some functions to my program because the main adress change when functions are added. 

 

My "boot" program call my "download" program. 

 

Infortunatly, with this change, the Bss init function is not execute (because of the call main) and when i try to call a function, the "download" program stuck. I don't know what happen. I think that some registers aren't initialized (sp, fp or others).  

 

Have you some ideas or a light crt.s file ? 

 

Thanks
0 포인트
Altera_Forum
명예로운 기여자 II
698 조회수

If your Reset Address (in SOPC Builder) is pointing to flash and your .text and .rodata sections reside in flash, then there shouldn't be a bootloader prepended to your application code. 

 

What version(s) of the tools are you using? 

 

- slacker
0 포인트
Altera_Forum
명예로운 기여자 II
698 조회수

Thanks for the answer, 

 

My sofware version are : 

Quartus II 4.2 

SOPC builder 4.2 

and NIOS IDE 1.1.0 

 

My Flash address : 0x00000000  

My Sram address : 0x00800000  

 

My Reset address : 0x00000000 (SOPC builder) 

My Exception address : 0x00800000 (SOPC builder) 

 

the "Boot" program is in the flash at 0x00000000 address 

the "Download" program in in the flash at 0x00010000 address 

 

the "Boot" program is configured : 

. text -> sram 

.rodata -> sram 

.rwdata -> sram 

 

the "Download" program is configured : 

. text -> cfi_flash 

.rodata -> onchip memory 

.rwdata -> onchip memory 

 

The both program has the crt0.o boot loader included in the projet. When we do the Jmp to the main in flash at the end of the "Boot" program to launch the "Download" program, we don't execute the crt0 sofware but it seems that some initialization are missing (bss for example) and the call to functions from the main of the "download" program is impossible (the program crash). 

 

Perhaps, we must use some parts of the crt to initialize some data and erase the rest ? 

 

thanks for your help.
0 포인트
응답