sipeed / RV-Debugger-BL702

RV-Debugger-BL702 Project, an opensource debugger implement
168 stars 60 forks source link

OpenOCD: No progress with mpsse_flush( ) #12

Open GideonZ opened 2 years ago

GideonZ commented 2 years ago

The mpsse implementation seems to be buggy. I cannot get this adapter to reliably work with OpenOCD. At times OpenOCD just hangs with the message "Haven't made progress in mpsse_flush()..."

This seems to happen more with OpenOCD 0.11.0-4, but I have also seen it happen with 0.10.0, which comes with Ubuntu (18.04 LTS).

robertlipe commented 2 years ago

For a way to reliably crash the device (admittedly a slightly different BL602...) see https://bbs.bouffalolab.com/d/118-restore-bl706-evb-mb-ability-to-upload-code/8 for a similar report.

I don't suspect this lands on Sipeed as much as it does Bouffalo and/or OpenOCD.

zqb-all commented 1 year ago

openocd log:

Debug: 14 30 command.c:166 script_debug(): command - adapter driver ftdi
Debug: 15 31 command.c:166 script_debug(): command - ftdi vid_pid 0x0403 0x6010
Debug: 16 35 command.c:166 script_debug(): command - transport select jtag
Debug: 17 36 command.c:166 script_debug(): command - ftdi layout_init 0x0008 0x001b
Debug: 18 38 command.c:166 script_debug(): command - ftdi layout_signal nSRST -oe 0x0020 -data 0x0020
Debug: 19 39 command.c:166 script_debug(): command - adapter speed 1200
Debug: 20 40 adapter.c:176 adapter_config_khz(): handle adapter khz
Debug: 21 41 adapter.c:140 adapter_khz_to_speed(): convert khz to adapter specific speed value
Debug: 22 43 adapter.c:140 adapter_khz_to_speed(): convert khz to adapter specific speed value
Debug: 23 44 command.c:166 script_debug(): command - bindto 0.0.0.0
Debug: 24 45 command.c:166 script_debug(): command - gdb_port 1025
Debug: 25 46 command.c:166 script_debug(): command - jtag newtap riscv cpu -irlen 5 -expected-id 0x10000BF6
Debug: 26 50 tcl.c:568 jim_newtap_cmd(): Creating New Tap, Chip: riscv, Tap: cpu, Dotted: riscv.cpu, 4 params
Debug: 27 52 tcl.c:593 jim_newtap_cmd(): Processing option: -irlen
Debug: 28 53 tcl.c:593 jim_newtap_cmd(): Processing option: -expected-id
Debug: 29 54 core.c:1468 jtag_tap_init(): Created Tap: riscv.cpu @ abs position 0, irlen 5, capture: 0x1 mask: 0x3
Debug: 30 56 command.c:166 script_debug(): command - target create riscv.cpu.0 riscv -chain-position riscv.cpu
Debug: 31 57 target.c:2214 target_free_all_working_areas_restore(): freeing all working areas
Debug: 32 59 riscv.c:356 riscv_create_target(): riscv_create_target()
Debug: 33 60 command.c:166 script_debug(): command - riscv.cpu.0 configure -work-area-phys 0x20000000 -work-area-size 4096 -work-area-backup 0
Debug: 34 64 target.c:2214 target_free_all_working_areas_restore(): freeing all working areas
Debug: 35 66 target.c:2214 target_free_all_working_areas_restore(): freeing all working areas
Debug: 36 67 target.c:2214 target_free_all_working_areas_restore(): freeing all working areas
Debug: 37 68 command.c:166 script_debug(): command - init
Debug: 38 69 command.c:166 script_debug(): command - target init
Debug: 39 70 command.c:166 script_debug(): command - target names
Debug: 40 71 command.c:166 script_debug(): command - riscv.cpu.0 cget -event gdb-flash-erase-start
Debug: 41 72 command.c:166 script_debug(): command - riscv.cpu.0 configure -event gdb-flash-erase-start reset init
Debug: 42 74 command.c:166 script_debug(): command - riscv.cpu.0 cget -event gdb-flash-write-end
Debug: 43 76 command.c:166 script_debug(): command - riscv.cpu.0 configure -event gdb-flash-write-end reset halt
Debug: 44 80 command.c:166 script_debug(): command - riscv.cpu.0 cget -event gdb-attach
Debug: 45 81 command.c:166 script_debug(): command - riscv.cpu.0 configure -event gdb-attach halt 1000
Debug: 46 83 target.c:1671 handle_target_init_command(): Initializing targets...
Debug: 47 84 riscv.c:369 riscv_init_target(): riscv_init_target()
Debug: 48 85 semihosting_common.c:130 semihosting_common_init():
Debug: 49 86 ftdi.c:742 ftdi_initialize(): ftdi interface using shortest path jtag state transitions
Debug: 50 110 mpsse.c:423 mpsse_purge(): -
Debug: 51 111 mpsse.c:704 mpsse_loopback_config(): off
Debug: 52 112 mpsse.c:749 mpsse_set_frequency(): target 1200000 Hz
Debug: 53 113 mpsse.c:710 mpsse_set_divisor(): 4
Debug: 54 114 mpsse.c:773 mpsse_set_frequency(): actually 1200000 Hz
Debug: 55 115 adapter.c:140 adapter_khz_to_speed(): convert khz to adapter specific speed value
Debug: 56 116 adapter.c:144 adapter_khz_to_speed(): have adapter set up
Debug: 57 118 mpsse.c:749 mpsse_set_frequency(): target 1200000 Hz
Debug: 58 119 mpsse.c:710 mpsse_set_divisor(): 4
Debug: 59 119 mpsse.c:773 mpsse_set_frequency(): actually 1200000 Hz
Debug: 60 120 adapter.c:140 adapter_khz_to_speed(): convert khz to adapter specific speed value
Debug: 61 122 adapter.c:144 adapter_khz_to_speed(): have adapter set up
Info : 62 123 adapter.c:104 adapter_init(): clock speed 1200 kHz
Debug: 63 126 openocd.c:143 handle_init_command(): Debug Adapter init complete
Debug: 64 127 command.c:166 script_debug(): command - transport init
Debug: 65 128 transport.c:230 handle_transport_init(): handle_transport_init
Debug: 66 130 core.c:824 jtag_add_reset(): SRST line released
Debug: 67 130 core.c:849 jtag_add_reset(): TRST line released
Debug: 68 131 core.c:322 jtag_call_event_callbacks(): jtag event: TAP reset
Debug: 69 133 command.c:166 script_debug(): command - jtag arp_init
Debug: 70 134 target.c:1857 target_call_event_callbacks(): target event 0 (gdb-halt) for core riscv.cpu.0
Debug: 71 135 target.c:3072 handle_target(): [riscv.cpu.0] target_poll() -> -4, next attempt in 100ms
Debug: 72 137 core.c:1503 jtag_init_inner(): Init JTAG chain
Debug: 73 137 core.c:322 jtag_call_event_callbacks(): jtag event: TAP reset
Debug: 74 139 core.c:1228 jtag_examine_chain(): DR scan interrogation for IDCODE/BYPASS
Debug: 75 142 core.c:322 jtag_call_event_callbacks(): jtag event: TAP reset
Warn : 76 2144 mpsse.c:917 mpsse_flush(): Haven't made progress in mpsse_flush() for 2001ms.
Warn : 77 4144 mpsse.c:917 mpsse_flush(): Haven't made progress in mpsse_flush() for 4001ms.
Warn : 78 8144 mpsse.c:917 mpsse_flush(): Haven't made progress in mpsse_flush() for 8001ms.
Warn : 79 16144 mpsse.c:917 mpsse_flush(): Haven't made progress in mpsse_flush() for 16001ms.
Warn : 80 32144 mpsse.c:917 mpsse_flush(): Haven't made progress in mpsse_flush() for 32001ms.
Warn : 81 64144 mpsse.c:917 mpsse_flush(): Haven't made progress in mpsse_flush() for 64001ms.
Warn : 82 128144 mpsse.c:917 mpsse_flush(): Haven't made progress in mpsse_flush() for 128001ms.

sipeed usb-jtag/ttl and sipeed rv-debugger lite can work, only sipeed rv-debugger plus have this issue.

Can anyone give me some advice?

GideonZ commented 1 year ago

I had the same issue. I also measured the JTAG signals with an oscilloscope. It was nonsense; TMS changing on both the rising and falling edges. I reported it to the seller and dumped it in the trash.

Been using an FTDI FT2232H since without issues.

thecasterian commented 1 year ago

So this is why I could not use this debugger in PlatformIO...

thecasterian commented 1 year ago

After re-flashing the debugger following the fixed instruction in https://github.com/sipeed/RV-Debugger-BL702/pull/15 it now works perfectly without such an error! The firmware initially uploaded on a new debugger might be somewhat broken.