[sdiy] Executing guest synthesizer code on stm32f4

Neil Johnson neil.johnson71 at gmail.com
Tue Dec 30 18:17:55 CET 2014


Hi,

> I made a nice instrument based on the stm32f4 and I want people to be able
> to upload their own synth code into it via microphone.  Has anyone got any
> suggestions for how to do this?

Welcome to the world of dynamic code loading.  You have several
options available, none of which are what you might call "easy".

1/ User code is written in an interpreted language like Java or Lua or
Python, and you port the virtual machine interpreter to your OS
codebase.  Conceptually that is the easiest option, although
performance might suck a bit, but it does give you platform security
and highest robustness (if user code goes bad it can't overwrite OS
code since the user app is bounded inside the virtual machine
sandbox).

2/ Provide a linker template file that puts the user code into a known
address, then export all public symbols (functions and data) through C
constant tables.  You need to be careful with this technique as
depending on the C compiler it might be making standard library calls
itself, as well as compiler support libraries (GCC is really good/bad
at this depending on your point of view) and if they don't get
statically linked into the user binary then the user app won't work.

3/ You write your own linker/loader that fixes up all the references
in the user code at load-time - also get the compiler to emit
position-independent code ("pic").  You then need a linker template
file and a stub library for your users to link against.  See Windows
DLLs and Linux dynamic library loading.

4/ Port linux to your platform and let that sort it out for you.  Not
that crazy - look at uCLinux.  The Modulus 002 is Linux-based so it is
not unheard of to base a synth product on Linux.  But watch the
runtime performance.

Oh, and for options 2-4 try to get your users to use the same version
of the same compiler to avoid any ABI problems or other compatibility
issues.

Hope that helps.

Cheers,
Neil
--



More information about the Synth-diy mailing list