I want to write an application for ARM microcontroller (Cortex-M) which should be able to load a part of code (text) from external sources and execute it when needed.An example of this would be writing a class (C++) which defines behavior of MCU when some specific chars are received on USART port.
One method would be writing look up table and arrays which contains every possible situation and populate them whenever needed. But I don't want to do this. I want to upload and execute some real code into MCU flash append it to the currently available .text .
How can I do this? How should I compile it? Should I compile the code as shared library? maybe static library? how can I append it to the existing code? What would happen to the addresses? Is there any existing solution/predefined routine for doing so?
I use arm-none-eabi toolchain.