0

I use an ARM Cortex-M0+ (RP2040 Pico), and I compile my programs with gcc, and then "flash" the MCU using openocd over SWD, by issuing the command

program myprog.elf verify reset exit

... to openocd.

What I want to know is this: Let's say I want to "protect" a Flash memory region: for instance, for the Pico, Flash starts at address 0x10000000, - and let's say I want to "protect" 0x10001000 to 0x10002000 ( which I could use for https://mcuoneclipse.com/2012/11/01/defining-variables-at-absolute-addresses-with-gcc/ )

Is there any flag that I can write in either .c source code, or in gcc command line, or gcc linker script, that would mark this Flash region as "protected" in the compiled .elf file - so that I would not have to give any special options to openocd; but instead, openocd would figure out "on its own" from the compiled .elf file, that when doing the flashing of the .elf on the chip (via program myprog.elf), it should basically skip the region from 0x10001000 to 0x10002000, so that Flash memory region keeps the data it had before the flashing?


EDIT: found a possible alternative here:

How to link Data in ELF file to show up during run time? STM32

... basically, memory is reserved in both C and linker script; then after build, objcopy is used to overwrite those sections to actual data - so one could develop a flashing script which first reads these reserved regions, and injects them into a newly built .elf, and the effect would be the same as "skipping the section". However, I would still like to know if there is an attribute that can be used, to "skip the section" without a special flashing script ...

sdbbs
  • 4,270
  • 5
  • 32
  • 87

0 Answers0