2015-05-28 05:55 PM
Hi,
I am developing codes on STM32L0 microcontrollerI want to add flash read out protection function in the code.After I enable the PcROP(proprietary Code Read Out Protection), my codes do not work anymore. It does not accept I2C commands, does not toggle LED programmed in the flash.If I remove that protection, my codes work fine.In the code, I update option bytes and reload them. After system reboot, I make sure the system will not trigger OB_Launch bit again. I don't know where the codes halt since I cannot debug anymore...The Keil IDE shows cannot access the target..I use the ST-link IDE to check option bytes. they are the same as I set. If I enable PcROP, do I need to change RDP level from 0 to 1?I think it should be level1 but either level 0 or 1 does not make my codes run...Please helpThank you. #stm32-stm32l0-cortex-m0 #stm32l0-flash-read-out-protect2015-05-29 02:10 AM
Hi Tansem
PCROP disable data access to flash the manual say:Any read access performed through the D-bus triggers a RDERR flag error.
And alsoAny program/erase operation on a PCROPed sector triggers a WRPERR flag error.
Check if the code contain static data like const .... or strings const data in PcROP sector protect can't be accessed while execute code You must separe data from code placing the code in sectors with PCROP protection and data in sector with RDP only protection use the linker for placing ro data section and code section in different memory sectors. I am using IAR and I can't help you with linker settings2015-05-29 02:56 PM
i think these read/write mentioned in the programming manual means outside read/write. If in the code I have read/write function, they should work, right?
In application note AN4246, page 5 I am able to add command line ''armcc --no_literal_pools --max_string_in_code=0'' to avoid the side effect generated by this execute-only mechanism makes the protected code itself unable to access the associated data values stored in the same area. I did that but still no effect. I will try to find out if there is any constant value stored in flash which read by my codes.2015-05-29 02:59 PM
actually i have bootloader too. the bootloader and application work well when no read out protection. after add protection for both sections, they do not work. I may try only protect application section.
2015-06-04 10:27 AM
Hi Tansem,
There are good practices that can help you: 1-you can place a code (functions) in a PCROP sector that use no contants and no data, as the data bus is not accessible with PCROP protection. After, you create your own main from which you call the protected code. 2-To enable the execute-only mechanism to get rid of literal pools, you can do these 2 steps (both are essential): 1-Click right on the file to be executed->option file...->c/c++->language->code generation->tick ''Execute only code'', in Linker tilt ''Use Memory layout from target Dialog'' 2-In the linker file, you determine the PCROP protected sector, you add files containing the code and you add (+XO) in front of every one. 3-If you have a bootloader, you should be aware that with RDP protection there are some restriction for rebooting the device. Have a look at the reference manual of STM32L0 below (page 88): I hope, these points could help