2024-07-22 07:26 AM
Hello,
I want to write my own ID in the STM32WL55 memory. For this I use STM32Cubeprogram and the ST-LINK V3.
My question is: is there a small flash area where I can write this identifier and which does not interfere with the code and data so as not to be deleted.
I looked at the memory organization in the documentation but it's a bit confusing.
Thanks.
Solved! Go to Solution.
2024-07-22 02:11 PM - edited 2024-07-23 07:55 AM
laesser wrote:
> is there a small flash area where I can write this identifier and which does not interfere with the code and data so as not to be deleted.
Bob S Wrote:
> [use] any area of flash that is not used by your main program
As others have mentioned, UID and OTP are the "proper" ways for identifying a particular chip/board. But if you really want to do use a flash location for this:
- You can easily modify the linker script to carve out a chunk of flash out of the address-space seen by the linker. It then becomes unavailable for the linker to place code/data in.
- Since CubeIDE uses STM32CubeProgrammer behind the scenes for programming the chip and it, in turn, only erases sectors used by the program it's downloading, any flash address space not occupied by the program will not be erased during programming.
So all you need to do it is edit the linker script and modify the flash section's size to be one sector smaller. Anything you put into that sector will not be disturbed by subsequent programming.
2024-07-22 10:57 AM
I don't know specifically for the WL55 chips, but there is usually an OTP section (one-time programmable) that is available, typically in the 0x1fff7xxx area (after the internal bootloader). If you don't want to use that (or if it is too small), then any area of flash that is not used by your main program or in-circuit code updater.
2024-07-22 11:10 AM
Hi,
OTP area seems perfect for this, see rm:
2024-07-22 12:01 PM
You can also consider using the 96-bit unique ID (UID) or UID64 register to identify the chip, if that's the intention.
2024-07-22 02:11 PM - edited 2024-07-23 07:55 AM
laesser wrote:
> is there a small flash area where I can write this identifier and which does not interfere with the code and data so as not to be deleted.
Bob S Wrote:
> [use] any area of flash that is not used by your main program
As others have mentioned, UID and OTP are the "proper" ways for identifying a particular chip/board. But if you really want to do use a flash location for this:
- You can easily modify the linker script to carve out a chunk of flash out of the address-space seen by the linker. It then becomes unavailable for the linker to place code/data in.
- Since CubeIDE uses STM32CubeProgrammer behind the scenes for programming the chip and it, in turn, only erases sectors used by the program it's downloading, any flash address space not occupied by the program will not be erased during programming.
So all you need to do it is edit the linker script and modify the flash section's size to be one sector smaller. Anything you put into that sector will not be disturbed by subsequent programming.