0
\$\begingroup\$

I never protect the FLASH memory but this time it is my client requirement. I have my own bootloader and the application ready. Everything works fine if the protection level is zero. But if I switch it (it does not matter if I use ST-LINK utility or it is done from the bootloader) to the Level 1 the program just do not work. I know that is ridiciolus to say "program does not work" - but during the tests I wrote simple LED blinking program. It only enables the GPIO clock and toggles the LED. It works fine on level 0, but stops working on Level1. As I understand switching from level 0 to 1 or 2 does not erase the FLASH (it does in the opposite direction). I cant take a look inside as any debug interfaces are disabled.

Boot 0 is connected via 10k resistor to the GND.

\$\endgroup\$
  • \$\begingroup\$ Perhaps you can add a link to the datasheet for your device. \$\endgroup\$ – Tyler Nov 11 '17 at 2:56
  • \$\begingroup\$ as per Application note AN4701 on st.com website When the read protection level 1 is activated, no access (read, erase, and program) to Flash memory or backup SRAM can be performed via debug features same for level 2 ..... you have to program the chip first, then switch levels ... are you by chance switching level and then programming it? \$\endgroup\$ – jsotola Nov 11 '17 at 4:05
  • \$\begingroup\$ it also says that you have to boot from flash \$\endgroup\$ – jsotola Nov 11 '17 at 4:08
  • \$\begingroup\$ @jsotola it is obvious. If something is write protected, it has to be programmed first :) \$\endgroup\$ – P__J__ Nov 11 '17 at 8:30
  • \$\begingroup\$ And protected after programming \$\endgroup\$ – P__J__ Nov 11 '17 at 9:10
2
\$\begingroup\$

Silly thing. After setting the protection level Power On Reset is needed. No other reset type resets the micro. After the power on reset everything works fine. (only one POR needed of course after the protection level change).

It is in the RM - I have not noticed it

If the read protection is set while the debugger is still connected through JTAG/SWD, apply a POR (power-on reset) instead of a system reset.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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