‎2019-12-10 01:41 AM
I've developed a safety critical application over STM32F103RG microcontroller.
I want to add a fail-safe mechanism to it by making sure that all unused memory locations are either carrying opcode to RESET (like available in PICmicros) or any specific pattern.
I went through this question on the forum, but it doesn't provide instructions to follow for the STM32CubeIDE platform.
Also, if this feature is not available in STM32F, how can this be taken care of? The answer which I've linked says accessing unused memory will throw unhandled exception anyway (is it the hardfault?) If yes, then how should this exception / fault be handled?
‎2019-12-10 01:55 AM
Hi. It is linker option. For IAR: Option->Linker->Checksum select "Fill unused code memory" specify pattern and address range.
‎2019-12-10 01:58 AM
Thanks for the response;idea how can it be done through the STM32Cube platform (MX / IDE / Programmer)?
‎2019-12-10 02:32 AM
STM32CubeMX used only for generation of initial configuration for MCU.
Filling of unused memory locations possible only after linking. So linker can do this. What IDE are you used? IAR, Keil, AtolicTrueStudio?
‎2019-12-10 02:39 AM
Do you mean RAM or FLASH?
Are you making firmware for Boeing 787?
‎2019-12-10 02:40 AM
You are talking about filling gaps in a physically existing memory, so the "unused memory will throw unhandled exception" does not apply here.
Think more of "filling the whole memory with the pattern, and then overlaying the program over it".
CubeIDE uses the GNU toolchain (GCC and binutils), so you would do it in the linker script:
https://sourceware.org/binutils/docs/ld/Output-Section-Fill.html#Output-Section-Fill
Alternatively, you can do it as a post-linking step, using a tool which can handle hexfiles, such as Srecord.
If your mcu does have an MPU, you can use that to define an executable region excluding the "unprogrammed" part; not a trivial undertaking either.
JW
‎2019-12-10 07:16 PM
:D :D :D
No no, nothing for the Boeing.
It's not a jet, but I do take safety considerations of my products seriously.
I'm referring to FLASH memory for filling up unused locations.
‎2019-12-10 07:19 PM
I'm using STM32CubeIDE.
I did check the options available in Project Properties > C/C++ Build Settings > MCU GCC Linker > General,
but the closest I could find to the ''Fill unused code memory" option as you've mentioned for IAR was
"Discard unused sections (-WI, --gc-sections)"
Any idea if this does the same, or something else?
‎2019-12-10 07:23 PM
Never mind about the "Discard unused sections" option.
I found that it only finds and clears off unreachable code to save memory.
Not what I'm looking for.