Skip to main content
TARHAN SAMAH
Senior
Oct 1, 2018 8:20 AM UTC
Solved

how to protect my code from reading

hello i need to protect my code from reading or just protect the two first pages is enough because ill put my devices on market ?

i cliked on execute only code option in keil flash options

my code doesnt compile here is the error :

..\Middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM3\port.c(254): error: A1944E: Literal pool entries cannot be generated in execute-only sections

..\Middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM3\port.c(272): error: A1944E: Literal pool entries cannot be generated in execute-only sections

..\Middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM3\port.c(405): error: A1944E: Literal pool entries cannot be generated in execute-only sections

what should i do ???

This topic has been closed for replies.
TARHAN SAMAH
TARHAN SAMAHBest answer
Senior
Oct 4, 2018 8:39 AM UTC

prblm solved with st link utility

open option bytes

then select enable read out protection then download the new option byte by selecting apply .

then you will see if you try to connect to device it says that cannot read memory ..

13 replies

TARHAN SAMAH
TARHAN SAMAHAuthorBest answer
Senior
Oct 4, 2018 8:39 AM UTC

prblm solved with st link utility

open option bytes

then select enable read out protection then download the new option byte by selecting apply .

then you will see if you try to connect to device it says that cannot read memory ..

TARHAN SAMAH
Senior
Oct 5, 2018 12:39 PM UTC

there is also this way by code someone told me it thanks mister yilmaz from stm :look at the attached main file here ..good luck

GY_it
Visitor II
Jul 4, 2019 4:15 PM UTC

PoVEL A Use this code instead:

FLASH_OBProgramInitTypeDef obInit;   /* Allow Access to option bytes sector */

HAL_FLASH_Unlock();

HAL_FLASH_OB_Unlock();

 obInit.OptionType = OPTIONBYTE_RDP;

 obInit.WRPState  = OB_RDP_LEVEL_1; // VERY IMPORTANT !! DONT SET TO LEVEL2//MCU FUSE WILL SET FOR EVER.// MCU OR BOARD MAYBE UNUSABLE//

 HAL_FLASHEx_OBProgram(&obInit);   /* Start the Option Bytes programming process */

 //HAL_FLASH_OB_Launch();   /* Prevent Access to option bytes sector */

 HAL_FLASH_OB_Lock();   /* Disable the Flash option control register access (recommended to protect   the option Bytes against possible unwanted operations)*/

HAL_FLASH_Lock();