SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By atalax
#171498
After connecting the Nucleo to my PC, the RG LED turns red (was green when everything worked). When I run "openocd -f /usr/share/openocd/scripts/board/st_nucleo_f401re.cfg" I get following output:
Code: Select all
Info : This adapter doesn't support configurable speed
Info : STLINK v2 JTAG v19 API v2 SWIM v3 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.267850
Error: init mode failed
in procedure 'init' 
in procedure 'ocd_bouncer' 
in procedure 'transport'
in procedure 'init'
with -d 3:
Code: Select all
User : 13 2 command.c:546 command_print(): debug_level: 3
Debug: 14 2 options.c:98 add_default_dirs(): bindir=/usr/bin
Debug: 15 2 options.c:99 add_default_dirs(): pkgdatadir=/usr/share/openocd
Debug: 16 2 options.c:100 add_default_dirs(): run_prefix=
Debug: 17 2 configuration.c:44 add_script_search_dir(): adding /home/atx/.openocd
Debug: 18 2 configuration.c:44 add_script_search_dir(): adding /usr/share/openocd/site
Debug: 19 2 configuration.c:44 add_script_search_dir(): adding /usr/share/openocd/scripts
Debug: 20 2 configuration.c:84 find_file(): found /usr/share/openocd/scripts/board/st_nucleo_f401re.cfg
Debug: 21 2 configuration.c:84 find_file(): found /usr/share/openocd/scripts/interface/stlink-v2-1.cfg
Debug: 22 2 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_interface hla
Debug: 23 2 command.c:145 script_debug(): command - interface ocd_interface hla
Debug: 25 2 command.c:366 register_command_handler(): registering 'ocd_hla_device_desc'...
Debug: 26 2 command.c:366 register_command_handler(): registering 'ocd_hla_serial'...
Debug: 27 2 command.c:366 register_command_handler(): registering 'ocd_hla_layout'...
Debug: 28 2 command.c:366 register_command_handler(): registering 'ocd_hla_vid_pid'...
Debug: 29 2 command.c:366 register_command_handler(): registering 'ocd_trace'...
Debug: 30 2 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_hla_layout stlink
Debug: 31 2 command.c:145 script_debug(): command - hla_layout ocd_hla_layout stlink
Debug: 33 2 hla_interface.c:176 hl_interface_handle_layout_command(): hl_interface_handle_layout_command
Debug: 34 2 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_hla_device_desc ST-LINK/V2-1
Debug: 35 2 command.c:145 script_debug(): command - hla_device_desc ocd_hla_device_desc ST-LINK/V2-1
Debug: 37 2 hla_interface.c:150 hl_interface_handle_device_desc_command(): hl_interface_handle_device_desc_command
Debug: 38 2 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_hla_vid_pid 0x0483 0x374b
Debug: 39 2 command.c:145 script_debug(): command - hla_vid_pid ocd_hla_vid_pid 0x0483 0x374b
Debug: 41 2 hla_interface.c:204 hl_interface_handle_vid_pid_command(): hl_interface_handle_vid_pid_command
Debug: 42 2 configuration.c:84 find_file(): found /usr/share/openocd/scripts/target/stm32f4x_stlink.cfg
Debug: 43 2 configuration.c:84 find_file(): found /usr/share/openocd/scripts/target/stm32_stlink.cfg
Debug: 44 2 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_transport select hla_swd
Debug: 45 2 command.c:145 script_debug(): command - ocd_transport ocd_transport select hla_swd
Debug: 46 2 hla_transport.c:187 hl_transport_select(): hl_transport_select
Debug: 47 2 command.c:366 register_command_handler(): registering 'ocd_hla'...
Debug: 48 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 49 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 50 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 51 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 52 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 53 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 54 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 55 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 56 2 command.c:366 register_command_handler(): registering 'ocd_jtag'...
Debug: 57 2 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_hla newtap stm32f4x cpu -expected-id 0x2ba01477
Debug: 58 2 command.c:145 script_debug(): command - ocd_hla ocd_hla newtap stm32f4x cpu -expected-id 0x2ba01477
Debug: 59 2 hla_tcl.c:104 jim_hl_newtap_cmd(): Creating New Tap, Chip: stm32f4x, Tap: cpu, Dotted: stm32f4x.cpu, 2 params
Debug: 60 2 hla_tcl.c:114 jim_hl_newtap_cmd(): Processing option: -expected-id
Debug: 61 2 core.c:1319 jtag_tap_init(): Created Tap: stm32f4x.cpu @ abs position 0, irlen 0, capture: 0x0 mask: 0x0
Debug: 62 2 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_target create stm32f4x.cpu hla_target -chain-position stm32f4x.cpu
Debug: 63 2 command.c:145 script_debug(): command - ocd_target ocd_target create stm32f4x.cpu hla_target -chain-position stm32f4x.cpu
Debug: 64 2 target.c:1722 target_free_all_working_areas_restore(): freeing all working areas
Debug: 65 2 command.c:366 register_command_handler(): registering 'ocd_arm'...
Debug: 66 2 command.c:366 register_command_handler(): registering 'ocd_arm'...
Debug: 67 2 command.c:366 register_command_handler(): registering 'ocd_arm'...
Debug: 68 3 command.c:366 register_command_handler(): registering 'ocd_arm'...
Debug: 69 3 command.c:366 register_command_handler(): registering 'ocd_arm'...
Debug: 70 3 command.c:366 register_command_handler(): registering 'ocd_arm'...
Debug: 71 3 hla_target.c:367 adapter_target_create(): adapter_target_create
Debug: 72 3 hla_target.c:338 adapter_init_arch_info(): adapter_init_arch_info
Debug: 73 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 74 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 75 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 76 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 77 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 78 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 79 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 80 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 81 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 82 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 83 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 84 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 85 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 86 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 87 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 88 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 89 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 90 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 91 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 92 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 93 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 94 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 95 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 96 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 97 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 98 3 command.c:366 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 99 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x10000 -work-area-backup 0
Debug: 100 3 command.c:145 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x10000 -work-area-backup 0
Debug: 101 3 target.c:1722 target_free_all_working_areas_restore(): freeing all working areas
Debug: 102 3 target.c:1722 target_free_all_working_areas_restore(): freeing all working areas
Debug: 103 3 target.c:1722 target_free_all_working_areas_restore(): freeing all working areas
Debug: 104 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_flash bank stm32f4x.flash stm32f2x 0 0 0 0 stm32f4x.cpu
Debug: 105 3 command.c:145 script_debug(): command - ocd_flash ocd_flash bank stm32f4x.flash stm32f2x 0 0 0 0 stm32f4x.cpu
Debug: 107 3 command.c:366 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 108 3 command.c:366 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 109 3 command.c:366 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 110 3 tcl.c:804 handle_flash_bank_command(): 'stm32f2x' driver usage field missing
Debug: 111 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_reset_config srst_only srst_nogate
Debug: 112 3 command.c:145 script_debug(): command - reset_config ocd_reset_config srst_only srst_nogate
User : 114 3 command.c:546 command_print(): srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Debug: 115 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_init
Debug: 116 3 command.c:145 script_debug(): command - init ocd_init
Debug: 118 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_target init
Debug: 119 3 command.c:145 script_debug(): command - ocd_target ocd_target init
Debug: 121 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_target names
Debug: 122 3 command.c:145 script_debug(): command - ocd_target ocd_target names
Debug: 123 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu cget -event gdb-flash-erase-start
Debug: 124 3 command.c:145 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu cget -event gdb-flash-erase-start
Debug: 125 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -event gdb-flash-erase-start reset init
Debug: 126 3 command.c:145 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -event gdb-flash-erase-start reset init
Debug: 127 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu cget -event gdb-flash-write-end
Debug: 128 3 command.c:145 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu cget -event gdb-flash-write-end
Debug: 129 3 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -event gdb-flash-write-end reset halt
Debug: 130 3 command.c:145 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -event gdb-flash-write-end reset halt
Debug: 131 3 target.c:1285 handle_target_init_command(): Initializing targets...
Debug: 132 3 hla_target.c:357 adapter_init_target(): adapter_init_target
Debug: 133 3 command.c:366 register_command_handler(): registering 'ocd_target_request'...
Debug: 134 3 command.c:401 register_command(): command 'trace' is already registered in '<global>' context
Debug: 135 3 command.c:366 register_command_handler(): registering 'ocd_trace'...
Debug: 136 3 command.c:366 register_command_handler(): registering 'ocd_trace'...
Debug: 137 3 command.c:366 register_command_handler(): registering 'ocd_fast_load_image'...
Debug: 138 3 command.c:366 register_command_handler(): registering 'ocd_fast_load'...
Debug: 139 3 command.c:366 register_command_handler(): registering 'ocd_profile'...
Debug: 140 3 command.c:366 register_command_handler(): registering 'ocd_virt2phys'...
Debug: 141 3 command.c:366 register_command_handler(): registering 'ocd_reg'...
Debug: 142 3 command.c:366 register_command_handler(): registering 'ocd_poll'...
Debug: 143 3 command.c:366 register_command_handler(): registering 'ocd_wait_halt'...
Debug: 144 3 command.c:366 register_command_handler(): registering 'ocd_halt'...
Debug: 145 3 command.c:366 register_command_handler(): registering 'ocd_resume'...
Debug: 146 3 command.c:366 register_command_handler(): registering 'ocd_reset'...
Debug: 147 3 command.c:366 register_command_handler(): registering 'ocd_soft_reset_halt'...
Debug: 148 3 command.c:366 register_command_handler(): registering 'ocd_step'...
Debug: 149 3 command.c:366 register_command_handler(): registering 'ocd_mdw'...
Debug: 150 3 command.c:366 register_command_handler(): registering 'ocd_mdh'...
Debug: 151 3 command.c:366 register_command_handler(): registering 'ocd_mdb'...
Debug: 152 3 command.c:366 register_command_handler(): registering 'ocd_mww'...
Debug: 153 3 command.c:366 register_command_handler(): registering 'ocd_mwh'...
Debug: 154 3 command.c:366 register_command_handler(): registering 'ocd_mwb'...
Debug: 155 3 command.c:366 register_command_handler(): registering 'ocd_bp'...
Debug: 156 4 command.c:366 register_command_handler(): registering 'ocd_rbp'...
Debug: 157 4 command.c:366 register_command_handler(): registering 'ocd_wp'...
Debug: 158 4 command.c:366 register_command_handler(): registering 'ocd_rwp'...
Debug: 159 4 command.c:366 register_command_handler(): registering 'ocd_load_image'...
Debug: 160 4 command.c:366 register_command_handler(): registering 'ocd_dump_image'...
Debug: 161 4 command.c:366 register_command_handler(): registering 'ocd_verify_image'...
Debug: 162 4 command.c:366 register_command_handler(): registering 'ocd_test_image'...
Debug: 163 4 command.c:366 register_command_handler(): registering 'ocd_reset_nag'...
Debug: 164 4 command.c:366 register_command_handler(): registering 'ocd_ps'...
Debug: 165 4 command.c:366 register_command_handler(): registering 'ocd_test_mem_access'...
Debug: 166 4 hla_interface.c:108 hl_interface_init(): hl_interface_init
Debug: 167 4 hla_layout.c:85 hl_layout_init(): hl_layout_init
Info : 168 4 core.c:1371 adapter_init(): This adapter doesn't support configurable speed
Debug: 169 4 openocd.c:132 handle_init_command(): Debug Adapter init complete
Debug: 170 4 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_transport init
Debug: 171 4 command.c:145 script_debug(): command - ocd_transport ocd_transport init
Debug: 173 4 transport.c:240 handle_transport_init(): handle_transport_init
Debug: 174 4 hla_transport.c:148 hl_transport_init(): hl_transport_init
Debug: 175 4 hla_transport.c:165 hl_transport_init(): current transport hla_swd
Debug: 176 4 hla_interface.c:44 hl_interface_open(): hl_interface_open
Debug: 177 4 hla_layout.c:42 hl_layout_open(): hl_layout_open
Debug: 178 4 stlink_usb.c:1573 stlink_usb_open(): stlink_usb_open
Debug: 179 4 stlink_usb.c:1588 stlink_usb_open(): transport: 1 vid: 0x0483 pid: 0x374b
Info : 180 8 stlink_usb.c:468 stlink_usb_version(): STLINK v2 JTAG v19 API v2 SWIM v3 VID 0x0483 PID 0x374B
Info : 181 8 stlink_usb.c:1699 stlink_usb_open(): using stlink api v2
Debug: 182 12 stlink_usb.c:636 stlink_usb_init_mode(): MODE: 0x02
Info : 183 22 stlink_usb.c:500 stlink_usb_check_voltage(): Target voltage: 3.263116
Debug: 184 22 stlink_usb.c:691 stlink_usb_init_mode(): MODE: 0x02
Debug: 185 26 stlink_usb.c:423 stlink_usb_error_check(): status error: 9 ('unknown')
Error: 186 26 stlink_usb.c:1719 stlink_usb_open(): init mode failed
Debug: 187 26 hla_layout.c:49 hl_layout_open(): failed
Debug: 188 26 command.c:628 run_command(): Command failed with error code -4
User : 189 26 command.c:666 command_run_line(): in procedure 'init' 
in procedure 'ocd_bouncer' 
in procedure 'transport'
Debug: 190 26 command.c:628 run_command(): Command failed with error code -4
User : 191 26 command.c:666 command_run_line(): in procedure 'init'
Debug: 192 26 hla_interface.c:116 hl_interface_quit(): hl_interface_quit
after that, OpenOCD exits. The target MCU works fine. I tested the Nucleo+OpenOCD on other PC and it does not work there too. I also noticed, that I OpenOCD does not exit when I hold the reset button but just after it gets released, It starts spamming with:
Code: Select all
Error: 270 2550 hla_target.c:462 adapter_poll(): jtag status contains invalid mode value - communication failure
User : 271 2550 target.c:2412 handle_target(): Polling target stm32f4x.cpu failed, GDB will be halted. Polling again in 700ms
Debug: 272 2550 target.c:1401 target_call_event_callbacks(): target event 0 (gdb-halt)
Error: 273 3354 hla_target.c:462 adapter_poll(): jtag status contains invalid mode value - communication failure
User : 274 3354 target.c:2412 handle_target(): Polling target stm32f4x.cpu failed, GDB will be halted. Polling again in 1500ms
Debug: 275 3354 target.c:1401 target_call_event_callbacks(): target event 0 (gdb-halt)
then the LED turns orange. I also tested the stlink utility from https://github.com/texane/stlink. ./st-info --flash leads to:
Code: Select all
Error: could not open stlink device
Error: could not open stlink device
0x0
To me, it seems that the stlink has died. Has anyone seen this before?
By atalax
#171598
There already is jumper on the IDD header - the target MCU seems to be running fine (I uploaded LED blinking script onto it before and it blinks when power is on).
By atalax
#171636
Tried and produces the same result :(. I ordered standalone JTAG adapter of eBay, so I am going to try that after it arrives (going to take at least 2 weeks).
By hsutherl
#171969
I also have a NucleoF401 and now I'm seeing similar symptoms. Too tired to post details tonight. The overall sequence was something like:

1. Updated ST-Link V/2-1 using the windows utility because I could only mount the virtual drive as root in Ubuntu.
2. Wound up going back to Fedora anyway.
3. ST-Link seemed to be working so I tried to flash one file to target.
4. Now I see the similar symptoms.

Will investigate and report any findings.
By atalax
#171987
Few days ago, second nucleo arrived from Farnell. I tested debugging the old one with the new ones st-link, but that did not work. Then, I tried using the old one to debug the new one and that seems to work. So now it looks like it's the debugging part of the target STM which is dead.
By hsutherl
#172004
Sounds like you have an actual hardware failure. Which means I should post my results in a separate thread. OTOH there isn't really enough info to justify a separate thread. My "invesigation" was roughly as follows:
  • connected Nucleo back to XP laptop. Virtual drive and ST dongle detected. Not sure about COM port. I don't have openocd on that machine.
  • Imported and compiled Nucleo_Blink_LED on mbed.org, and dragged the resulting file (Nucleo_b.bin) to the virtual drive. The file appeared in the folder and the JTAG LED blinked. But none of the target LEDs did anything.
  • re-ran the ST-Link update utility. It recognized the Nucleo and displayed it as already being the latest rev. I let it do the update anyway. After that the JTAG LED turned from red to green.
  • Downloaded Nucleo_b.bin to the virtual folder again. Still nothing on target.
  • From Fedora, openocd seems to work once again
  • and it appears that Nucleo_b.bin has been faithfully copied to 0x0800 0000
  • Shut down openocd
  • copied a .bin file created with a (Makefile) project to the virtual folder. Activity on the JTAG LED but nothing on the target. Copy done from command line with cp.
  • Now openocd has the same problems as before.
I'm sure this is all solvable given some time and research. But I had a specific, narrow purpose in mind when I bought the Nucleo: hand off a simple hardware and software prototype to some co-workers**, who would then customize the code. The Nucleo has utterly failed for that purpose - if I had spent the time documenting how to set up a simple command line environment for (let's say) a Discovery board, I'd already be done. So I think I'll set the Nucleo aside.

**none of us normally do any design, hardware or software, as part of our main job. This has to be very quick and simple.
By atalax
#172437
Oh well, I am an idiot. Doing
Code: Select all
while(True) {
    GPIOA->ODR = ~GPIOA->ODR;
    sleep(10);
}
is NOT a good idea as all the SWD pins are in the GPIO bank A...
The way I managed to get OpenOCD working in the end was pulling both BOOT0 and BOOT1 up. This causes the MCU to boot from internal SRAM (which does just have some random data on reset I assume). After that, I just flashed a working binary and everything started to work fine.