I am implementing external code execution for STM32F765VG with NOR flash (8/16 bit). The idea is to execute code from external flash memory. are there any ways to protect my code present in external memory from unauthorized access?
I have understood about following two methods presently. But, i am not sure whether i am thinking in right direction. Also, please guide me in right direction.
Method 1:
Encrypt whole code Hex file blockwise, before flashing to external memory. Load the blocks with normal read to the internal RAM, decrypt in the internal RAM and execute it from RAM. By this method, there will be no possibility for external parties to understand the code content of external flash memory.
Method2:
Recompile the software for every MCU and flash combination based on the unique hardware ID of flash memory and MCU ID. This way, even if the code is copied by third party, it will not execute as the IDs of new MCU will not match with the ID assumed in the code.
Please suggest if there are standard practices. Thank you in advance!