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

1 ACCEPTED SOLUTION

Accepted Solutions
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 ..

View solution in original post

13 REPLIES 13

> what should i do ???

Read the reference manual (Memory Protection part under the Flash section)?

The key words are RDP (Read Out Protection) and PcROP (Proprietary Code Read-Out Protection).

Or at least mention the microcontroller model so we can give you more precise directions or code examples.

TARHAN SAMAH
Senior

yes, thanks im working on stm32f103cb of course i have read it ,

1- i told that i tried "execute only code" option ---->it make error on building

..\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

2-second solution is

//protect our code ********************

HAL_FLASH_OB_Unlock();

FLASH_OB_RDP_LevelConfig(OB_RDP_LEVEL_1);//read protection

HAL_FLASH_OB_Launch();

HAL_FLASH_OB_Lock();

this one doesnt recognize the FLASH_OB_RDP_LevelConfig function!!

---->ROVER_LORA\ROVER_LORA.axf: Error: L6218E: Undefined symbol FLASH_OB_RDP_LevelConfig (referred from main.o). even it is clearly defined on the "stm32f1xx_hal_flash_ex.c" file

Pavel A.
Evangelist III

> even it is clearly defined on the "stm32f1xx_hal_flash_ex.c" file

So, is this file included into the project? does it compile?

-- pa

TARHAN SAMAH
Senior

no it make errors that i wrote for you up , thats why im asking this forum .

the "stm32f1xx_hal_flash_ex.c" file is in the project but it doesnt detect this function ???

TARHAN SAMAH
Senior

for stm managers:

when we want to download any software , it send us again and again to our email even we clik to the link it deosnt download it just make you turn around and come back to this email then nothing download

Start your software download

This message contains graphics.

If you do not see the graphics, click here to view

TARHAN SAMAH
Senior

Mister Pavel A. imentionned that im using stm32f103cb ,

does it allow this reading protection ??

With missing functions, make sure that stm32f1xx_hal_conf.h for your project calls out the components you want it to build/use.

>>i cliked on execute only code option in keil flash options

That's not a method to protect your code.

You want to use read-out protection, but it will make your part very difficult to debug and use in general. You'd want your code outputting debugging and telemetry data so you can understand what's going on, and likely have an interactive terminal mode so you can test/query operation. You should have a function to disengage read-out protection, and while it will mass-erase your device it can be less tedious than other methods to walk it out of the mode.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III
TARHAN SAMAH
Senior

no i dont need debug , i finished my code i just want to protect it to put it on market !!!, it should be quite easy option , like microchip its very easy but in stm looks like big issue should be very basic option ,

i dont understand

so execute only code what is it done for ???