Execute Code From RAM

OP #1173311
Hello!

I'm working on a In Application Programming solution for an STR711
Microcontroller. There are some reasons for me, to execute the routines,
which will write the flash banks from RAM.


So here is my question:

I compiled this routines for executing them in RAM.
I reserved some space for this code by defining a new memory range in
the linker script ( .ld )

MEMORY
{

  IntCodeRAM  (rx) : ORIGIN = 0x00000000, LENGTH = 256k
  ReservedRAM (rw) : ORIGIN = 0x20000000, LENGTH = 2k
  IntDataRAM  (rw) : ORIGIN = 0x20000200, LENGTH = 62k

}

It works, but does someone knows a more flexible method?
The main Problem is, i think, to find an empty space in RAM.

Thanks, Stefan
Guest
>   IntCodeRAM  (rx) : ORIGIN = 0x00000000, LENGTH = 256k
>   ReservedRAM (rw) : ORIGIN = 0x20000000, LENGTH = 2k
>   IntDataRAM  (rw) : ORIGIN = 0x20000200, LENGTH = 62k

0x200 is 512, not 2048 (2K).
OP
A.K. wrote:
>>   IntCodeRAM  (rx) : ORIGIN = 0x00000000, LENGTH = 256k
>>   ReservedRAM (rw) : ORIGIN = 0x20000000, LENGTH = 2k
>>   IntDataRAM  (rw) : ORIGIN = 0x20000200, LENGTH = 62k
>
> 0x200 is 512, not 2048 (2K).

Thanks, just a little typing error. But this isn't the Problem.

Regards,

Stefan
Guest
To permanently place some functions in RAM, you do not have to define a
separate memory region. The linker script can place them the into the
same RAM memory region as the data.
Guest
As already mentioned by A.K. an extra entry in "MEMORY" is not needed.

You could simple try use this function attribute:
_attribute_ ((long_call, section (".data")))
This will assign the function declared with the attribute to the
".data". No modification in the linker-script should be needed for this.

An addtional section (i.e. ".fastrun") might be useful later since the
locations of such extra sections can be changed easily in the
linker-script without side-effect on the "real" .data.

May serve as examples:
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index.html#gcc_ramfunc
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index_at91.html#at91_gamma
both not for STR711 but the method is not target-dependent

Martin Thomas
OP
Martin Thomas wrote:
> As already mentioned by A.K. an extra entry in "MEMORY" is not needed.
>
> You could simple try use this function attribute:
> _attribute_ ((long_call, section (".data")))
> This will assign the function declared with the attribute to the
> ".data". No modification in the linker-script should be needed for this.
>
> An addtional section (i.e. ".fastrun") might be useful later since the
> locations of such extra sections can be changed easily in the
> linker-script without side-effect on the "real" .data.
>
> May serve as examples:
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index.html#gcc_ramfunc
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index_at91.html#at91_gamma
> both not for STR711 but the method is not target-dependent
>
> Martin Thomas

Hello!

At first, thanks for all your help. I read and tried the examples above.
The Problem is, that i don't want to place the code permamently in RAM.
I don't want to wast 3kB of RAM, if I don't need the functions.
Sorry guys, im very new to programming ARM.

Regards,

Stefan
Guest
Martin Thomas wrote:
> As already mentioned by A.K. an extra entry in "MEMORY" is not needed.
>
> You could simple try use this function attribute:
> _attribute_ ((long_call, section (".data")))
> This will assign the function declared with the attribute to the
> ".data". No modification in the linker-script should be needed for this.
>
> An addtional section (i.e. ".fastrun") might be useful later since the
> locations of such extra sections can be changed easily in the
> linker-script without side-effect on the "real" .data.
>
> May serve as examples:
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index.html#gcc_ramfunc
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index_at91.html#at91_gamma
> both not for STR711 but the method is not target-dependent
>
> Martin Thomas

Dear Martin,

I have a quiestion about the function attribute, i want to write some
bytes to flash. My function is located in RAM, this works only with
functions without function arguments. Suppose you have a flash write
function with address and data arguments. Can we pass this arguments as
well.

Regards, Bram Dobbelaar


#define FASTRUN _attribute_ ((long_call, section (".data")))

FASTRUN void Erase_sector1(void);
FASTRUN void Word_program(void);
FASTRUN void FLASH_WWrite(u32 XtargetAdd, u32 Xdata);
u32 Addres,data;
Moderator
Bram Dobbelaar wrote:
> I have a quiestion about the function attribute, i want to write some
> bytes to flash. My function is located in RAM, this works only with
> functions without function arguments. Suppose you have a flash write
> function with address and data arguments. Can we pass this arguments as
> well.

I have not noticed this before. Can you step though the code with a
debugger to see what is going on?
Guest
Martin Thomas wrote:
> Bram Dobbelaar wrote:
>> I have a quiestion about the function attribute, i want to write some
>> bytes to flash. My function is located in RAM, this works only with
>> functions without function arguments. Suppose you have a flash write
>> function with address and data arguments. Can we pass this arguments as
>> well.
>
> I have not noticed this before. Can you step though the code with a
> debugger to see what is going on?


Thanks for you're answer. I have an another probably related problem. I
can erase flash and write word in flash memory (i use the attribute as
mentioned ). It only works one time after programming the flash. After a
power down and up the copied function in RAM are not working. Do i need
to change the linker script to be sure the ram functions are loaded in
memory. I want to make a flash table that can be changed (error
correction for a sensor application).
Probably i will do this in eeprom, but my eeprom was to small, so i
thought maybe a table in flash is possible.


Regards, Bram Dobbelaar
Attached files:

Reply

A question of your own? This thread is over 20 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.