1
\$\begingroup\$

I developed some hardware with an STM32F4 and firmware and want now to protect the firmware as good as possible when the product goes out. Since I use two flash sectors for virtual EEPROM memory, I still want to access them for r/w. Now I had a look at the option bytes in the STUtility and see there readout protection aswell read/write protection for different flash sectors.

enter image description here

Is it enough for a good protection (I know there were some problems also with the best protections in the past and that a person with enough knowledge can access the code) to choose the read out protection level 2 and then choose the read/write protection for any sectors expect the ones choosen for the virtual EEPROM emulation?

\$\endgroup\$
2
  • \$\begingroup\$ That sounds... like a huge security hazard. \$\endgroup\$
    – user103380
    Dec 7, 2018 at 16:06
  • \$\begingroup\$ Well, I never had to do with read out protection before and try to gain some knowledge is this area. I also had a look at the AN4701 from ST. \$\endgroup\$ Dec 7, 2018 at 16:14

1 Answer 1

4
\$\begingroup\$

I think you're confusing the different types of protection. The Read Out Protection is really the key thing for protecting your code from being accessed by an end user. It basically locks down access to the code from the boot loader, RAM boots and system boots. This means it is not possible to use the boot loader to read the FLASH, or feed a malicious program into the CPU that can scan the flash array.

However, none of these settings affect the operation of the FLASH when booting into your code normally. This is handled by the write protect bits associated with each sector in the FLASH. The point of these is to allow you to prohibit writes to sectors that contain your static code. A good example of where this is useful is in your application. You can write protect all sectors but those used by your virtual EEPROM. This will means that if your virtual EEPROM code goes crazy and tries to write to a random sector, the program will not be corrupted.

So to protect your program, you want to select the appropriate level of ROP (probably the highest) and then set write protection on all sectors except for your EEPROM code.

\$\endgroup\$
5
  • \$\begingroup\$ Thank you, that with the FLASH sector write protection is actually pretty cool, didn't know this. \$\endgroup\$ Dec 7, 2018 at 16:34
  • \$\begingroup\$ There is also a read/write protection option for the flash, why the read out? If this would be activated, the sector is dead, right? Or is the static code still accessible, but not with flash read option? \$\endgroup\$ Dec 7, 2018 at 16:40
  • \$\begingroup\$ @HansPeterLoft Will update answer. That makes the sector execute only. You can use that to achieve read out protection, but it is much tricker to use. I haven't used it before, but I think it would be useful if you have an external memory and wish to protect a kernel/bootloader. \$\endgroup\$
    – Jon
    Dec 7, 2018 at 16:55
  • \$\begingroup\$ Just one last question, when I choose the read protection level 1and also the flash write protection for some sectors, can I undo this in the Utility Tool? I know that protection level 2 can't be undone, since it is fuse based, but level 1 can be undone. But can the flash write be undone? \$\endgroup\$ Dec 8, 2018 at 8:40
  • \$\begingroup\$ Yes. At level 1 you can change the write/erase bits. See STM's AN4701 for all the gory details. \$\endgroup\$
    – GB - AE7OO
    Dec 29, 2020 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.