-
Notifications
You must be signed in to change notification settings - Fork 28
Espruino Inline C
Espruino device can run native code dynamically from binary data array. The easiest way to generate such binary data in proper format is to use inline C compiler as described here https://www.espruino.com/InlineC
This allows you to develop and test quickly and interactively even low level C code without building and uploading full native application.
Espruino website hosts InlineC compiler service for official boards only, however you can run your own version quite easily and even with additional features enabled.
The source is hosted on github https://github.com/gfwilliams/EspruinoCompiler so check its README.md and try something like this with nodejs and ARM compiler in path.
git clone https://github.com/gfwilliams/EspruinoCompiler
cd EspruinoCompiler
npm install
node server.js
Then go to web IDE https://www.espruino.com/ide/ and configure it as per README ( set Communications / JavaScript Compiler URL to http://localhost:32766) and try some example from https://www.espruino.com/InlineC
If you have it correctly setup it will fail for you for two reasons but you should still see in console of EspruinoCompiler some output. To get it really running you need to:
- Enable CORS headers so that
https://www.espruino.com/ide/
can callhttp://localhost:32766
(can be also fixed by running IDE locally too) - Disable check for official boards
And also for better functionality you can:
- enable compiler options tuned for your board CPU e.g. NRF52832 has Cortex M4 with hardware floating point
- enable C preprocessor so that commands like
#define
work.
For that you can apply this patch or do those changes in server.js
and compile.js
files by hand.