This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: Thoughts about dynamically loadable code

Tool/software: TI C/C++ Compiler

Hello,

 

I would like to see if the following scenario is possible with the latest compiler (CCS8 & CC135x EV board)

  • We store 2 chunks of binary data on the external (SPI) flash, preferably using a file system, let's call those files DynaTsk1.bin and DynaTsk2.bin.
  • Let's assume that the code stored within ' DynaTsk1.bin ' simply prints 'a' , and then delay for 1000 milliseconds in an infinite loop, ' DynaTsk2.bin' does the same only it prints 'b'.
  • We create an empty memory region with a fixed start address and size, this region will be assigned by the compiler as a ram function that does not exist a boot time..
  • After the board was booted, the code loads DynaTsk1.bin into the ram function address space and start a task with a pointer to this region, we can observe the later 'a' being dumped every second.
  • After a while. The code stops this task and overwrites its memory location with the content of DynaTsk2.bin, we should now see the later 'b'.

 

The purpose of this is obviously to create a mechanism for dynamically loadable tasks.

Could this be done? If so how shall I proceed ?

Thanks,

Eitan.

  • Hi Eitan,

    This should be possible, but you are going to have to do the work yourself. Some things to consider
    - I'd limit what is in the DynaTskN.bin files. For example, I would not have any of the kernel it in...just my application code
    - I'm assuming DynaTskN.bin will reference functions or global variables not in DynaTskN.bin. Make sure any of these functions or global variables are at a fixed location so you can move between the different versions easily.
    - You need to make sure that DynaTskN.bin is not currently executing when the swap happens. In other words, no callstack (Hwi, Swi, or Task) just have a DynaTskN.bin address in it when the swap occurs.
    - I would not have DynaTskN.bin be a kernel Task. It should just be code that you call from within a kernel thread (e.g. Hwi, Swi or Task).

    Todd