title: Loading and running a small script on a microcontroller with limited functionality?
body: <p>I am doing a project with a fairly powerful 32-bit microcontroller, the STM32F4 (with 192K RAM and 1024K Flash). I am using C. The system I wish to create consists of this controller (I'll call it the 'host') and a small module (the 'client'). </p>
  
  <p>The client simply contains a memory bank and an LED controller that both use the same data line (I2C) to connect to the host. The host can read from the memory and send commands to control the LED outputs on the client.</p>
  
  <p>I want to be able to write code directly on the client's memory. Then at runtime, the host will pull the code from the client and run it - and the code will be limited to doing two things:</p>
  
  <ul>
  <li>Manipulating variables in an arbitrary way</li>
  <li>Sending commands to the LED driver based on these variables.</li>
  </ul>
  
  <p>I want these limitations so that anyone can write code for a client without being able to do something malicious to the host. I am looking for a way to run a scripting language interpreter on the microcontroller for this purpose. The code on the client would then be text-format and it would be interpreted on the host.</p>
  
  <p>I have looked into eLua but it looks like it would require me to implement all of my C code on the host as Lua libraries, which I would like to avoid. Does anyone know of a solution where I can just interface to the I2C library and run simple scripts without too much pain?</p>
  
  <p>If not, is there something out there that I can build on to build this simple interpreter myself?</p>
  
  <p>I can provide any clarification if needed.</p>