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++
12604 Discussions

Changing location of .entry section

Altera_Forum
Honored Contributor II
1,207 Views

Hi, 

 

i'm working on a bootloader for a system with a Cyclone 1C6, Nios II/s,256kb SRAM and an Atmel serial dataflash (2 megabits). The bootloader will load the main application from the dataflash into the SRAM and jump to it. The problem is making the linker use another reset (or .entry) location for the mainapp than what's entered in SOPC builder, because at startup it has to run the bootloader. I've done some .elf dumping, and I see that it does locate the .text, .rodata,.exception and .rwdata sections to the SRAM as set in the system lib, but the .entry is located at the reset location.  

 

Why are .entry and .exception not settable in the IDE at the system lib properties? I guess I have to change the linker script, not really something I like; IMHO this greatly defies the advantages of auto generated makefiles and the IDE. The Altera documentation is not really exhaustive (yet). 

 

Thanks for any input, 

 

Jeroen
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
412 Views

Have the same problem. But no one from either Altera nor Microtronix have been able to help me with this. If you find a solution can't you write in this forum plz. 

 

Regards 

GreateWhite.DK
0 Kudos
Altera_Forum
Honored Contributor II
412 Views

Actually I have found a solution but it involves changing the auto generated linker script; so you have to use the auto generated script as basis for a custom linker script, as these script look quite intimidating http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif . If you look at generated.x in the system library, there is this sections block: 

 

SECTIONS {    .entry :    {        KEEP (*(.entry))    } > reset    .exceptions :    {        . = ALIGN(0x20);        *(.irq)        KEEP (*(.exceptions));    } > sram . . . } 

 

All I had to do was to change the > reset into > sram, and everything ended up where I wanted it. Of course, I copied the generated.x to another file, so that it won&#39;t be overwritten at the next change of the system.
0 Kudos
Altera_Forum
Honored Contributor II
412 Views

I have tried changing that script. But the damn IDE just overrides my file everytime. Don&#39;t know why though. I tried changing the base adr for my SDRAM so that I could make a offset from the base, so that I could fit in some other code in the beginnning. How do you prevent the IDE from overriding your custom file??? 

 

And thx alot for taking some time for helping me out. 

 

Regards 

GreateWhite.DK
0 Kudos
Altera_Forum
Honored Contributor II
412 Views

How do you use nios2-elf-objdump to see where what&#39;s located. I tried nios2-elf-objdump -h xxx.elf. 

That typed out alot of data, but I can&#39;t see that it should have changed anything changing to custom script. 

I tried changing the SDRAM from 0x1000000 to 0x1100000.
0 Kudos
Altera_Forum
Honored Contributor II
412 Views

You have to tell the IDE that you have a custom script... Under System Library properties there&#39;s a box at the right linker script. Check &#39;Custom linker script&#39;. Everytime the IDE sees a reason to recompile the system library it will also regenerate the linker script, which is called generated.x I&#39;ve made a copy of this one, edited it and called it custom.x and filled that in.  

 

I use nios2-elf-objdump -d *.elf to see where it puts the sections.
0 Kudos
Reply