2025-10-17 8:36 AM
Hello Team,
I want to store encryption Key - 4 byte into Option Byte OR any other memory Except in-built Flash Memory.
Is it possible to write in Option Memory ?
If not what could be the other option ?
Solved! Go to Solution.
2025-10-18 3:02 AM - edited 2025-10-18 5:27 AM
@bsuthar wrote:
Can we Program those bytes with Cube Programmer and Read using Firmware code ?
I am using RDP1 after Flashing Firmware.
This is what the reference manual is saying. It's accessible over this address: 0x1FFF F804
But it can contain only two bytes and their opposite (Datax and nDatax) and you need 4-bytes storage!
In the CubeProgrammer I've written 0x12 in Data0, 0x78 in Data1:
Read in software:
key = *(uint32_t*)0x1FFFF804;
key contains 0x8778ED12
ED the bitwise inversion of 12 and 87 is the bitwite inserion of 78.
2025-10-17 8:39 AM
There are no spare addresses in option bytes for this.
The usual method for doing this is writing them to the last page of FLASH. If you don't want to do that, you'll need to use an external memory chip.
2025-10-17 9:11 AM
Hello,
I think you can store only two bytes in the option bytes in STM32F3. (By the way you didn't mention the exact part number you are using)
The only possibility in your case (4 bytes) is to use the RTC backup registers where you need an external battery.
I'm not in favor to save the keys in an external memory as it may "breach" the security by sniffing the communication between the chips ;).
2025-10-17 9:36 PM
Exact Device is : STM32F303Rbt6
"I'm not in favor to save the keys in an external memory as it may "breach" the security by sniffing the communication between the chips ;). "
Yes , you catched the point, :).
Can we Program those bytes with Cube Programmer and Read using Firmware code ?
I am using RDP1 after Flashing Firmware.
Whole idea is no body Should sniff the Key.
Thank you,
2025-10-18 3:02 AM - edited 2025-10-18 5:27 AM
@bsuthar wrote:
Can we Program those bytes with Cube Programmer and Read using Firmware code ?
I am using RDP1 after Flashing Firmware.
This is what the reference manual is saying. It's accessible over this address: 0x1FFF F804
But it can contain only two bytes and their opposite (Datax and nDatax) and you need 4-bytes storage!
In the CubeProgrammer I've written 0x12 in Data0, 0x78 in Data1:
Read in software:
key = *(uint32_t*)0x1FFFF804;
key contains 0x8778ED12
ED the bitwise inversion of 12 and 87 is the bitwite inserion of 78.
2025-10-21 6:35 AM
@mƎALLEm , This is useful.
we will look into it.
Since, you mentioned BitInversion, will it automatically inverted while storing this two byte in Option memory ?
If we enable RDP1 , will this two byte as well be read/Write protected ?
Thank you,
2025-10-21 6:51 AM
@bsuthar wrote:
@mƎALLEm , This is useful.
we will look into it.
Since, you mentioned BitInversion, will it automatically inverted while storing this two byte in Option memory ?
Yes. It's automatically inverted. The inverted values are not accessible by the user. I think it is used mainly to check the consistency.
@bsuthar wrote:
@mƎALLEm , This is useful.
If we enable RDP1 , will this two byte as well be read/Write protected ?
Thank you,
Emm that's a good question. I'm not expert of security subjects. You can ask it in the STM32 Security forum but according to the AN4758 "Proprietary code read-out protection on
STM32L4, STM32L4+, STM32G4 and STM32WB Series"
Both Option bytes and Back-up registers are accessible at RDP1. So I think you need to use the internal Flash. No way ..
2025-10-28 3:13 AM
@mƎALLEm ,
Sorry for delay reply as we were on new Year Holiday.
You are saying :
"Both Option bytes and Back-up registers are accessible at RDP1. So I think you need to use the internal Flash. No way .."
Are you pointing out because of limittaion of 4 byte storage ?. we can shrink Key to 2 byte to be stored in Option Byte.
2025-10-28 4:02 AM
@bsuthar wrote:
@mƎALLEm ,
Are you pointing out because of limittaion of 4 byte storage ?. we can shrink Key to 2 byte to be stored in Option Byte.
No, I'm saying that option bytes are not protected by RDP1. Please read my previous post. Meanwhile you can confirm by asking that question in STM32 Security forum as I'm not a security expert guy.
2025-10-28 8:56 AM