I'd like to know if it is possible to write to the flash memory of my micro (Atmega 328P - Arduino Uno) during run-time. I'm currently in the process of writing a simple interpreter for it, which I want to be able to receive user code via serial, and then store it in flash memory, so that the code remains on the micro after reset. The last part is what I'm having difficulty with. I'm not sure how or if it is even possible to store data in flash memory during run-time.
The only alternative I see to this, is making a program which generates a sketch for the user, which includes both the interpreter and the user's code. However, I'd really like to avoid having to do this.