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 file with code on either side of a flash config block

I find myself stuck trying to create a working scatter file. I am using the Keil compiler, mbed-os, and an STM32F407VG (1meg flash). I want to create a flash image that reserves flash sectors 3 and 4 (0x0800C000, 16K and 0x08010000, 64K) for in-app programming (config) space. I prefer these sectors because they are the right size for my needs as opposed to the ones higher in the address map.

However, my .text sections are larger than will fit below FLASH_SECTOR_3, and thus some .o files must end up above the end of FLASH_SECTOR_4. All attempts to create two ER's so far have resulted in a distribution of code that puts all of the .o's in the larger upper regions and then the initial BLX to SystemInit fails (it appears to try to branch to an incorrect address).

Anyway, if anyone has an example of reserving out a flash sector with code living happily on both sides of the reserved block, that would be much appreciated.

Parents
  • And, of course, as soon as I post, I figured it out... The secret was to use two LRs instead of two ER's in a single LR. For posterity, here it is:

    LR_IROM1 0x08000000 0x0000C000 { ; load region size_region ER_IROM1 0x08000000 0x0000C000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x10000000 0x00010000 { ; CCM } RW_IRAM2 0x20000188 0x0001FE78 { .ANY (+RW +ZI) }
    } LR_IROM2 0x08020000 0x00C00000 { ; load region size_region ConfigSector 0x0800C000 EMPTY 0x00004000 {} UserProgramSector 0x08010000 EMPTY 0x00010000 {} ER_IROM2 0x08020000 0x00C00000 { ; load address = execution address .ANY (+RO) }
    }

Reply
  • And, of course, as soon as I post, I figured it out... The secret was to use two LRs instead of two ER's in a single LR. For posterity, here it is:

    LR_IROM1 0x08000000 0x0000C000 { ; load region size_region ER_IROM1 0x08000000 0x0000C000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x10000000 0x00010000 { ; CCM } RW_IRAM2 0x20000188 0x0001FE78 { .ANY (+RW +ZI) }
    } LR_IROM2 0x08020000 0x00C00000 { ; load region size_region ConfigSector 0x0800C000 EMPTY 0x00004000 {} UserProgramSector 0x08010000 EMPTY 0x00010000 {} ER_IROM2 0x08020000 0x00C00000 { ; load address = execution address .ANY (+RO) }
    }

Children