2015-05-04 01:59 PM
Hi, I'm trying to understand the memory mapping used on the STM32 Nucleo series of boards. Specifically, I'm trying to understand how I can use SRAM vs Flash for program execution.
2015-05-04 04:30 PM
There are several STM32 variants, you need to be specific
The BOOTx pins shadow a specific memory at ZERO, as well as there normal addresses, ie 0x08000000 for FLASH, and 0x20000000 for SRAM If you mess up your code you can still boot into the ROM.2015-05-04 05:03 PM
Hi Clive1,
I'm planning to use several STM32 nucleos boards for this work, but for now, I am specifically working with the STM32F302R8 board. cheers!2015-05-05 06:15 AM
To place the code in SRAM, it is not just necessary to change the state of the BOOT pin.
I suggest you do the following:
Well, consider that you work with the Keil environment.
Step 1. Test your application in Flash execution before anything else.
Then erase the Flash memory (STLink Utilities)
Step 2. From the sizes of your firmware (see .map file generated at the link), hold the different sections of the Code, RO Data, RW Data, and ZI Data
Step 3. Study the datasheet of your STM32, SRAM start address 0x20000000 up 0x2000FFFF (ie: 64Kb SRAM for STM32F302R8), the sum of the linker sections of your program
should be less than the total size of SRAM for your device.
Step 4. In Keil options, into Target tab, change the Start address and size to IROM1 and IRAM1:
Example: Suppose your application gives: Code = 8072, 252 = R0-Data, RW Data, ZI = 88 and = 1344-Data
In code + RO = 8072 + 252 = 8324 bytes = 0x2084 (we keep 0x20FF)
RW in memory = 88 + 1344 = 1432 bytes = 0x598
IROM1and IRAM1 sections are changed in the target options Keil:
IROM1 Start = 0x20000000 Size = 0x20FF code for RO + datas
IRAM1 Start = 0x200020100 Size = 0xFFFF for RW datas
Step5.
Also in the Keil Linker Options tab ensure that Use Memory Layout from Target Dialog is
checked
.Step6. In
STLinkV2 options, uncheck Flash Download: Programm and Verify. And thhen
Remove Flash Algorithm.
Step8. Save your project and Clean and rebuild it.Step7.
Put the Pin Boot0 = High = 3V and run Keil in Debug mode.
Your code is now fully executed from SRAM.You can check with the STLink utilities that SRAM is written.
If you disconnect STLink, target is no powered.You loose code in SRAM.
If your application uses interrupt you need to relocate interrup vector in SRAM too.To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.