cancel
Showing results for 
Search instead for 
Did you mean: 

write flash memory

cyril2399
Associate II
Posted on May 30, 2011 at 12:36

hello,

I have a STM32F107 and I'm programming with IAR embedded workbench.

I have seen on the stm32f107 datasheet that the flash memory adress is between 0x08000000 and 0x0803FFFF.

How sould I program if I want to write a .txt on the flash memory?

Could anyone give me a sample of program?

Any help is welcomes.

Thanks to everybody

#flash #rtfm #iar #stm32 #flash-programming
9 REPLIES 9
Posted on May 30, 2011 at 13:15

Aren't there some flash programming examples within the ST firmware releases? Have you reviewed the flash app note?

The flash is programmable 16-bits (half-word) at a time.

How to you plan on delivering the .TXT file to your part?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist
Posted on May 30, 2011 at 15:06

''Aren't there some flash programming examples within the ST firmware releases?''

 

Yes, there are.

''Have you reviewed the flash app note?''

Also the Flash Programming Manual: 

http://www.st.com/stonline/stappl/resourceSelector/app?page=resourceSelector&doctype=PROGRAMMING_MANUAL&ClassID=1734

cyril2399
Associate II
Posted on May 30, 2011 at 16:42

I want to write and read as easy as on window. I need to store some datas and then transfert it to usb.

So I need to write in the flash memory, but I don't know if with write() it will be done automaticaly...
Andrew Neil
Evangelist
Posted on May 30, 2011 at 18:24

''I want to write and read as easy as on window.''

 

 

Please explain what you mean by that:

 - what do you want to read and write?

 - why do you want in on a window?

''I need to store some datas and then transfer it to usb.''

What do you mean by, ''transfer it to usb'' ?

''So I need to write in the flash memory''

Why? How does that follow?

''I don't know if with write() it will be done automaticaly''

That depends on precisely what ''write()'' you are talking about!

What does the documentation for this ''write()'' tell you??

Have you actually studied any of the documents mentioned in previous posts?
turicikm
Associate
Posted on November 13, 2011 at 15:37

Posted on November 14, 2011 at 01:13

If

 

i

use the same

utility

link

and loaded into an

SRAM memory

,

erasing

and writing to

flash memory

does not work (read from SD card works).

 

Well without seeing how you are writing the flash I can't give a specific reason why it might fail. There is no intrinsic limitation that would prevent it working from SRAM. If you have software timing/timeout loops, these may expire faster when running from SRAM. The flash unit is not going to permit writing to memory that is not erased, and expects aligned 16-bit units to be written.

How does it fail, does the flash unit return an error, or does it not write the correct data, you'll need to be more specific.

There are issues with how code in SRAM boots, but again without knowing more details I can't say if they impact you.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
turicikm
Associate
Posted on November 19, 2011 at 16:16

Thanks for your answer.

Problems writing

to

flash

is

resolved

.

The above

problem

occurs when

not running

HSI :--).

New query

:

As

with

flash

utilities

disable

FLASH_ReadOutProtection

bit

and write

a new program.

It is normal

, to protect

the content

from reading

flash

firmware

?

Thanks for any advise.

ilkay
Associate
Posted on May 29, 2015 at 22:09

Dear clive1,

I have same problem, when i erase to all flash, i can change flash one time, if i not erase to flash i cant change. what is wrong colud you help me. code part is this. regards

HAL_FLASH_Unlock();
HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, 0x0800fff0, 0x01); // 0x01 is dummy write
HAL_FLASH_Lock();

Posted on May 29, 2015 at 22:16

Well that's how flash memory works.

''

The flash unit is not going to permit writing to memory that is not erased, and expects aligned 16-bit units to be written.

''

You seem to ignore any error returned from the function. If you can't do the erase then you'll have to journal your writes. ie advance to the next unwritten location, and write the new value there, and when reading go through the list until you know what was more recent write was.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..