cancel
Showing results for 
Search instead for 
Did you mean: 

Question on STM32CubeIDE and remote debugging

elagano
Associate

Hello,

I am looking for some guidelines on how to make remote debugging possible with STM32CubeIDE running on Win10x64 and my STM32F070RB board connected to a Linux host.

Everything works fine when the device is connected locally, but there is an option to "connect to remote GDB server" in the IDE and I am not 100% on what should be running on the Linux host.

I installed stlink-server from ST on the linux host and run it with the following:

$ sudo stlink-server --network -p 61234 -d 3

Looks like the device is found:

Debug: 1 0 options.c:113 add_default_dirs(): run_prefix=

Debug: 2 0 main.c:100 main(): create_listening_sockets

Debug: 3 0 common.c:103 create_listening_sockets(): Entering create_listening_sockets()

Debug: 4 0 common.c:104 create_listening_sockets(): Creating the list of sockets to listen for ...

Debug: 5 0 common.c:117 create_listening_sockets(): interface, tcp port : (null) , 61234

Info : 6 0 common.c:118 create_listening_sockets(): default port : 61234

Debug: 7 1 common.c:133 create_listening_sockets(): getaddrinfo successful. Enumerating the returned addresses ...

Debug: 8 1 common.c:138 create_listening_sockets(): Processing Address 0x1f7f370 returned by getaddrinfo(1) : (null)

Debug: 9 1 common.c:154 create_listening_sockets(): Created socket with handle = 3

Info : 10 1 common.c:83 print_address_string(): Remote address: 0.0.0.0

Debug: 11 1 common.c:207 create_listening_sockets(): Socket bound successfully

Debug: 12 1 common.c:219 create_listening_sockets(): Non Blocking Setting

Debug: 13 1 sock_info.c:74 alloc_sock_info(): alloc_init_sock_info : Allocated 0x1f7f410

Debug: 14 1 common.c:237 create_listening_sockets(): Added socket to list of listening sockets

Debug: 15 1 common.c:247 create_listening_sockets(): Freed the memory allocated for res by getaddrinfo

Debug: 16 1 common.c:250 create_listening_sockets(): Exiting create_listening_sockets()

Debug: 17 1 libusb1_common.c:145 stlink_libusb_init(): stlink_libusb_init

Debug: 18 23 libusb1_common.c:154 stlink_libusb_init(): libusb version : 1.0.23.11397 : http://libusb.info

Debug: 19 23 libusb1_common.c:382 stlink_libusb_open(): libusb_get_device_list entry

Debug: 20 24 libusb1_common.c:400 stlink_libusb_open(): libusb_open success 0664FF363732594D43163107

Debug: 21 24 stlink_api.c:112 get_stlink_by_name(): usb not found : 0x23befa52

Debug: 22 25 libusb1_common.c:423 stlink_libusb_open(): add to list vendor_id 0x483, devs 0x374b, 0664FF363732594D43163107

Debug: 23 25 libusb1_common.c:429 stlink_libusb_open(): new_stlink->dev->dev = 0x1f8a480, new_stlink->dev->fd = 0x1f99130

Debug: 24 25 libusb1_common.c:436 stlink_libusb_open(): close new_stlink->dev->dev = 0x1f8a480, new_stlink->dev->fd = 0x1f99130

Debug: 25 25 libusb1_common.c:450 stlink_libusb_open(): close usb device 0x1f8a480, 0x1f99130

However, when I setup IDE with remote debugger and start the debug, I see the following in the stlink-server:

Debug: 33 174755 accept.c:190 non_blocking_accept_main(): listening state : 1

Debug: 34 174755 common.c:290 process_accept_event(): Entering process_accept_event() on socket 3, sock_info 0x1f7f410

Info : 35 174755 common.c:83 print_address_string(): Remote address: 192.168.88.10

Debug: 36 174755 sock_info.c:74 alloc_sock_info(): alloc_init_sock_info : Allocated 0x1f8b860

Debug: 37 174755 common.c:329 process_accept_event(): Added accepted socket 10 to list of sockets

Debug: 38 174756 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received +$qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+#df

Debug: 39 174756 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 40 176771 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+#df

Debug: 41 176771 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 42 178776 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+#df

Debug: 43 178776 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 44 180786 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+#df

Debug: 45 180786 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 46 184799 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received -

Debug: 47 184799 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 48 186807 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received -

Debug: 49 186807 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 50 188818 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received -

Debug: 51 188818 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 52 188819 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received +

Debug: 53 188819 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 54 188822 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received $vMustReplyEmpty#3a

Debug: 55 188822 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 56 190934 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received $vMustReplyEmpty#3a

Debug: 57 190934 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 58 192931 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received $vMustReplyEmpty#3a

Debug: 59 192931 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 60 194939 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received $vMustReplyEmpty#3a

