flipperdevices / flipperzero-ufbt

Compact tool for building and debugging applications for Flipper Zero.
https://pypi.org/project/ufbt/
GNU General Public License v3.0
550 stars 38 forks source link

Issues with STlink debugging #38

Closed o7-machinehum closed 7 months ago

o7-machinehum commented 7 months ago
machinehum@walkers-macbook-pro flipper-blackhat-app % ufbt SWD_TRANSPORT=stlink flash
scons: Entering directory `/Users/machinehum/.ufbt/current/scripts/ufbt'
python3 /Users/machinehum/.ufbt/current/scripts/fwflash.py --interface=stlink --serial=auto /Users/machinehum/.ufbt/current/firmware.elf
2024-03-06 10:28:09,280 [INFO] Using stlink
2024-03-06 10:28:09,281 [INFO] Flashing /Users/machinehum/.ufbt/current/firmware.elf
.
2024-03-06 10:28:09,541 [ERROR] OpenOCD failed to flash
2024-03-06 10:28:09,542 [ERROR] xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-12-07-19:33)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : DEPRECATED target event trace-config; use TPIU events {pre,post}-{enable,disable}
Info : clock speed 500 kHz
Info : STLINK V2J24S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.283794
Error: init mode failed (unable to connect to the target)
2024-03-06 10:28:09,542 [ERROR] Failed to flash via stlink
scons: *** [/Users/machinehum/.ufbt/flash] Error 1
machinehum@walkers-macbook-pro flipper-blackhat-app % 

20240306_102856 20240306_102901

skotopes commented 7 months ago

Is debug enabled in Flipper system settings?

o7-machinehum commented 7 months ago

Is debug enabled in Flipper system settings?

How is this done?

skotopes commented 7 months ago

Main Menu -> Settings -> System -> Debug

o7-machinehum commented 7 months ago

Main Menu -> Settings -> System -> Debug

Thanks, that works. How do I debug the actual app I'm working on, is this possible with stlink?

Edit: Alright I think I have it, from a separate terminal I just issued "ufbt launch". One last question, I don't seem to have debug symbols

Thread 2 received signal SIGINT, Interrupt.
[Switching to Thread 536882352]
vPortSuppressTicksAndSleep (expected_idle_ticks=263) at targets/f7/furi_hal/furi_hal_os.c:172
172 targets/f7/furi_hal/furi_hal_os.c: No such file or directory.
(gdb) list
167 in targets/f7/furi_hal/furi_hal_os.c
(gdb) bt
#0  vPortSuppressTicksAndSleep (expected_idle_ticks=263) at targets/f7/furi_hal/furi_hal_os.c:172
#1  0x08015d28 in prvIdleTask (pvParameters=<optimized out>) at lib/FreeRTOS-Kernel/tasks.c:3524
#2  0x08013a32 in furi_thread_catch () at furi/core/thread.c:62
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) 

Can you enable this from ufbt build?

Lastly, while I have you here, is there a way to specific a serial port for the cli command?

machinehum@walkers-macbook-pro flipper-blackhat-app % ufbt cli                               
scons: Entering directory `/Users/machinehum/.ufbt/current/scripts/ufbt'
python3 /Users/machinehum/.ufbt/current/scripts/serial_cli.py -p auto
More than one Flipper is attached
Failed to guess which port to use
Is Flipper connected via USB and not in DFU mode?
machinehum@walkers-macbook-pro flipper-blackhat-app % ls /dev | grep usb
cu.usbmodemflip_Ofakri31
cu.usbmodemflip_Ofakri33
tty.usbmodemflip_Ofakri31
tty.usbmodemflip_Ofakri33
skotopes commented 7 months ago

ufbt flash ufbt debug

hedger commented 7 months ago

What do you mean by "no debug symbols"? Firmware's ELF is clearly loaded, since valid stack traces are displayed. Firmware sources are not distributed in the SDK.