cancel
Showing results for 
Search instead for 
Did you mean: 

Flash Programming

lucaontheweb
Associate II
Posted on October 11, 2006 at 06:40

Flash Programming

8 REPLIES 8
lucaontheweb
Associate II
Posted on May 22, 2006 at 08:46

Hi all,

I have just started work with the STR7, and have a requirement to store data in Flash Bank 1, whilst running from Flash Bank 0.

My understanding after reading the Flash Prog Ref. Manual is that the first write to Flash must be done either from FB1 or RAM.

Therefore my question is, if I am running from FB0, how do I execute the instruction to write to FB1 from RAM?

I have seen some reference to using a __ram directive on this forum, but I can't find any reference to this other than this.

Any help/suggestions would be really appreciated.

Thanks.

lucaontheweb
Associate II
Posted on May 22, 2006 at 11:33

I'm using the GNU complier/linker and the Idealist IDE... hope that's what you meant. 🙂

Thanks

lucaontheweb
Associate II
Posted on May 23, 2006 at 14:05

Ok, I thought I had cracked this... but unfortunately not.

My Program executes from Flash Bank0, I am attempting to write to Flash Bank1.

I am using the Anglia Idealist IDE with the GNU Compiler and Linker

In debugger mode it works fine, as expected. But because we have to execute from RAM for the first Flash Write it crashes with either an Unhandled_Handler or a FIQ_Handler.

In order to locate and run my functions in RAM I did the following:

#define RAMFUNC __attribute__ ((long_call, section (''.fastrun'')))

RAMFUNC void FLASH_WordWrite(u32 XtargetAdd, u32 Xdata)

{

...

}

etc...

This was taken from an Anglia Idealist DFU example - but this still failed to work and resulted in a crash as detailed above.

If anyone could suggest anything, either a solution or elsewhere I may find one, then I would be very grateful.

Thanks

sjo
Associate II
Posted on May 23, 2006 at 14:43

This is some code from the Anglia usb dfu demo, these are ram based functions built using IDEaliST.

Simply you need to make sure any other functions called are also ram based.

Regards

sjo

________________

Attachments :

flashram.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtET&d=%2Fa%2F0X0000000aKZ%2FxyHlqbiXQ.odwiFWqAMd7PpPUHy8kze3k6R0AXfgpgg&asPdf=false
lucaontheweb
Associate II
Posted on May 24, 2006 at 07:15

Sojo,

This is the example I took the code from, please note that in the project the calls to these functions aren't placed in RAM via RAMFUNC.

Nonetheless, I tried your suggestion and placed the calling function of the erase sector in RAM via RAMFUNC, but this resulted in the same problems.

If you have any other suggestions then please let me know.

Thanks.

sjo
Associate II
Posted on May 24, 2006 at 16:04

No the code is placed into ram (.data) with the help of the linker script and the startup file, i know i wrote them.

Make sure you have the .data section declared as follows:

The code should be placed in the fastrun section via the FASTROM definition.

.data : AT (_etext)

{

__data_start = .;

*(.data .data.*)

*(.gnu.linkonce.d.*)

SORT(CONSTRUCTORS)

. = ALIGN(4);

*(.fastrun .fastrun.*)

} >DATA

Regards

sjo

per239955_st
Associate II
Posted on October 10, 2006 at 14:31

Hi,

I also use the Anglia toolchain (and IDE)

I've got one large project where I now need to add the functionality to store parameters. My plan is to store them in Bank 1 of the FLASH.

I understand that even if my firmware is run from Bank 0 I need to execute the FLASH writing code from RAM.

When I try to declare a function to be ''RAMFUNC'' I allways end up with a linker error.

main.c:(.text+0x10): relocation truncated to fit: R_ARM_THM_PC22 against symbol `My_WriteParam' defined in .fastrun section in obj/main.o

I don't know what this can be, I've made sure that my .data area is big enough.

Any ideas?

Thanks.

PS.

The ''anglia\IDEaliST\examples\str7\ramfunc'' example compiles fine for me

DS.

sjo
Associate II
Posted on October 11, 2006 at 06:40

you need to check your code, any fucntion that needs to run from ram needs to be declared in a seperate file with a header.

Check your linker script has a data section declared as follows:

.data : AT (_etext)

{

__data_start = .;

*(.data .data.*)

*(.gnu.linkonce.d.*)

SORT(CONSTRUCTORS)

. = ALIGN(4);

*(.fastrun .fastrun.*)

} >DATA

. = ALIGN(4);

I have attached the flash programming files i use, as part of the dfu demo.

Regards

sjo

________________

Attachments :

flash.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtEA&d=%2Fa%2F0X0000000aKW%2FPXWcWINy6hbPkNu1xHXHZjjneb1l.uOHjebYBcg_O9g&asPdf=false