Hi all,
I was trying to use OpenOCD to debug my STM32F303RC6 MCU on my Ubuntu 22.04. However, when I enter command openocd -f interface/stlink.cfg -c "transport select hlaswd" -f target/stm32f3x.cfg. I encounter a segmentation fault error. I guess there probably has a usb driver issue but I don't know what is the correct version for OpenOCD. My libusb-1.0-0-dev is version 2:1.0.25-1ubuntu1 amd64.
The following is the debug log, very grateful for all your time and help!
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
User : 13 1 options.c:63 configuration_output_handler(): debug_level: 3
User : 14 1 options.c:63 configuration_output_handler():
Debug: 15 1 options.c:244 add_default_dirs(): bindir=/usr/bin
Debug: 16 1 options.c:245 add_default_dirs(): pkgdatadir=/usr/share/openocd
Debug: 17 1 options.c:246 add_default_dirs(): exepath=/usr/bin
Debug: 18 1 options.c:247 add_default_dirs(): bin2data=../share/openocd
Debug: 19 1 configuration.c:42 add_script_search_dir(): adding /home/yd/.config/openocd
Debug: 20 1 configuration.c:42 add_script_search_dir(): adding /home/yd/.openocd
Debug: 21 1 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/site
Debug: 22 1 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/scripts
Debug: 23 2 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/interface/stlink.cfg
Debug: 24 2 command.c:146 script_debug(): command - adapter driver hla
Debug: 26 2 command.c:146 script_debug(): command - hla_layout stlink
Debug: 28 2 hla_interface.c:242 hl_interface_handle_layout_command(): hl_interface_handle_layout_command
Debug: 29 2 command.c:146 script_debug(): command - hla_device_desc ST-LINK
Debug: 31 2 hla_interface.c:216 hl_interface_handle_device_desc_command(): hl_interface_handle_device_desc_command
Debug: 32 2 command.c:146 script_debug(): command - hla_vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753
Debug: 34 2 command.c:146 script_debug(): command - transport select hla_swd
Debug: 35 2 hla_transport.c:205 hl_swd_transport_select(): hl_swd_transport_select
User : 36 2 options.c:63 configuration_output_handler(): hla_swdUser : 37 2 options.c:63 configuration_output_handler():
Debug: 38 2 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/target/stm32f3x.cfg
Debug: 39 2 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/target/swj-dp.tcl
Debug: 40 2 command.c:146 script_debug(): command - transport select
Debug: 41 2 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/mem_helper.tcl
Debug: 42 2 command.c:146 script_debug(): command - add_usage_text mrw address
Debug: 44 2 command.c:1115 help_add_command(): added 'mrw' help text
Debug: 45 2 command.c:146 script_debug(): command - add_help_text mrw Returns value of word in memory.
Debug: 47 2 command.c:1128 help_add_command(): added 'mrw' help text
Debug: 48 2 command.c:146 script_debug(): command - add_usage_text mrh address
Debug: 50 2 command.c:1115 help_add_command(): added 'mrh' help text
Debug: 51 2 command.c:146 script_debug(): command - add_help_text mrh Returns value of halfword in memory.
Debug: 53 2 command.c:1128 help_add_command(): added 'mrh' help text
Debug: 54 2 command.c:146 script_debug(): command - add_usage_text mrb address
Debug: 56 2 command.c:1115 help_add_command(): added 'mrb' help text
Debug: 57 2 command.c:146 script_debug(): command - add_help_text mrb Returns value of byte in memory.
Debug: 59 2 command.c:1128 help_add_command(): added 'mrb' help text
Debug: 60 2 command.c:146 script_debug(): command - add_usage_text mmw address setbits clearbits
Debug: 62 2 command.c:1115 help_add_command(): added 'mmw' help text
Debug: 63 2 command.c:146 script_debug(): command - add_help_text mmw Modify word in memory. new_val = (old_val & ~clearbits) | setbits;
Debug: 65 2 command.c:1128 help_add_command(): added 'mmw' help text
Debug: 66 2 command.c:146 script_debug(): command - adapter speed 1000
Debug: 68 2 core.c:1822 jtag_config_khz(): handle jtag khz
Debug: 69 2 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 70 2 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 71 2 command.c:146 script_debug(): command - adapter srst delay 100
Debug: 73 2 command.c:146 script_debug(): command - transport select
Debug: 74 2 command.c:146 script_debug(): command - transport select
Debug: 75 2 command.c:146 script_debug(): command - transport select
Debug: 76 2 command.c:146 script_debug(): command - transport select
Debug: 77 2 command.c:146 script_debug(): command - swd newdap stm32f3x cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x2ba01477
Debug: 78 2 hla_tcl.c:110 jim_hl_newtap_cmd(): Creating New Tap, Chip: stm32f3x, Tap: cpu, Dotted: stm32f3x.cpu, 8 params
Debug: 79 2 hla_tcl.c:121 jim_hl_newtap_cmd(): Processing option: -irlen
Debug: 80 2 hla_tcl.c:121 jim_hl_newtap_cmd(): Processing option: -ircapture
Debug: 81 2 hla_tcl.c:121 jim_hl_newtap_cmd(): Processing option: -irmask
Debug: 82 2 hla_tcl.c:121 jim_hl_newtap_cmd(): Processing option: -expected-id
Debug: 83 2 core.c:1484 jtag_tap_init(): Created Tap: stm32f3x.cpu @ abs position 0, irlen 0, capture: 0x0 mask: 0x0
Debug: 84 2 command.c:146 script_debug(): command - dap create stm32f3x.dap -chain-position stm32f3x.cpu
Debug: 85 2 command.c:146 script_debug(): command - transport select
Debug: 86 2 command.c:146 script_debug(): command - target create stm32f3x.cpu cortex_m -endian little -dap stm32f3x.dap
Info : 87 2 target.c:5668 target_create(): The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Debug: 88 2 hla_target.c:203 adapter_target_create(): adapter_target_create
Debug: 89 2 hla_target.c:173 adapter_init_arch_info(): adapter_init_arch_info
Debug: 90 2 command.c:375 register_command(): command 'rtt' is already registered in '<global>' context
Debug: 91 2 command.c:146 script_debug(): command - stm32f3x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x4000 -work-area-backup 0
Debug: 92 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 93 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 94 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 95 2 command.c:146 script_debug(): command - flash bank stm32f3x.flash stm32f1x 0 0 0 0 stm32f3x.cpu
Debug: 97 2 tcl.c:1319 handle_flash_bank_command(): 'stm32f1x' driver usage field missing
Debug: 98 2 command.c:146 script_debug(): command - reset_config srst_nogate
Debug: 100 2 command.c:146 script_debug(): command - transport select
Debug: 101 2 command.c:146 script_debug(): command - stm32f3x.cpu configure -event examine-end stm32f3x_default_examine_end
Debug: 102 2 command.c:146 script_debug(): command - stm32f3x.cpu configure -event reset-start stm32f3x_default_reset_start
Debug: 103 2 command.c:146 script_debug(): command - stm32f3x.cpu configure -event reset-init stm32f3x_default_reset_init
Debug: 104 2 command.c:146 script_debug(): command - stm32f3x.cpu configure -event trace-config
# Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
# change this value accordingly to configure trace pins
# assignment
mmw 0xe0042004 0x00000020 0</global>
Info : 105 2 server.c:311 add_service(): Listening on port 6666 for tcl connections
Info : 106 2 server.c:311 add_service(): Listening on port 4444 for telnet connections
Debug: 107 2 command.c:146 script_debug(): command - init
Debug: 109 2 command.c:146 script_debug(): command - target init
Debug: 111 2 command.c:146 script_debug(): command - target names
Debug: 112 2 command.c:146 script_debug(): command - stm32f3x.cpu cget -event gdb-flash-erase-start
Debug: 113 2 command.c:146 script_debug(): command - stm32f3x.cpu configure -event gdb-flash-erase-start reset init
Debug: 114 2 command.c:146 script_debug(): command - stm32f3x.cpu cget -event gdb-flash-write-end
Debug: 115 2 command.c:146 script_debug(): command - stm32f3x.cpu configure -event gdb-flash-write-end reset halt
Debug: 116 2 command.c:146 script_debug(): command - stm32f3x.cpu cget -event gdb-attach
Debug: 117 2 command.c:146 script_debug(): command - stm32f3x.cpu configure -event gdb-attach halt 1000
Debug: 118 2 target.c:1639 handle_target_init_command(): Initializing targets...
Debug: 119 2 hla_target.c:193 adapter_init_target(): adapter_init_target
Debug: 120 2 semihosting_common.c:99 semihosting_common_init():
Debug: 121 2 hla_interface.c:109 hl_interface_init(): hl_interface_init
Debug: 122 2 hla_layout.c:95 hl_layout_init(): hl_layout_init
Debug: 123 2 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 124 2 core.c:1789 adapter_khz_to_speed(): have interface set up
Debug: 125 2 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 126 2 core.c:1789 adapter_khz_to_speed(): have interface set up
Info : 127 2 core.c:1565 adapter_init(): clock speed 1000 kHz
Debug: 128 2 openocd.c:143 handle_init_command(): Debug Adapter init complete
Debug: 129 2 command.c:146 script_debug(): command - transport init
Debug: 131 2 transport.c:229 handle_transport_init(): handle_transport_init
Debug: 132 2 hla_transport.c:156 hl_transport_init(): hl_transport_init
Debug: 133 2 hla_transport.c:173 hl_transport_init(): current transport hla_swd
Debug: 134 2 hla_interface.c:42 hl_interface_open(): hl_interface_open
Debug: 135 2 hla_layout.c:40 hl_layout_open(): hl_layout_open
Debug: 136 2 stlink_usb.c:2819 stlink_usb_open(): stlink_usb_open
Debug: 137 2 stlink_usb.c:2831 stlink_usb_open(): transport: 4 vid: 0x0483 pid: 0x3744 serial:
Debug: 138 2 stlink_usb.c:2831 stlink_usb_open(): transport: 4 vid: 0x0483 pid: 0x3748 serial:
Debug: 139 2 stlink_usb.c:2831 stlink_usb_open(): transport: 4 vid: 0x0483 pid: 0x374b serial:
Debug: 140 2 stlink_usb.c:2831 stlink_usb_open(): transport: 4 vid: 0x0483 pid: 0x374d serial:
Debug: 141 2 stlink_usb.c:2831 stlink_usb_open(): transport: 4 vid: 0x0483 pid: 0x374e serial:
Debug: 142 2 stlink_usb.c:2831 stlink_usb_open(): transport: 4 vid: 0x0483 pid: 0x374f serial:
Debug: 143 2 stlink_usb.c:2831 stlink_usb_open(): transport: 4 vid: 0x0483 pid: 0x3752 serial:
Debug: 144 2 stlink_usb.c:2831 stlink_usb_open(): transport: 4 vid: 0x0483 pid: 0x3753 serial:
Segmentation fault (core dumped)
This is a duplicate of ticket https://sourceforge.net/p/openocd/tickets/308/
Solved with http://review.openocd.org/6331
Please use older libusb or rebuild OpenOCD from git's master branch
The other possibility is to upgrade to libusb 1.0.26 to see if that helps.
https://github.com/libusb/libusb/blob/master/ChangeLog
2022-04-10: v1.0.26 * Fix regression with transfer free's after closing device * Fix regression with destroyed context if API is misused * Workaround for applications using missing default context
...
Hi, unfortunately just downgrade to 1.0.24 or update to 1.0.26 are not working. So I rebuild openocd with 1.0.24 which seems okay now.
Last edit: Splen Did 2022-05-19
Did you rebuild OpenOCD from the git master branch as suggested here?
https://sourceforge.net/p/openocd/tickets/351/#8032
Edit: post crossed with Antonio's
https://sourceforge.net/p/openocd/tickets/351/#8955
Last edit: Tommy Murphy 2022-05-19
And what about recompiling OpenOCD from master branch?
Hi, I just rebuilt OpenOCD and it works now. Sorry to make you reopen the ticket!
No problem, I probably closed it to quickly.
It remains the strange observation that downgrading to 1.0.24 doesn't work.
Can be something incorrect in such test?