Debugging firmware on Linux

Is there documentation on how to debug the flipper on Linux? I tried running make debug but OpenOcd doesn’t connect to the device. Any pointers on how to get this working through USB would be appreciated (is it even possible?)

I think I found the answer. Also the WI Fi dev board seems like it’ll also work.

1 Like

Will add manual for debugging soon.

2 Likes

It’s kind of not the full answer.

The WiFi board is sold out, this one was never sold in the first place.

Is there a PCB maker that would be able to build one with just the files provided?

Or can some off the-shelf board like some FTDI or STM32 USB adapters be used instead?

You can use a ST-Link V2 dongle for debugging. It is fully supported by the FBT.

That’s sold out as well. Only Chinese clones are available.

Apparently the Chinese clone is good enough. The reset pin is not connected, instead the USB cable between flipper nad PC needs to be connected in addition to the debug cable.


To summarize

This documentation Developer Board - Flipper Zero — Documentation shows a picture of custom board designed for flipper debugging

You can use an off-the-shelf ST-LINK/V2 clone instead
1bc411f64a2551578f00afe774c779bc90aeaf0f_2_690x370

First off, you will need access to flipper and debugger USB devices. qFlipper provides a script for installing udev rules for flipper itself: qFlipper/setup_rules.sh at dev · flipperdevices/qFlipper · GitHub but for stlink2 you will need an additional rule (note: the vendor and device ID corresponds to a particular Chinese device, and yours may be different)

#ST-LINK/V2 0483:3748
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", TAG+="uaccess"

Instead of TAG+="uaccess" you might want to use something like MODE="0664", GROUP="usb", OWNER="your username" - the uaccess may not always do what you want.

The ST-LINK/V2 has 3 data pins on the (small) connector. To connect the flipper

  • connect ground pin on ST-LINK/V2 to a ground pin on Flipper - Flipper pin 8 is used in the picture
  • connect SWDIO to pin 12 marked SIO on the Flipper
  • connect SWCLK to pin 10 marked SWC on the Flipper
  • connect SWIM to pin 5 marked B3 on the Flipper and SWO on the custom board picture

Suggested debugging procedure

  • disconnect Flipper and ST-LINK/V2 from USB, power off Flipper
  • connect the debug wires between Flipper and ST-LINK/V2
  • connect ST-LINK/V2 and Flipper to USB
  • run ./fbt debug in flipperzero-firmware git checkout
  • when gdb starts use r command to start the firmware
  • when you are done debugging use the menu power function to power off Flipper
  • while the debug firmware can run without the debugger it likely has some caveats - use ./fbt flash_usb to restore non-debug firmware

Troubleshooting trivial problems:

  • the debugger can run only once, it will not start if it’s already open
  • fbt needs to use the Flipper emulated USB serial port to communicate with Flipper - if you have this port open fbt will fail
  • you need sufficient permissions to open the serial and raw USB devices corresponding to Flipper and ST-LINK/V2