Using the embedded debugger

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
nrD
Posts: 7
Joined: Wed Oct 21, 2020 12:30 am

Using the embedded debugger

Post by nrD » Thu Oct 22, 2020 2:54 am

Both microbit v1 and v2 have integrated debugger. I know it is possible to use it with platformio for example.

Any way to use it in micropython (ideally with some kind of GUI like with VS Code - whether that is using GDB underneath with some kind of remote attach or whatever)?

I think it would be amazing for teaching students (both high school and university). We currently do this with Atmel Studio on SAMD boards (running FreeRTOS).

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Using the embedded debugger

Post by jimmo » Thu Oct 22, 2020 6:37 am

nrD wrote:
Thu Oct 22, 2020 2:54 am
Any way to use it in micropython (ideally with some kind of GUI like with VS Code - whether that is using GDB underneath with some kind of remote attach or whatever)?

I think it would be amazing for teaching students (both high school and university). We currently do this with Atmel Studio on SAMD boards (running FreeRTOS).
Yes, I have done this with the v1 micro:bit (and I imagine the v2 will be similar).

Note that this is limited to debugging the C code, not the Python code (there's no interactive debugger for MicroPython on any board), but I assume that if you're comparing to FreeRTOS on SAMD then this is what you mean anyway.

The basic idea is that the USB frontend on the micro:bit runs DAPLink, which you can connect to with pyocd or openocd, and then gdb use that as a remote and debug using the elf file. I don't have any experience with VS Code, but hopefully that just builds on top of gdb and remote attach.

Here's how I do it with a v1 micro:bit

In one terminal:
$ pyocd-gdbserver

In another terminal
$ arm-none-eabi-gdb build-microbit/firmware.elf
...
(gdb) target remote localhost:3333

Post Reply