cancel
Showing results for 
Search instead for 
Did you mean: 

how to protect my code from reading

TARHAN SAMAH
Senior

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 ???

13 REPLIES 13
TARHAN SAMAH
Senior

in hal config

its opened

#ifdef HAL_FLASH_MODULE_ENABLED

 #include "stm32f1xx_hal_flash.h"

i added

 #include "stm32f1xx_hal_flash_ex.h"// i add it 

it didnt affect still it doesnt detect FLASH_OB_RDP_LevelConfig

TARHAN SAMAH
Senior

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

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
Associate

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();