ElectronicCats / DAP-Cat-Programmer

An Open-Source CMSIS-DAP Debug Probe based on DAPLink and USB bus convert and it can realize USB convert to serial interface based in CH552, low-cost of $3 dollars
GNU Lesser General Public License v2.1
91 stars 29 forks source link

DAPCat not recognized as a CMSIS-DAP device #7

Open Daniel9719 opened 2 weeks ago

Daniel9719 commented 2 weeks ago

Describe the problem: I've bought the DAPCat and tried to make it run under OpenOCD using the cmsis-dap interface but the device does not seem to be recognized as a CMSIS DAP device.

I tried to contact the support team of Electronic Cats (support1@electroniccats.com) back on October 5th, 2022 with the subject "DapCat" under my email (danieldraftsman@gmail.com) but I didn't get a solution to this problem. I was instructed to reflash my device using the release file CMSIS_DAP.ino.ch552.hex found at https://github.com/ElectronicCats/DAP-Cat-Programmer/releases using the WCHISPTool and by setting the device on boot mode (which I accomplished by pressing the boot button on the board while I powered on the device). I was successful at flashing the file into the board as you can see below

image

But even after following those steps I haven't been able to have the device recognized as a CMSIS-DAP device.

Reproduce steps First, have the device recognized by the linux environment, you can use the command lsusb for this purpose as illustrated below

image

