This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Scatter load

Hi,

I am using STM32F070C in one USB application with command line interface. Settings of the device is stored in flash in last 1k bank (device is 32k): 0x0800 7c00 to 0x800 7fff. I have some issues with default setup of a new project after writing to flash. After restart (or reset), the device goes into hard fault exception during startup. I single-stepped all through __scatterload and the hard fault is generated when R0 within __scatterload routine hits address which was modified during my flash write.

Then I changed IROM size in the target dialog from 0x8000 to 0x7c00 and it passed the startup and runs OK. My question now is about the startup process: where can I find some detailed info about startup process and how can I change the sections of the flash memory to r/w and specify that to linker to avoid those sections.

  • I don't think changing them to RW in this case helps you. What you want to do is exclude specific areas so they are outside the linker's view, and have your code recognize if they are blank or not, and write your defaults settings there.

    The scatter file allows you to describe multiple areas of memory, and what content gets packed in there. The reason RAM data/statics get packed into the FLASH/ROM is because the RAM content is unknown at reset, and it is unpackaged from the load region. Think of the nesting structures inside the scatter files load regions like a Russian nesting doll. Describing a FLASH section inside another FLASH section is a bad plan.