Skip to main content
Mrunal A
Associate III
February 1, 2018
Solved

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

  • February 1, 2018
  • 5 replies
  • 1074 views
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
    This topic has been closed for replies.
    Best answer by henry.dick
    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.

    5 replies

    Tesla DeLorean
    Guru
    February 1, 2018
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Mrunal A
    Mrunal AAuthor
    Associate III
    February 5, 2018
    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..  

    henry.dick
    Associate II
    February 5, 2018
    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.

    henry.dick
    henry.dickBest answer
    Associate II
    February 1, 2018
    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.