Run the following command under a linux environment (I've specified my environment below) sudo openocd -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s /home/danielortiz2/OS_Course_Skills/os_core_skills_course -c "debug_level 4" -f /home/vscode/.vscode-server/extensions/marus25.cortex-debug-1.12.1/support/openocd-helpers.tcl -f /interface/cmsis-dap.cfg -c "transport select swd" -f /target/stm32f4x.cfg

Expected behavior: I'd expect the DAPCat to be recognized as a CMSIS-DAP device

Screenshots: The result that I get from OpenOCD after running the previous command is the following:

Open On-Chip Debugger 0.11.0 Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html User : 16 3 options.c:63 configuration_output_handler(): debug_level: 4 User : 17 3 options.c:63 configuration_output_handler(): Debug: 18 3 configuration.c:97 find_file(): found /home/vscode/.vscode-server/extensions/marus25.cortex-debug-1.12.1/support/openocd-helpers.tcl User : 19 3 options.c:63 configuration_output_handler(): CDLiveWatchSetupUser : 20 3 options.c:63 configuration_output_handler(): Debug: 21 3 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts//interface/cmsis-dap.cfg Debug: 22 4 command.c:146 script_debug(): command - adapter driver cmsis-dap Debug: 24 4 command.c:146 script_debug(): command - transport select swd User : 25 4 options.c:63 configuration_output_handler(): swdUser : 26 4 options.c:63 configuration_output_handler(): Debug: 27 4 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts//target/stm32f4x.cfg Debug: 28 4 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/target/swj-dp.tcl Debug: 29 4 command.c:146 script_debug(): command - transport select Debug: 30 4 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/mem_helper.tcl Debug: 31 4 command.c:146 script_debug(): command - add_usage_text mrw address Debug: 33 4 command.c:1115 help_add_command(): added 'mrw' help text Debug: 34 5 command.c:146 script_debug(): command - add_help_text mrw Returns value of word in memory. Debug: 36 5 command.c:1128 help_add_command(): added 'mrw' help text Debug: 37 5 command.c:146 script_debug(): command - add_usage_text mrh address Debug: 39 5 command.c:1115 help_add_command(): added 'mrh' help text Debug: 40 5 command.c:146 script_debug(): command - add_help_text mrh Returns value of halfword in memory. Debug: 42 5 command.c:1128 help_add_command(): added 'mrh' help text Debug: 43 5 command.c:146 script_debug(): command - add_usage_text mrb address Debug: 45 5 command.c:1115 help_add_command(): added 'mrb' help text Debug: 46 5 command.c:146 script_debug(): command - add_help_text mrb Returns value of byte in memory. Debug: 48 5 command.c:1128 help_add_command(): added 'mrb' help text Debug: 49 5 command.c:146 script_debug(): command - add_usage_text mmw address setbits clearbits Debug: 51 5 command.c:1115 help_add_command(): added 'mmw' help text Debug: 52 5 command.c:146 script_debug(): command - add_help_text mmw Modify word in memory. new_val = (old_val & ~clearbits) | setbits; Debug: 54 5 command.c:1128 help_add_command(): added 'mmw' help text Debug: 55 5 command.c:146 script_debug(): command - transport select Debug: 56 5 command.c:146 script_debug(): command - transport select Debug: 57 5 command.c:146 script_debug(): command - transport select Debug: 58 5 command.c:146 script_debug(): command - swd newdap stm32f4x cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x2ba01477 Debug: 59 5 tcl.c:571 jim_newtap_cmd(): Creating New Tap, Chip: stm32f4x, Tap: cpu, Dotted: stm32f4x.cpu, 8 params Debug: 60 5 core.c:1484 jtag_tap_init(): Created Tap: stm32f4x.cpu @ abs position 0, irlen 0, capture: 0x0 mask: 0x0 Debug: 61 5 command.c:146 script_debug(): command - dap create stm32f4x.dap -chain-position stm32f4x.cpu Debug: 62 5 command.c:146 script_debug(): command - transport select Debug: 63 5 command.c:146 script_debug(): command - target create stm32f4x.cpu cortex_m -endian little -dap stm32f4x.dap Debug: 64 5 command.c:375 register_command(): command 'rtt' is already registered in '' context Debug: 65 5 command.c:146 script_debug(): command - stm32f4x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x8000 -work-area-backup 0 Debug: 66 5 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas Debug: 67 5 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas Debug: 68 5 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas Debug: 69 5 command.c:146 script_debug(): command - flash bank stm32f4x.flash stm32f2x 0 0 0 0 stm32f4x.cpu Debug: 71 6 tcl.c:1319 handle_flash_bank_command(): 'stm32f2x' driver usage field missing Debug: 72 6 command.c:146 script_debug(): command - flash bank stm32f4x.otp stm32f2x 0x1fff7800 0 0 0 stm32f4x.cpu Debug: 74 6 command.c:375 register_command(): command 'stm32f2x' is already registered in '' context Debug: 75 6 command.c:375 register_command(): command 'lock' is already registered in 'stm32f2x' context Debug: 76 6 command.c:375 register_command(): command 'unlock' is already registered in 'stm32f2x' context Debug: 77 6 command.c:375 register_command(): command 'mass_erase' is already registered in 'stm32f2x' context Debug: 78 6 command.c:375 register_command(): command 'options_read' is already registered in 'stm32f2x' context Debug: 79 6 command.c:375 register_command(): command 'options_write' is already registered in 'stm32f2x' context Debug: 80 6 command.c:375 register_command(): command 'optcr2_write' is already registered in 'stm32f2x' context Debug: 81 6 command.c:375 register_command(): command 'otp' is already registered in 'stm32f2x' context Debug: 82 6 tcl.c:1319 handle_flash_bank_command(): 'stm32f2x' driver usage field missing Debug: 83 6 command.c:146 script_debug(): command - adapter speed 2000 Debug: 85 6 core.c:1822 jtag_config_khz(): handle jtag khz Debug: 86 6 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value Debug: 87 6 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value Debug: 88 6 command.c:146 script_debug(): command - adapter srst delay 100 Debug: 90 6 command.c:146 script_debug(): command - transport select Debug: 91 6 command.c:146 script_debug(): command - reset_config srst_nogate Debug: 93 6 command.c:146 script_debug(): command - transport select Debug: 94 6 command.c:146 script_debug(): command - cortex_m reset_config sysresetreq Debug: 96 6 command.c:146 script_debug(): command - stm32f4x.cpu configure -event examine-end

Enable debug during low power modes (uses more power)

DBGMCU_CR |= DBG_STANDBY | DBG_STOP | DBG_SLEEP

mmw 0xE0042004 0x00000007 0

Stop watchdog counters during halt

DBGMCU_APB1_FZ |= DBG_IWDG_STOP | DBG_WWDG_STOP

mmw 0xE0042008 0x00001800 0 Debug: 97 6 command.c:146 script_debug(): command - stm32f4x.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 Debug: 98 6 command.c:146 script_debug(): command - stm32f4x.cpu configure -event reset-init

Configure PLL to boost clock to HSI x 4 (64 MHz)

mww 0x40023804 0x08012008 ;# RCC_PLLCFGR 16 Mhz /8 (M) * 128 (N) /4(P) mww 0x40023C00 0x00000102 ;# FLASH_ACR = PRFTBE | 2(Latency) mmw 0x40023800 0x01000000 0 ;# RCC_CR |= PLLON sleep 10 ;# Wait for PLL to lock mmw 0x40023808 0x00001000 0 ;# RCC_CFGR |= RCC_CFGR_PPRE1_DIV2 mmw 0x40023808 0x00000002 0 ;# RCC_CFGR |= RCC_CFGR_SW_PLL

Boost JTAG frequency

adapter speed 8000 Debug: 99 6 command.c:146 script_debug(): command - stm32f4x.cpu configure -event reset-start

Reduce speed since CPU speed will slow down to 16MHz with the reset

adapter speed 2000 Info : 100 6 server.c:311 add_service(): Listening on port 50001 for tcl connections Info : 101 6 server.c:311 add_service(): Listening on port 50002 for telnet connections Debug: 102 6 command.c:146 script_debug(): command - init Debug: 104 6 command.c:146 script_debug(): command - target init Debug: 106 6 command.c:146 script_debug(): command - target names Debug: 107 6 command.c:146 script_debug(): command - stm32f4x.cpu cget -event gdb-flash-erase-start Debug: 108 6 command.c:146 script_debug(): command - stm32f4x.cpu configure -event gdb-flash-erase-start reset init Debug: 109 6 command.c:146 script_debug(): command - stm32f4x.cpu cget -event gdb-flash-write-end Debug: 110 6 command.c:146 script_debug(): command - stm32f4x.cpu configure -event gdb-flash-write-end reset halt Debug: 111 6 command.c:146 script_debug(): command - stm32f4x.cpu cget -event gdb-attach Debug: 112 6 command.c:146 script_debug(): command - stm32f4x.cpu configure -event gdb-attach halt 1000 Debug: 113 6 target.c:1639 handle_target_init_command(): Initializing targets... Debug: 114 6 semihosting_common.c:99 semihosting_common_init():
Debug: 115 7 cmsis_dap_usb_bulk.c:176 cmsis_dap_usb_open(): enumerating interfaces of 0x1d6b:0x0003 Debug: 116 9 cmsis_dap_usb_bulk.c:156 cmsis_dap_usb_open(): found product string of 0x1209:0xc550 'CMSIS-DAP' Debug: 117 9 cmsis_dap_usb_bulk.c:176 cmsis_dap_usb_open(): enumerating interfaces of 0x1209:0xc550 Debug: 118 9 cmsis_dap_usb_bulk.c:243 cmsis_dap_usb_open(): skipping interface 0, endpoint[0] is not bulk out Debug: 119 9 cmsis_dap_usb_bulk.c:176 cmsis_dap_usb_open(): enumerating interfaces of 0x1d6b:0x0002 Error: 120 10 cmsis_dap_usb_hid.c:139 cmsis_dap_hid_open(): unable to open CMSIS-DAP device 0x1209:0xc550 Error: 121 10 cmsis_dap.c:259 cmsis_dap_open(): unable to find a matching CMSIS-DAP device Debug: 122 10 command.c:628 run_command(): Command 'init' failed with error code -4 User : 123 10 command.c:694 command_run_line(): Debug: 124 10 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas

The issue lies in lines

Debug: 117 9 cmsis_dap_usb_bulk.c:176 cmsis_dap_usb_open(): enumerating interfaces of 0x1209:0xc550 Debug: 118 9 cmsis_dap_usb_bulk.c:243 cmsis_dap_usb_open(): skipping interface 0, endpoint[0] is not bulk out

where it seems like the DAPCat does not support bulk transfers as specified by the cmsis_dap_usb_bulk.c file at https://sourceforge.net/p/openocd/code/ci/master/tree/src/jtag/drivers/cmsis_dap_usb_bulk.c#l256

If applicable, add screenshots or photos to help explain your problem.

My environment I'm running the command under a docker container with Ubuntu 22.04 as the OS I've opened the container through WSL2 version 2.2.4.0 on VSCode version 1.90.2

Possible solution The issue might lie on checking whether the device is configured properly to support bulk transfers.

Eric286 commented 2 weeks ago

Hello @Daniel9719,

Based on the logs, it appears the issue might be with the bulk endpoint not being available. Check the USB descriptors using lsusb -v to see if the bulk endpoints are correctly listed.

lsusb -v -d 1209:c550

Also, ensure that the DAPCat device is properly enumerated by the USB subsystem. You can use dmesg and lsusb to verify that the device is recognized correctly:

dmesg | grep -i usb lsusb

Please send me the output of the lsusb -v command and the message that appears from the dmesg command.

Have a nice day!

Support Team.

Eric286 commented 1 week ago

Hello @Daniel9719,

Due to lack of response we will close this issue now, however, please feel free to reach out to us again in case you have further suggestions, encounter an issue, or you would like to contribute.

Have a nice day!

Support Team.

Daniel9719 commented 6 days ago

Hi Eric,Sorry for not replying but Im in a business trip and don’t have access to my DAPCat right now, Ill take a look into it once I get back home but that will be until next Saturday 20 July.