While Espruino can be compiled and debugged on a Host PC, sometimes you'll need to be able to debug the hardware itself.
We'd suggest using an STM32DISCOVERY board (not the VLDISCOVERY).
Make sure you disconnect the two ST-LINK jumpers first, then connect as detailed below. You can then use a normal debugger such as st-link on linux.
Connect wires onto the 6 pin SWD connector as follows:
Pin No. | F3/F4 Discovery Pin | Espruino Pin |
---|---|---|
1 | VDD Target | |
2 | SWCLK | A14 |
3 | GND | GND |
4 | SWDIO | A13 |
5 | NRST | |
6 | SWO |
The Six SWD connections are available on six circular pads on the back of the Pico. Pin one is unmarked, but is nearest the USB connector.
You only actually need to connect pins 2,3 and 4 - but you can connect more if you want to.
SWD SWCLK and SWDIO are available via two labelled circular pads on the top of the board, by the USB connector.
USE_BOOTLOADER=1
from the Makefile (under else ifdef ESPRUINO_1V3
), and 'bootloader' : 1,
from ESPRUINOBOARD.py
or PICO_XX.py
DEBUG=1
in order to save the relevant debug info into the binary.USE_NET
, USE_GRAPHICS
, USE_FILESYSTEM
and whatever you're not interested in, to ensure that the binary (with debug info) fits in available flashtargets/stm32/jshardware.c
, remove the line containing GPIO_Remap_SWJ_Disable
BOOT0
to 3.3v
and tap reset, which stops Espruino itself booting and reclaiming the SWD pins.Phew. Finally (if you have the st-link tools installed and on your path), you can flash Espruino, with:
DEBUG=1 ESPRUINO_1V3=1 make flash
# or
DEBUG=1 PICO_1V3=1 make flash
You can then debug by running:
st-util
in one window, and:
DEBUG=1 ESPRUINO_1V3=1 make gdb
#or
DEBUG=1 PICO_1V3=1 make gdb
in the other.
There are some useful functions defined in .gdinit
if you plan on debugging the interpreter - but if you're doing that we'd strongly suggest you try and debug a normal Linux executable of Espruino first, and only move onto actual hardware if you can't fix the problem there.
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.