Debug: 61 194939 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 62 198955 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received -

Debug: 63 198955 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 64 200966 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received -

Debug: 65 200966 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 66 202971 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received -

Debug: 67 202971 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Debug: 68 202972 stlink_tcp_cmd.c:1161 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : unknown command received +

Debug: 69 202972 stlink_tcp_cmd.c:1163 process_stlink_tcp_cmd(): process_stlink_tcp_cmd : returned value 0 unknown_command

Error: 70 202973 common.c:391 process_read_event(): recv returned 0. Remote side has closed gracefully. Good.

Debug: 71 202973 stlink_connection.c:148 evaluate_auto_kiil(): not ask to exit() because 0

IDE reports:

Failed to execute MI command:

target remote arch00:61234

Error message from debugger back end:

Remote replied unexpectedly to 'vMustReplyEmpty': timeout

Failed to execute MI command:

target remote arch00:61234

Looks like there is some sort of a protocol mismatch, but I am not sure what is missing.

Thank you,

Eric

5 REPLIES 5
Markus GIRDLAND
ST Employee

I think it's because you're trying to start stlink-server and you should start ST-LINK_gdbserver.

elagano
Associate

Markus,

Thank you for your reply. I was thinking this direction as well, however, it is not clear what stlink-server package use case is. But I am curious if st-link_gdbserver is available as a standalone package for linux? Perhaps I can check what is in the linux package for STM32CubeIDE and try to extract gdbserver from there, as I am currently not planning to install X on my headless linux box.

Thanks,

Eric

To my knowledge I don't think stlink-server is really meant to be called standalone, it gets called by CubeIDE. We don't distribute the gdb server standalone but we might in the future, it has been discussed. For now it's shipped with the installation of CubeIDE and located at:

/opt/st/stm32cubeide_1.1.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_1.1.0.201910081157/tools/bin/

For the love of all that is right, PLEASE release a gdbserver for Linux. I am completely stalled in working with the STM32G031 because I can't get the OpenOCD patches to work and I don't have (or want) Windows. I will never understand why chip vendors don't start with a multi-arch gdbserver and then layer the GUIs on later.

MMcNa.1
Associate

They do release a gdbserver for Linux, and they gave you the path. For the release current as of today (12/2022) it is at:

$  ls -lR /opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104

/opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104:

total 28

-rw-rw-r-- 1 root root 6053 Nov 22 05:07 about.html

-rw-rw-r-- 1 root root 551 Nov 22 05:07 fragment.properties

-rw-rw-r-- 1 root root 1337 Nov 22 05:07 fragment.xml

drwxrwxr-x 2 root root 4096 Dec 19 14:31 icons

drwxrwxr-x 2 root root 4096 Dec 19 14:31 META-INF

drwxrwxr-x 4 root root 4096 Dec 19 14:30 tools

/opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104/icons:

total 4

-rw-rw-r-- 1 root root 411 Nov 22 05:07 STM32CubeIDE_icon_32px.png

/opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104/META-INF:

total 8

-rw-rw-r-- 1 root root 728 Nov 22 05:15 MANIFEST.MF

-rw-rw-r-- 1 root root 1434 Nov 22 05:15 p2.inf

/opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104/tools:

total 8

drwxrwxr-x 3 root root 4096 Dec 19 14:31 bin

drwxrwxr-x 2 root root 4096 Dec 19 14:31 doc

/opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104/tools/bin:

total 3652

-rw-rw-r-- 1 root root   619 Nov 22 05:08 49-stlinkv2-1.rules

-rw-rw-r-- 1 root root   491 Nov 22 05:08 49-stlinkv2.rules

-rw-rw-r-- 1 root root   883 Nov 22 05:08 49-stlinkv3.rules

-rw-rw-r-- 1 root root  3185 Nov 22 05:08 config.txt

drwxrwxr-x 3 root root  4096 Dec 19 14:30 native

-rwxrwxr-x 1 root root 1811176 Nov 22 05:08 ST-LINK_gdbserver

-rwxrwxr-x 1 root root   44 Nov 22 05:08 ST-LINK_gdbserver.sh

-rw-rw-r-- 1 root root 1898172 Nov 22 05:08 STLinkUpgrade.jar

/opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104/tools/bin/native:

total 4

drwxrwxr-x 2 root root 4096 Dec 19 14:31 linux_x64

/opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104/tools/bin/native/linux_x64:

total 32

-rwxrwxr-x 1 root root 31144 Nov 22 05:08 libSTLinkUSBDriver.so

/opt/st/stm32cubeide_1.11.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.0.400.202209281104/tools/doc:

total 264

-rw-rw-r-- 1 root root 267441 Nov 22 05:08 DM00613038.pdf

[10:41am] [mac@lexington] /home/mac/Build/stm32/stlink>