cancel
Showing results for 
Search instead for 
Did you mean: 

Need advices for separating flash memory for STM32F0 and STM32F1

toantq3
Associate II
Posted on October 08, 2012 at 03:44

Dear friends.

In my project, I'm separating the flash memory for Eeprom emulation and application code but It's not working. Anyboy can help me my working is correct or not.

In my project, I do something below for STM32F05R 64K.

1) Don't use page 0 and page 8. Memory address from 0x08000000 to 0x08001FFF

2) Use page 9 and page 10 for eeprom emulation. Memory address from 0x08002000 to 0x08002800 

3) Application code will program from page 12 to 64 for application code. Memory address from  0x08003000 to 0x0800FFFF.

I using KEIL compiler. when i build the applicaiton code, i modified Start of IROM1 in ''option for target'' in Keil to 0x08003000 to start application code from this address.

I do the same for STM32F2 but it is not working. Anybody can give me advice about my job. 

If I use the eeprom emulation address in last two pages 63 and 64 of STM32F0 and application code start from page 0. Everything is ok.

Note: I don't use bootloader in my project.

Thanks and Best Regards,
8 REPLIES 8
Posted on October 08, 2012 at 04:31

Some of this numbering doesn't make sense. Page 8 = 0x08002000

You will presumably need some code at 0x08000000 that jumps to your application code, or at least some vector table entries for SP and PC.

If Pages 0 through 7, 0x08000000 .. 0x08001FFF are blank and void, I can't see this starting properly.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
toantq3
Associate II
Posted on October 08, 2012 at 05:09

Dear Clive1

Thanks for reply.

Actually, I want to use top page page 0- page 8 for eeprom emulation, last page for application code. If I try to do like that many times, it is not working.

I understand your advice, we can leave blank the top address from 0x08000000 to application code. We must have code to jump application code. Is that right?

One more thing, I want to ask that we cannot use eeprom emulation in top page of flash memory. Is that right?. Because, i think we don't have any method to jump to application code.

The best way, we only use the last page of flash memory for eeprom emulation and ensure the application code cannot cover that page. Is it right? If this is true, I have one problem with STM32F2. Because Flash of STM32F2 have 12 sectors from 0 to 11, and there are sector 0 to 3 is 16KB, the others from 64KB to 128KB. If I use last sector for eeprom emulation, that will wast alot of memory.

Could you kindly please give me some advices? I'm really confused about this?

Thanks and Best Regards,

Toan Thieu

Posted on October 08, 2012 at 05:30

You can describe the available memory to Keil so that it doesn't allocate FLASH in certain regions to the application. The linker will then not place code there.

I would imagine you could describe two areas, using IROM1 and IROM2, so that IROM1 described 0x08000000, size 0x400, and IROM2 described 0x08003000, size 0xCC00 (ie 0x08003000 .. 0x0800FBFF)

The vector table will then be placed at 0x08000000, and the processor will start execution of your code. I don't think you want to be using Page 0 for EEPROM emulation, as this will conflict with the processor startup sequence.

Using the 128KB sectors of the F2 part are not to be recommended, the erase times can exceed 1 second, so not much good for real-time applications. Generally I think the examples use 2 flash sectors/pages so that it may ping/pong between the two.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
toantq3
Associate II
Posted on October 08, 2012 at 05:57

Dear Clive1

I'm starter of KEIL and STM32 for 2 months. I seems that I still understand your explanation 100% about IROM1 and IROM2. You can kindly help me to make clear so that I can test with my board immediately.

My application code:

I must set IROM1 start 0x08000000 size 0x400.  Is it for eeprom emulation memory area or for any purpose???

I must set IROM2 start 0x08003000 size 0xCC00. Is it for applicaiton code?

We have too setting in OPTION FOR TARGET ''default'' and ''startup''. How I will set for it? Could you explain little about how program will run? First, It jump to address 0x08000000 and then to 0x08003000. Is it right?

For STM32F2, I only want to use Page 2-3 (16KB) for eeprom emulation and reserve page 0-1 don't use this area. I don't want to use 128 KB for eeprom emulation. But every thing, I do right now it is not working. So I really need your help so I can understand to use page 2-3 for eeprom.

Thanks and best Regards,

Toan Thieu

Posted on October 08, 2012 at 06:19

I believe you want to check IROM1 and IROM2 as ''default'' so code is placed there, but you want IROM1 as ''startup'' as this is physically where you want the vectors to reside. The purpose of dividing it into two sections is the permit you to have a void between them which you can use for you EEPROM emulation without interfering with active code.

You're not going to be able to use Page 0 as an EEPROM scratch area. Architecturally it presents a number of problems, which are best avoided.

You should perhaps review the Keil documentation on code placement, and perhaps ''Scatter Files'', as these describe where the linker should place code and data within a device. The equivalent in the GNU/GCC space is linker scripts.

The processor technically doesn't jump to 0x08000000, it loads addresses/pointers from that region, and jumps to those, indirectly if you will.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
toantq3
Associate II
Posted on October 08, 2012 at 07:31

Dear Clive1

Thank you so much. I understand what you mean already, i don't use page 0 for eeprom. I explain again if you see ok, please say YES

Configuration for KEIL

1) Set IROM1: Choose default  - Start: 0x8000000 Size: 0x400 Choose startup

2) Set IROM2: Choose default  - Start: 0x8003000 Size: 0xCC00:

Keil compiler will automatically separate 3 flash area for STM32F. Startup code and intiatially will start from address 0x8000000 and then avoid memory area from 0x8000400 to 0x8002FF and then continue application code from address 0x8003000. As this result, we can use address from 0x8000400 to 0x8002FF for eeprom emulation, that don't interfere with any memory area.

 

Thanks and Best regards,

Toan Thieu

Posted on October 08, 2012 at 13:14

0x08000400 to 0x08002FFF, but yes

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
toantq3
Associate II
Posted on October 09, 2012 at 07:33

Dear Clive1

Thank you.

Toan Thieu