cancel
Showing results for 
Search instead for 
Did you mean: 

Script file for linker in RIDE. I want to place main.o into my own section

vaclav2
Associate II
Posted on February 28, 2007 at 08:45

Script file for linker in RIDE. I want to place main.o into my own section

4 REPLIES 4
vaclav2
Associate II
Posted on May 17, 2011 at 09:36

Hi All

I want to place my files .o (main.o, myfunction.o etc.) into my own section that is defined at absolute address. There will not be standard libraries (91xlib.o, 91x_scu.o etc) . These libraries will be in standard section .text in FLASH region.

I made region USERFLASH in file str91xfx44_FLASH.ld

.

.

.

MEMORY

{

FLASH (rx) : ORIGIN = 0, LENGTH = 64K

USERFLASH (rx) : ORIGIN = 0x10000, LENGTH = 448K

FLASHB1 (rx) : ORIGIN = 0x00400000, LENGTH = 32K

EXTMEMB0 (rx) : ORIGIN = 0x30000000, LENGTH = 64M

EXTMEMB1 (rx) : ORIGIN = 0x34000000, LENGTH = 64M

EXTMEMB2 (rx) : ORIGIN = 0x38000000, LENGTH = 64M

EXTMEMB3 (rx) : ORIGIN = 0x3C000000, LENGTH = 64M

RAM (xrw) : ORIGIN = 0x50000000, LENGTH = 96K

}

.

.

.

.

I have to modify the file section_FLASH.ld, but I don't know how.

What have I to do?

I tried some things from ld.pdf but there aren't examples for this problem.

Thanks

[ This message was edited by: Vendelin on 28-02-2007 09:17 ]

vincentchoplin9
Associate II
Posted on May 17, 2011 at 09:37

Hi,

First, you should take care when modifying str91xfx44_FLASH.ld because it is generated by RIDE at every link. (ignoring all previous modifications) You should modify a copy of it in your project's folder, not the version in ''c:\ride\lib''. The same thing applies to the other subscripts (section_FLASH.ld, etc.), which are not modified by RIDE, but which will affect all projects on the PC if you modify the version in RIDE. So if you plan to modify the script, make copies of it and its subscripts and make sure that your project uses the copies and then modify the copies. I have seen several times people that were not using the file they thought they were using.

As for the the modifications in the SECTIONS zone, you can look at how it's done in ''sections_RAM.ld'' for putting the startup in flash. I think you'll end up with something like this:

/* the user program code is stored in the USERFLASH zone */

.usertext :

{

. = ALIGN(4);

* (.usertext) /* user code */

. = ALIGN(4);

} > USERFLASH

And then you'll have to declare the user functions like this:

int main() __attribute__ ((section (''.usertext'')));

I think that there are ways to tell the linker to place all .text from a predefined .o file in a specific section, but I never needed that so I've never tried to do it. Maybe you should ask the GCC team.

Finally, you'll have to be careful because the compiler generates calls to the run-time library (libgcc.a) and you'll have to take care as to where this code is placed. It all depends on why you want to have this specific section mapping...?

Best Regards,

Vincent

vaclav2
Associate II
Posted on May 17, 2011 at 09:37

Hi VincentC

I am looking for method, how modify only part of program code in flash.

I want to have standart libraries, my own libraries and interrupt handlers in flash for all times and I want to upgrade only program code.

Does the method with ''__attribute__'' mean, that I rewrite all standart libraries?

Isn't simple way how to place full file into region USERFLASH?

Best regards

[ This message was edited by: Vendelin on 28-02-2007 10:44 ]

vaclav2
Associate II
Posted on May 17, 2011 at 09:37

Hi

Declaration of function

void __attribute__((section(''.usertext''))) MyFunc(void);

is going very well.

Thanks for your help VincentC

Best regards