cancel
Showing results for 
Search instead for 
Did you mean: 

How can I perform unconditional jump in random address of Flash?

Mrunal A
Associate III
Posted on February 01, 2018 at 08:24

How can I perform unconditional jump to random address in flash? I know about goto statement but I read that its not a good way to achieve this. So how can I do it? 

#nucleo-stm
1 ACCEPTED SOLUTION

Accepted Solutions
henry.dick
Senior II
Posted on February 01, 2018 at 14:49

Use a function pointer, assign is a random value (of the right range) and then call that function pointer.

Something like this is routinely done by people who sell encrypted commercial software. Once the software detects tampering, it fly's off.

View solution in original post

5 REPLIES 5
Posted on February 01, 2018 at 14:31

The micro-controller can transfer control to wherever, in C you can use things line function pointers (see qsort)

The more important question is WHAT are you trying to achieve or solve by doing this? Perhaps there is a better approach.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
henry.dick
Senior II
Posted on February 01, 2018 at 14:49

Use a function pointer, assign is a random value (of the right range) and then call that function pointer.

Something like this is routinely done by people who sell encrypted commercial software. Once the software detects tampering, it fly's off.

Posted on February 05, 2018 at 07:57

Hi CliveOne,

Actually I am trying to perform IAP(in application programming) to achieve OTA via Wifi. So I have decided to map memory and after programming jump to new code memory, for this I was thinking of implementing a check to know where to jump, hence was thinking how do I perform unconditional jump..  

Posted on February 05, 2018 at 12:19

'

how do I perform unconditional jump..  '

that's different from performing a random jump. 

take a look at the start-up file as it may give you a hint - it is fairly easy.

Posted on February 05, 2018 at 15:05

Typically with IAP the secondary app image contains a full vector table so you have access to interrupts, etc. Normally one enters through the Reset_Handler, as jumping to main() directly causes issue with the statics not being correctly initialized.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..