cancel
Showing results for 
Search instead for 
Did you mean: 

Writing Flash Bank1

simon
Associate II
Posted on April 19, 2008 at 09:08

Writing Flash Bank1

8 REPLIES 8
simon
Associate II
Posted on March 26, 2008 at 10:52

I try to write in the flash bank 1 with the ST library functions:

EIC_IRQConfig(DISABLE);

FLASH_Init();

FLASH_WritePrConfig(FLASH_B1F0, DISABLE);

FLASH_SectorErase(FLASH_B1F0);

FLASH_WordWrite(SAVE_FLASH_BASE, 0x123456);

EIC_IRQConfig(ENABLE);

The program is running in bank 0. When I run the section with the debugger and everything is ok, but the program don't starts himself by power up without debugging. May be I have to start the flash writing sequence from RAM??? How can I copy the function from Flash into RAM and running there???

Can anybody helps me

amoreno
Associate II
Posted on April 18, 2008 at 09:09

I have the same problem,

Could anybody kindly help us?

thanks in advance.

Alfa.

simon
Associate II
Posted on April 18, 2008 at 09:27

I solved the problem. You must copy the flash library into RAM, because the first FLASH writing cycle must be started from there. Change your scatter file as shown below:

USER_MODE 0x40000000 0xC40000

{

FLASH 0x40000000

{

71x_vect.o (Vect, +First)

71x_init.o (Init)

* (+RO)

}

RAM 0x20000000

{

flash.o (+RO)

* (+RW)

* (+ZI)

}

}

amoreno
Associate II
Posted on April 18, 2008 at 14:30

Hello Simon,

Thank you very much for your reply. Unfortunately I don’t know what is the “scatter� file. Yes, I’m newbie in ARM’s.

I tried to find information on IAR website, googleing and here but I don’t know what exactly I must to modificate.

Could you please explain me in detail?

1000 thanks.

Regards.

amoreno
Associate II
Posted on April 18, 2008 at 14:30

Hello Simon,

Thank you very much for your reply. Unfortunately I don’t know what is the “scatter� file. Yes, I’m newbie in ARM’s.

I tried to find information on IAR website, googleing and here but I don’t know what exactly I must to modificate.

Could you please explain me in detail?

1000 thanks.

Regards.

amoreno
Associate II
Posted on April 18, 2008 at 14:34

I forgot to say that I'm ussing IAR WORKBENCH 5.1 and STR711 processor (tested in Evaluation board and selfmade board).

Alfa

kleshov
Associate II
Posted on April 19, 2008 at 09:05

You can avoid having to resort to modifying the scatter file. One way of doing it is to embed the body of the RAM function into a static variable. This way the runtime library will copy its contents from ROM to RAM during static variable initialization phase:

Code:

/*

* void flash_start_wait(uint32_t volatile* reg, uint32_t start)

* {

* *reg |= start;

* while ((*reg & start) != 0) {}

* }

*/

static uint32_t flash_start_wait_body[] = {

0xE5902000, /* LDR R2, [R0] */

0xE1822001, /* ORR R2, R2, R1 */

0xE5802000, /* STR R2, [R0] */

0xE5902000, /* loop LDR R2, [R0] */

0xE1120001, /* TST R2, R1 */

0x1AFFFFFC, /* BNE loop */

0xE12FFF1E /* BX LR */

};

union ramfunc

{

uint32_t* iptr;

void (*fptr)(uint32_t volatile* reg, uint32_t start);

};

static const union ramfunc flash_start_wait = { flash_start_wait_body };

static void

flash_start_operation(bool block)

{

if (block)

{

disable_irq();

(flash_start_wait.fptr)(&FLASH_CR0, 1u << 31);

enable_irq();

}

else

{

busy = true;

FLASH_CR0 |= FLASH_WMS;

}

}

kleshov
Associate II
Posted on April 19, 2008 at 09:08

Quote:

On 18-04-2008 at 18:04, Anonymous wrote:

I forgot to say that I'm ussing IAR WORKBENCH 5.1 and STR711 processor (tested in Evaluation board and selfmade board).

Alfa

One more thing. I seem to recall that there is the __ramfunc keyword in IAR EWARM which does the trick automatically. Not sure if it wasn't removed in the new version 5, though.