Skip to content

Espruino

fanoush edited this page Nov 11, 2019 · 8 revisions

Status

Espruino is working fine with all the hardware. There are no known issues to be solved. It it ready for your code.

DFU zip package can be flashed via DFU update procedure and it is also possible to restore original fitness app back or flash updated Espruino without opening the watch. You can either use build based on Nordic SDK11 which works with existing bootloader and bluetooth stack or you can use the more involved procedure and upgrade bootloader and Bluetooth SoftDevice to newer version which gives you few extra bluetooth features and better compatibility with upstream Espruino.

Info

Espruino is javascript for microcontrollers. It is very easy for development and for trying stuff interactively (probe various buses, try different drivers) - much easier than building C code. Espruino has excellent support for nRF52832 chip because official Espruino boards are based on it.

Tips & gotchas

If you do not to want to open your watch to reset or restore it, some precaution is needed. Make sure you avoid common pitfalls

  • do not turn off both bluetooth and serial console without having a way to enable the console back and/or reset device and reboot to bootloader from your running app

  • be careful with save() command - it saves javascript state including variables, enabled watches and intervals and pin state, however it cannot save current state of initialized hardware (display, sensors) which may be unexpected for your running code after reboot. Safest is to run save() when nothing is running yet and do all initialization later. Or maybe avoid save() altogether and put your code to storage and use .boot0 file

  • enable watchdog preferably with the manual way and do not kick the watchdog unless you determine in your code it is still safe

If you still manage to get into bad state without way to recover you may try to wait for battery to go empty then power is cut completely and after attaching to charger it boots again. At boot time you may try to hold touch button - it may go to DFU bootloader or just skip espruino boot code.

History

Getting it working was just a matter of setting right pins in board description file and building it :-)

I started with boards/MDBT42Q.py and changed serial console pins to D22 RX and D23 TX.

I currently have Espruino working with console over serial or bluetooth, even the Web IDE over Web Bluetooth works in Chrome! I used it to probe I2C and SPI buses to find the hardware. Now I have OLED display working with modified SSD1306 module. Details about the progress here

My current board file and Espruino build is here https://github.com/fanoush/ds-d6/tree/master/espruino For now this is clean build with no extra functionality, just the fonts modules are included (as listed in DSD6.py board file)

Code in progress that can be loaded via serial console or web ide is here https://gist.github.com/fanoush/ce461c73c299834bcb53a615721b5a2e