Forum > Embedded - ARM

Problems debugging STM32 blue pill with Lazarus [solved - with workarounds]

(1/3) > >>

petex:
hello,
I am attempting to get the GDB debugger to work with Lazarus.

I made a debug probe using a Raspberry PI and OpenOcd. The installation of the software went very well (several cups of coffee required!) with few snags. I also got the Ocd config file to work for this particular controller (STM32F103C8T6)

I connected the Pi to a STM32 blue pill card via the probe connector and a lashup of 4 wires, and arranged the PI (powered by USB) to supply 3.3v power to the STM32.

I was able to load and run the Blinky.bin program using a telnet link from my PC to the headless Pi using WiFi on my network.

I then ran the GDB debugger (arm-embedded-gdb.exe) supplied from the MBR package from git which I used previously. I was able to use this to connect to the GDB server on the PI and run the program using remote "Monitor" commands as follows:


--- Quote ---C:\Windows\System32>C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\arm-embedded-gdb.exe
C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\gdbtest.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote 192.168.1.201:3333
Remote debugging using 192.168.1.201:3333
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x0800118a in ?? ()
(gdb) monitor program /home/pi/fileserver/temp/Blinky.bin 0x8000000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000e9c msp: 0x20005000
** Programming Started **
** Programming Finished **
(gdb) monitor reset
(gdb) monitor halt
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x0800118a msp: 0x20004f8c
(gdb)

--- End quote ---

I set up the debugger options in Lazarus to use the remote debugger. When I run the program from Lazarus, I get the following error and it shuts down.


--- Quote ---warning: Couldn't determine a path for the index cache directory

--- End quote ---

Any ideas on how to proceed ?

Also (assuming it will work) will Lazarus load the program from PC to PI automatically, or do I have to load the program from the PI side before starting ?



ps - a working openocd.cfg file for a PI zero w......

--- Code: ---source [find interface/raspberrypi-native.cfg]

transport select swd

set CHIPNAME stm32f103c8t6

source [find target/stm32f1x.cfg]

# did not yet manage to make a working setup using srst

#reset_config srst_only

reset_config  srst_nogate

adapter srst delay 100

adapter srst pulse_width 100

bcm2835gpio_swd_nums 25 24
bcm2835gpio_trst_num 7
bcm2835gpio_srst_num 18
bindto 0.0.0.0
init

targets

reset halt

--- End code ---

MiR:
Haven't seens that particular error you reported but can you please provide a screenshot of your debugger configuration in Lazarus?

And yes, the binary will get uploaded automagically from lazarus to thre device.

Michael

Martin_fr:

--- Quote from: petex on January 29, 2021, 01:50:04 pm ---
--- Quote ---warning: Couldn't determine a path for the index cache directory

--- End quote ---

--- End quote ---

At least Lazarus trunk should ignore this. I am not sure if it is in the current fixes branch. (Nor did you say which version you use?)

You can try to patch your Lazarus:
https://github.com/User4martin/lazarus/commit/739958972a81acb2e6acb53bbe49697523da3e1c
https://github.com/User4martin/lazarus/commit/739958972a81acb2e6acb53bbe49697523da3e1c.diff

petex:
notice when i run from the windows comand line i get:-
C:\Windows\System32>C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\arm-embedded-gdb.exe
C:\fpcupdeluxe-mbf\fpc\bin\x86_64-win64\gdbtest.exe: warning: Couldn't determine a path for the index cache directory.

MiR:
Set Debugger_Remote_DownloadExe to true, this will upload the binary....

You may (or may not) need to play arround with EncodeCurrentDirPath and EncodeExeFileName. The rest of the settings look good to me.

Also looks like you are using truk-lazarus, on release lazarus some of the options are missing.

Navigation

[0] Message Index

[#] Next page

Go to full version