Author Topic: Does anyone have experience debugging CMSIS-DAP firmware itself?  (Read 13282 times)

0 Members and 1 Guest are viewing this topic.

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
I am not talking about debugging with a CMSIS-DAP, I am talking about debugging the debugger itself.

The project is about putting a full JTAG + SWD debugger into a STM32F042F4 chip. The existing DAP42 project by Devan Lai only supports SWD, not full JTAG, and it is too large for my 16kB chip.

Currently I have the following fails when coupled to OpenOCD:

* The JTAG to SWD dance doesn't work.
* While I can scan the JTAG chain, access to the TAP is not fully working.

Can someone give me some pointers at what I should look at?
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #1 on: May 05, 2021, 04:12:54 am »
I have this https://github.com/ataradov/free-dap . It is SWD-only as well, but it will fit into 16 kB chip easily.

As far as JTAG goes, the whole thing  boils down to one function (dap_jtag_sequence() in my case). So if you have something working at all, it all should be working.

And you can have a look at the  official ARM firmware. Again, you don't need the whole thing, just this function.

What specifically fails in your case?

I did not implement JTAG since I did not have any targets on hand to test it. I don't think I've ever seen  JTAG work over CMSIS-DAP.
Alex
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #2 on: May 05, 2021, 04:18:43 am »
I have this https://github.com/ataradov/free-dap . It is SWD-only as well, but it will fit into 16 kB chip easily.
Thanks to the link and I will look into it.

As far as JTAG goes, the whole thing  boils down to one function (dap_jtag_sequence() in my case). So if you have something working at all, it all should be working.

And you can have a look at the  official ARM firmware. Again, you don't need the whole thing, just this function.
Can I just transplant code from official ARM code to this?

What specifically fails in your case?
I have no idea how to read openocd -d3 output. I will post a console dump later for checking.

I did not implement JTAG since I did not have any targets on hand to test it. I don't think I've ever seen  JTAG work over CMSIS-DAP.
I have a board that paired that CMSIS-DAP to an LPC2103, so JTAG is a must have. Also for my boards I do tend to prefer full JTAG over SWD for it being full duplex can allow for some fast debugging actions.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #3 on: May 05, 2021, 04:31:21 am »
Can I just transplant code from official ARM code to this?
Yes, with obvious corrections for the pin manipulation function names. The function just takes raw payload of the frame sent over USB and expects to produce the response payload. So parsing of that data would be very similar. I have not looked at the official code in great details, but it does something very similar.

I have no idea how to read openocd -d3 output. I will post a console dump later for checking.
I have not used OpenOCD. But it may be a source of errors too, I don't know how much testing JTAG over CMSIS-DAP is tested.

Also for my boards I do tend to prefer full JTAG over SWD for it being full duplex can allow for some fast debugging actions.
With the same clock frequency SWD has higher throughput. It is a well designed interface.

Bidirectional nature of the JTAG does not help, since you are still clocking in dummy cycles to get your data back. There cases where data is sent and received at the same time are extremely rare, and usually it is just a few status bits.
Alex
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #4 on: May 05, 2021, 05:30:01 am »
With the same clock frequency SWD has higher throughput. It is a well designed interface.

Bidirectional nature of the JTAG does not help, since you are still clocking in dummy cycles to get your data back. There cases where data is sent and received at the same time are extremely rare, and usually it is just a few status bits.
There are some other features of JTAG I use:

* JTAG is, in a sense, multi-drop. I can have multiple chips hooked to the same JTAG chain regardless of vendor, for example STM32F103 + XC2C32A. Ever since I start using this cross-vendor multi-drop feature of JTAG, I have standardized my JTAG connector on all designs into the ARM CoreSight Debug 10-pin interface and built adapters that converts all kinds of other pinouts into that.
* I can do boundary scan over JTAG as well, not just debugging. That would be useful for testing, and especially for writing to external memory devices as I would be able to bit bang the memory bus without software support. Even my planned retro projects will have JTAG-enabled bus transceivers so I can use surface-mount Flash ROM.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #5 on: May 05, 2021, 05:40:42 am »
JTAG does have some advantages, for sure. For ARM-only devices SWD in theory has multi-drop as well, but I've never seen it used in practice.

As far as boundary scan and memories go, it depends. If you are using standard tools, then they are would likely to be made for plain JTAG and its boundary scan mode.

But if you are doing custom tools, then SWD lets you do the same thing and even better. You can actually initialize the related peripheral (SPI for example) and just use that to access your memories. Just like you would from the running application. Or even bit bang through the normal port controller.

Bit-banging SPI protocol over extest on a device with a long scan chain is not the fastest enterprise.

I did not realize that at least some STM parts support JTAG for actual system access, not just for boundary scan. I'll see if I can use one of them as a test target and finally implement JTAG too.
Alex
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #6 on: May 05, 2021, 06:17:17 am »
JTAG does have some advantages, for sure. For ARM-only devices SWD in theory has multi-drop as well, but I've never seen it used in practice.
AFAIK even with multiple ARM chips you have to use JTAG mode if you want to chain them in multi-drop. Multi-drop SWD requires chip support, but AFAIK nobody bothered to implement it, at least not on chips with only one core in it.

As far as boundary scan and memories go, it depends. If you are using standard tools, then they are would likely to be made for plain JTAG and its boundary scan mode.

But if you are doing custom tools, then SWD lets you do the same thing and even better. You can actually initialize the related peripheral (SPI for example) and just use that to access your memories. Just like you would from the running application. Or even bit bang through the normal port controller.
Standard tools means I can use this with other chips, not just ARM Cortex ones. Legacy ARM7 and ARM9 never supported SWD. There are FPGAs and CPLDs. Ann there are also JTAG-enabled bus transceivers.

Bit-banging SPI protocol over extest on a device with a long scan chain is not the fastest enterprise.
Sometimes you just have to do it. However usually the most I need to do is write a bootloader like U-Boot, then it is all running over high speed comms like USB and Ethernet.

I did not realize that at least some STM parts support JTAG for actual system access, not just for boundary scan. I'll see if I can use one of them as a test target and finally implement JTAG too.
AFAIK All STM32 except the Cortex-M0(+) parts have full JTAG. STM32L4's JTAG is bugged though as you can not run 4-wire JTAG with nJTRST pin released for GPIO.

I have a ready-made board design for you if you want - a STM32F042F4 and a STM32F103C8 on the same board, with the STM32F042 have access to STM32F103's JTAG, RESET and BOOT0 pins. (It also have Arduino Zero pinout, battery holder for RTC and a built-in USB hub as a clutter reducer.)
« Last Edit: May 05, 2021, 06:21:37 am by technix »
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #7 on: May 05, 2021, 06:22:35 am »
AFAIK All STM32 except the Cortex-M0(+) parts have full JTAG. STM32L4's JTAG is bugged though as you can not run 4-wire JTAG with nJTRST pin released for GPIO.
I found a random STM32F334 Nucleo board that I have around. I'll play with JTAG on it.

I wanted to implement JTAG for quite some time, just could not figure out the test target. Now I have a target.
Alex
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #8 on: May 05, 2021, 06:46:20 am »
I found a random STM32F334 Nucleo board that I have around. I'll play with JTAG on it.
Make sure you erase that chip beforehand, as STM32 do allow applications to release JTAG pins to use them for GPIO.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #9 on: May 05, 2021, 06:49:27 am »
Also saying, for the STM32F042 CMSIS-DAP devices I use as embedded debuggers, they always have a USB CDC in the composite, and that CDC port usually also comes with DTR-controlled reset pulses and 1200 baud activated bootloader entry.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #10 on: May 05, 2021, 07:12:06 am »
Make sure you erase that chip beforehand, as STM32 do allow applications to release JTAG pins to use them for GPIO.
It has the default blinky firmware in it, I doubt it does anything with the JTAG.

I've got this board many years ago when it was first released. I think ST ran some promotion where the board was $10 and shipping was free or something like that. I never needed the board for anything until now, apparently.

But also, how would you erase the device without access to JTAG? There is no dedicated erase pin. Other ST devices let you hold the RESET while establishing the connection and resetting the core internally through DHCSR. This prevents the firmware from running, so it never has a chance to do anything with the debug pins.

Anyway, I'm not too interested in supporting that chip in any of my tools. So I'll implement JTAG in the free-dap, and see if I can make it work with OpenOCD. Or just hack up my tool to have basic support, just enough for testing.

« Last Edit: May 05, 2021, 07:13:59 am by ataradov »
Alex
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #11 on: May 05, 2021, 07:18:18 am »
It has the default blinky firmware in it, I doubt it does anything with the JTAG.
I doubt it either. You can just try though, and if the program did disable JTAG, you will have to erase it, probably over SWD.

But also, how would you erase the device without access to JTAG? There is no dedicated erase pin. Other ST devices let you hold the RESET while establishing the connection and resetting the core internally through DHCSR. This prevents the firmware from running, so it never has a chance to do anything with the debug pins.
SWD. Or you can use the on-chip bootloader.

Anyway, I'm not too interested in supporting that chip in any of my tools. So I'll implement JTAG in the free-dap, and see if I can make it work with OpenOCD. Or just hack up my tool to have basic support, just enough for testing.
What chips do your tool to support? What do you mean by tools too?
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #12 on: May 05, 2021, 07:36:41 am »
SWD pins can be disabled too. But that is not a problem, the reset pin will let you recover from any state.

I'm talking about this tool https://github.com/ataradov/edbg

I generally support only MCUs I use personally. But this one may be a good candidate to support over both SWD and JTAG.
Alex
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #13 on: May 05, 2021, 12:32:59 pm »
Here is my current code making an attempt at a STM32F103 over JTAG:

Code: [Select]
$ openocd -d3 -f interface/cmsis-dap.cfg -c "transport select jtag" -c "adapter_khz 1000" -f target/stm32f1x.cfg
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
[url]http://openocd.org/doc/doxygen/bugs.html[/url]
User : 13 6 options.c:63 configuration_output_handler(): debug_level: 3
User : 14 6 options.c:63 configuration_output_handler():
Debug: 15 6 options.c:244 add_default_dirs(): bindir=/usr/local/Cellar/open-ocd/0.11.0/bin
Debug: 16 6 options.c:245 add_default_dirs(): pkgdatadir=/usr/local/Cellar/open-ocd/0.11.0/share/openocd
Debug: 17 6 options.c:246 add_default_dirs(): exepath=/usr/local/Cellar/open-ocd/0.11.0/bin
Debug: 18 6 options.c:247 add_default_dirs(): bin2data=../share/openocd
Debug: 19 6 configuration.c:42 add_script_search_dir(): adding /Users/user/Library/Preferences/org.openocd
Debug: 20 6 configuration.c:42 add_script_search_dir(): adding /Users/user/.config/openocd
Debug: 21 6 configuration.c:42 add_script_search_dir(): adding /Users/user/.openocd
Debug: 22 6 configuration.c:42 add_script_search_dir(): adding /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/site
Debug: 23 6 configuration.c:42 add_script_search_dir(): adding /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts
Debug: 24 7 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/interface/cmsis-dap.cfg
Debug: 25 7 command.c:146 script_debug(): command - adapter driver cmsis-dap
Debug: 27 8 command.c:146 script_debug(): command - transport select jtag
User : 28 8 options.c:63 configuration_output_handler(): jtagUser : 29 8 options.c:63 configuration_output_handler():
Debug: 30 8 command.c:146 script_debug(): command - echo DEPRECATED! use 'adapter speed' not 'adapter_khz'
User : 32 8 command.c:769 jim_echo(): DEPRECATED! use 'adapter speed' not 'adapter_khz'
Debug: 33 8 command.c:146 script_debug(): command - adapter speed 1000
Debug: 35 8 core.c:1822 jtag_config_khz(): handle jtag khz
Debug: 36 8 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 37 8 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
User : 38 8 options.c:63 configuration_output_handler(): adapter speed: 1000 kHz
User : 39 8 options.c:63 configuration_output_handler():
Debug: 40 9 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/target/stm32f1x.cfg
Debug: 41 10 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/target/swj-dp.tcl
Debug: 42 10 command.c:146 script_debug(): command - transport select
Debug: 43 10 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/mem_helper.tcl
Debug: 44 11 command.c:146 script_debug(): command - add_usage_text mrw address
Debug: 46 11 command.c:1115 help_add_command(): added 'mrw' help text
Debug: 47 11 command.c:146 script_debug(): command - add_help_text mrw Returns value of word in memory.
Debug: 49 11 command.c:1128 help_add_command(): added 'mrw' help text
Debug: 50 11 command.c:146 script_debug(): command - add_usage_text mrh address
Debug: 52 11 command.c:1115 help_add_command(): added 'mrh' help text
Debug: 53 11 command.c:146 script_debug(): command - add_help_text mrh Returns value of halfword in memory.
Debug: 55 11 command.c:1128 help_add_command(): added 'mrh' help text
Debug: 56 11 command.c:146 script_debug(): command - add_usage_text mrb address
Debug: 58 11 command.c:1115 help_add_command(): added 'mrb' help text
Debug: 59 11 command.c:146 script_debug(): command - add_help_text mrb Returns value of byte in memory.
Debug: 61 11 command.c:1128 help_add_command(): added 'mrb' help text
Debug: 62 11 command.c:146 script_debug(): command - add_usage_text mmw address setbits clearbits
Debug: 64 11 command.c:1115 help_add_command(): added 'mmw' help text
Debug: 65 11 command.c:146 script_debug(): command - add_help_text mmw Modify word in memory. new_val = (old_val & ~clearbits) | setbits;
Debug: 67 11 command.c:1128 help_add_command(): added 'mmw' help text
Debug: 68 11 command.c:146 script_debug(): command - transport select
Debug: 69 11 command.c:146 script_debug(): command - transport select
Debug: 70 11 command.c:146 script_debug(): command - transport select
Debug: 71 11 command.c:146 script_debug(): command - jtag newtap stm32f1x cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x3ba00477
Debug: 72 11 tcl.c:572 jim_newtap_cmd(): Creating New Tap, Chip: stm32f1x, Tap: cpu, Dotted: stm32f1x.cpu, 8 params
Debug: 73 11 tcl.c:596 jim_newtap_cmd(): Processing option: -irlen
Debug: 74 11 tcl.c:596 jim_newtap_cmd(): Processing option: -ircapture
Debug: 75 11 tcl.c:596 jim_newtap_cmd(): Processing option: -irmask
Debug: 76 11 tcl.c:596 jim_newtap_cmd(): Processing option: -expected-id
Debug: 77 11 core.c:1488 jtag_tap_init(): Created Tap: stm32f1x.cpu @ abs position 0, irlen 4, capture: 0x1 mask: 0xf
Debug: 78 11 command.c:146 script_debug(): command - dap create stm32f1x.dap -chain-position stm32f1x.cpu
Debug: 79 11 command.c:146 script_debug(): command - transport select
Debug: 80 11 command.c:146 script_debug(): command - jtag newtap stm32f1x bs -irlen 5
Debug: 81 11 tcl.c:572 jim_newtap_cmd(): Creating New Tap, Chip: stm32f1x, Tap: bs, Dotted: stm32f1x.bs, 2 params
Debug: 82 11 tcl.c:596 jim_newtap_cmd(): Processing option: -irlen
Debug: 83 11 core.c:1488 jtag_tap_init(): Created Tap: stm32f1x.bs @ abs position 1, irlen 5, capture: 0x1 mask: 0x3
Debug: 84 11 command.c:146 script_debug(): command - target create stm32f1x.cpu cortex_m -endian little -dap stm32f1x.dap
Debug: 85 12 command.c:376 register_command(): command 'rtt' is already registered in '<global>' context
Debug: 86 12 command.c:146 script_debug(): command - stm32f1x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x1000 -work-area-backup 0
Debug: 87 12 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 88 12 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 89 12 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 90 12 command.c:146 script_debug(): command - flash bank stm32f1x.flash stm32f1x 0x08000000 0 0 0 stm32f1x.cpu
Debug: 92 13 tcl.c:1319 handle_flash_bank_command(): 'stm32f1x' driver usage field missing
Debug: 93 13 command.c:146 script_debug(): command - adapter speed 1000
Debug: 95 13 core.c:1822 jtag_config_khz(): handle jtag khz
Debug: 96 13 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 97 13 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 98 13 command.c:146 script_debug(): command - adapter srst delay 100
Debug: 100 13 command.c:146 script_debug(): command - transport select
Debug: 101 13 command.c:146 script_debug(): command - jtag_ntrst_delay 100
Debug: 103 13 command.c:146 script_debug(): command - reset_config srst_nogate
Debug: 105 13 command.c:146 script_debug(): command - transport select
Debug: 106 13 command.c:146 script_debug(): command - cortex_m reset_config sysresetreq
Debug: 108 13 command.c:146 script_debug(): command - stm32f1x.cpu configure -event examine-end
# DBGMCU_CR |= DBG_WWDG_STOP | DBG_IWDG_STOP |
#              DBG_STANDBY | DBG_STOP | DBG_SLEEP
mmw 0xE0042004 0x00000307 0

Debug: 109 13 command.c:146 script_debug(): command - stm32f1x.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

Info : 110 13 server.c:312 add_service(): Listening on port 6666 for tcl connections
Info : 111 13 server.c:312 add_service(): Listening on port 4444 for telnet connections
Debug: 112 13 command.c:146 script_debug(): command - init
Debug: 114 13 command.c:146 script_debug(): command - target init
Debug: 116 13 command.c:146 script_debug(): command - target names
Debug: 117 13 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-flash-erase-start
Debug: 118 13 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-flash-erase-start reset init
Debug: 119 13 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-flash-write-end
Debug: 120 14 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-flash-write-end reset halt
Debug: 121 14 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-attach
Debug: 122 14 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-attach halt 1000
Debug: 123 14 target.c:1639 handle_target_init_command(): Initializing targets...
Debug: 124 14 semihosting_common.c:99 semihosting_common_init():
Debug: 125 2492 cmsis_dap_usb_bulk.c:157 cmsis_dap_usb_open(): found product string of 0x0002:0xda42 'SushiBits One with CMSIS-DAP'
Debug: 126 2492 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0xda42
Debug: 127 2492 cmsis_dap_usb_bulk.c:237 cmsis_dap_usb_open(): skipping interface 0, has only 1 endpoints
Debug: 128 2492 cmsis_dap_usb_bulk.c:285 cmsis_dap_usb_open(): skipping interface 1, class 10 subclass 0 protocol 0
Debug: 129 2492 cmsis_dap_usb_bulk.c:224 cmsis_dap_usb_open(): found interface 2 string 'SushiBits One Embedded CMSIS-DAP'
Debug: 130 2492 cmsis_dap_usb_bulk.c:244 cmsis_dap_usb_open(): skipping interface 2, endpoint[0] is not bulk out
Debug: 131 2658 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a40:0x0101
Debug: 132 2660 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0x2812
Debug: 133 2660 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x03eb:0x2104
Debug: 134 2660 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x046d:0xc52b
Debug: 135 2661 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x03f0:0x052a
Debug: 136 2662 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x04d8:0x9012
Debug: 137 2662 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1366:0x0101
Debug: 138 2836 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0xf003
Debug: 139 3007 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0451:0x8140
Debug: 140 3186 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1050:0x0407
Debug: 141 3366 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x2109:0x2812
Debug: 142 3547 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x2109:0x2812
Debug: 143 3547 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x046d:0x085c
Debug: 144 3719 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0451:0x8142
Debug: 145 3720 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a86:0x752d
Debug: 146 3886 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a40:0x0101
Info : 147 3896 cmsis_dap.c:788 cmsis_dap_get_caps_info(): CMSIS-DAP: SWD  Supported
Info : 148 3896 cmsis_dap.c:790 cmsis_dap_get_caps_info(): CMSIS-DAP: JTAG Supported
Info : 149 3898 cmsis_dap.c:768 cmsis_dap_get_version_info(): CMSIS-DAP: FW Version = 1.0
Info : 150 3902 cmsis_dap.c:921 cmsis_dap_init(): CMSIS-DAP: Interface Initialised (JTAG)
Debug: 151 3903 cmsis_dap.c:953 cmsis_dap_init(): CMSIS-DAP: Packet Size = 64
Debug: 152 3905 cmsis_dap.c:966 cmsis_dap_init(): CMSIS-DAP: Packet Count = 8
Debug: 153 3905 cmsis_dap.c:969 cmsis_dap_init(): Allocating FIFO for 3 pending packets
Info : 154 3907 cmsis_dap.c:809 cmsis_dap_get_status(): SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 1 nRESET = 1
Info : 155 3915 cmsis_dap.c:1023 cmsis_dap_init(): CMSIS-DAP: Interface ready
Debug: 156 3915 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 157 3915 core.c:1789 adapter_khz_to_speed(): have interface set up
Debug: 158 3917 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 159 3917 core.c:1789 adapter_khz_to_speed(): have interface set up
Info : 160 3917 core.c:1565 adapter_init(): clock speed 1000 kHz
Debug: 161 3917 openocd.c:143 handle_init_command(): Debug Adapter init complete
Debug: 162 3917 command.c:146 script_debug(): command - transport init
Debug: 163 3917 log.c:428 gdb_timeout_warning(): keep_alive() was not invoked in the 1000 ms timelimit (3917 ms). This may cause trouble with GDB connections.
Debug: 166 3917 transport.c:229 handle_transport_init(): handle_transport_init
Debug: 167 3919 core.c:830 jtag_add_reset(): SRST line released
Debug: 168 3919 core.c:855 jtag_add_reset(): TRST line released
Debug: 169 3919 core.c:327 jtag_call_event_callbacks(): jtag event: TAP reset
Debug: 170 4137 command.c:146 script_debug(): command - jtag arp_init
Debug: 171 4137 core.c:1578 jtag_init_inner(): Init JTAG chain
Debug: 172 4137 core.c:327 jtag_call_event_callbacks(): jtag event: TAP reset
Info : 173 4137 cmsis_dap.c:1076 cmsis_dap_execute_tlr_reset(): cmsis-dap JTAG TLR_RESET
Debug: 174 4171 core.c:1243 jtag_examine_chain(): DR scan interrogation for IDCODE/BYPASS
Debug: 175 4171 core.c:327 jtag_call_event_callbacks(): jtag event: TAP reset
Info : 176 4178 cmsis_dap.c:1076 cmsis_dap_execute_tlr_reset(): cmsis-dap JTAG TLR_RESET
Info : 177 4181 core.c:1142 jtag_examine_chain_display(): JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x3)
Info : 178 4181 core.c:1142 jtag_examine_chain_display(): JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020 (STMicroelectronics), part: 0x6410, ver: 0x1)
Debug: 179 4181 core.c:1374 jtag_validate_ircapture(): IR capture validation scan
Debug: 180 4184 core.c:1432 jtag_validate_ircapture(): stm32f1x.cpu: IR capture 0x01
Debug: 181 4184 core.c:1432 jtag_validate_ircapture(): stm32f1x.bs: IR capture 0x01
Debug: 182 4184 command.c:146 script_debug(): command - dap init
Debug: 184 4184 arm_dap.c:106 dap_init_all(): Initializing all DAPs ...
Debug: 185 4184 arm_adi_v5.c:653 dap_dp_init(): stm32f1x.dap
Debug: 186 4184 arm_adi_v5.c:685 dap_dp_init(): DAP: wait CDBGPWRUPACK
Debug: 187 4184 arm_adi_v5.h:507 dap_dp_poll_register(): DAP: poll 4, mask 0x20000000, value 0x20000000
Error: 188 4194 adi_v5_jtag.c:425 jtagdp_overrun_check(): Invalid ACK (4) in DAP response
Debug: 189 4196 command.c:629 run_command(): Command 'dap init' failed with error code -107
User : 190 4196 command.c:694 command_run_line():
Debug: 191 4196 command.c:629 run_command(): Command 'init' failed with error code -4
User : 192 4196 command.c:694 command_run_line():
Debug: 193 4197 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #14 on: May 05, 2021, 12:36:29 pm »
This is STM32F103 over SWD:

Code: [Select]
$ openocd -d3 -f interface/cmsis-dap.cfg -c "transport select swd" -c "adapter speed 1000" -f target/stm32f1x.cfg
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
[url]http://openocd.org/doc/doxygen/bugs.html[/url]
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/local/Cellar/open-ocd/0.11.0/bin
Debug: 16 1 options.c:245 add_default_dirs(): pkgdatadir=/usr/local/Cellar/open-ocd/0.11.0/share/openocd
Debug: 17 1 options.c:246 add_default_dirs(): exepath=/usr/local/Cellar/open-ocd/0.11.0/bin
Debug: 18 1 options.c:247 add_default_dirs(): bin2data=../share/openocd
Debug: 19 1 configuration.c:42 add_script_search_dir(): adding /Users/user/Library/Preferences/org.openocd
Debug: 20 1 configuration.c:42 add_script_search_dir(): adding /Users/user/.config/openocd
Debug: 21 1 configuration.c:42 add_script_search_dir(): adding /Users/user/.openocd
Debug: 22 1 configuration.c:42 add_script_search_dir(): adding /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/site
Debug: 23 1 configuration.c:42 add_script_search_dir(): adding /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts
Debug: 24 1 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/interface/cmsis-dap.cfg
Debug: 25 1 command.c:146 script_debug(): command - adapter driver cmsis-dap
Debug: 27 1 command.c:146 script_debug(): command - transport select swd
User : 28 1 options.c:63 configuration_output_handler(): swdUser : 29 1 options.c:63 configuration_output_handler():
Debug: 30 1 command.c:146 script_debug(): command - adapter speed 1000
Debug: 32 1 core.c:1822 jtag_config_khz(): handle jtag khz
Debug: 33 1 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 34 1 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
User : 35 1 options.c:63 configuration_output_handler(): adapter speed: 1000 kHz
User : 36 1 options.c:63 configuration_output_handler():
Debug: 37 1 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/target/stm32f1x.cfg
Debug: 38 1 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/target/swj-dp.tcl
Debug: 39 1 command.c:146 script_debug(): command - transport select
Debug: 40 1 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/mem_helper.tcl
Debug: 41 1 command.c:146 script_debug(): command - add_usage_text mrw address
Debug: 43 1 command.c:1115 help_add_command(): added 'mrw' help text
Debug: 44 1 command.c:146 script_debug(): command - add_help_text mrw Returns value of word in memory.
Debug: 46 1 command.c:1128 help_add_command(): added 'mrw' help text
Debug: 47 1 command.c:146 script_debug(): command - add_usage_text mrh address
Debug: 49 1 command.c:1115 help_add_command(): added 'mrh' help text
Debug: 50 1 command.c:146 script_debug(): command - add_help_text mrh Returns value of halfword in memory.
Debug: 52 1 command.c:1128 help_add_command(): added 'mrh' help text
Debug: 53 1 command.c:146 script_debug(): command - add_usage_text mrb address
Debug: 55 1 command.c:1115 help_add_command(): added 'mrb' help text
Debug: 56 1 command.c:146 script_debug(): command - add_help_text mrb Returns value of byte in memory.
Debug: 58 1 command.c:1128 help_add_command(): added 'mrb' help text
Debug: 59 1 command.c:146 script_debug(): command - add_usage_text mmw address setbits clearbits
Debug: 61 1 command.c:1115 help_add_command(): added 'mmw' help text
Debug: 62 1 command.c:146 script_debug(): command - add_help_text mmw Modify word in memory. new_val = (old_val & ~clearbits) | setbits;
Debug: 64 1 command.c:1128 help_add_command(): added 'mmw' help text
Debug: 65 2 command.c:146 script_debug(): command - transport select
Debug: 66 2 command.c:146 script_debug(): command - transport select
Debug: 67 2 command.c:146 script_debug(): command - transport select
Debug: 68 2 command.c:146 script_debug(): command - swd newdap stm32f1x cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x1ba01477
Debug: 69 2 tcl.c:572 jim_newtap_cmd(): Creating New Tap, Chip: stm32f1x, Tap: cpu, Dotted: stm32f1x.cpu, 8 params
Debug: 70 2 core.c:1488 jtag_tap_init(): Created Tap: stm32f1x.cpu @ abs position 0, irlen 0, capture: 0x0 mask: 0x0
Debug: 71 2 command.c:146 script_debug(): command - dap create stm32f1x.dap -chain-position stm32f1x.cpu
Debug: 72 2 command.c:146 script_debug(): command - transport select
Debug: 73 2 command.c:146 script_debug(): command - target create stm32f1x.cpu cortex_m -endian little -dap stm32f1x.dap
Debug: 74 2 command.c:376 register_command(): command 'rtt' is already registered in '<global>' context
Debug: 75 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x1000 -work-area-backup 0
Debug: 76 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 77 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 78 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 79 2 command.c:146 script_debug(): command - flash bank stm32f1x.flash stm32f1x 0x08000000 0 0 0 stm32f1x.cpu
Debug: 81 2 tcl.c:1319 handle_flash_bank_command(): 'stm32f1x' driver usage field missing
Debug: 82 2 command.c:146 script_debug(): command - adapter speed 1000
Debug: 84 2 core.c:1822 jtag_config_khz(): handle jtag khz
Debug: 85 2 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 86 2 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 87 2 command.c:146 script_debug(): command - adapter srst delay 100
Debug: 89 2 command.c:146 script_debug(): command - transport select
Debug: 90 2 command.c:146 script_debug(): command - reset_config srst_nogate
Debug: 92 2 command.c:146 script_debug(): command - transport select
Debug: 93 2 command.c:146 script_debug(): command - cortex_m reset_config sysresetreq
Debug: 95 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -event examine-end
# DBGMCU_CR |= DBG_WWDG_STOP | DBG_IWDG_STOP |
#              DBG_STANDBY | DBG_STOP | DBG_SLEEP
mmw 0xE0042004 0x00000307 0

Debug: 96 2 command.c:146 script_debug(): command - stm32f1x.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

Info : 97 2 server.c:312 add_service(): Listening on port 6666 for tcl connections
Info : 98 2 server.c:312 add_service(): Listening on port 4444 for telnet connections
Debug: 99 2 command.c:146 script_debug(): command - init
Debug: 101 2 command.c:146 script_debug(): command - target init
Debug: 103 2 command.c:146 script_debug(): command - target names
Debug: 104 2 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-flash-erase-start
Debug: 105 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-flash-erase-start reset init
Debug: 106 2 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-flash-write-end
Debug: 107 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-flash-write-end reset halt
Debug: 108 2 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-attach
Debug: 109 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-attach halt 1000
Debug: 110 2 target.c:1639 handle_target_init_command(): Initializing targets...
Debug: 111 2 semihosting_common.c:99 semihosting_common_init():
Debug: 112 2478 cmsis_dap_usb_bulk.c:157 cmsis_dap_usb_open(): found product string of 0x0002:0xda42 'SushiBits One with CMSIS-DAP'
Debug: 113 2478 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0xda42
Debug: 114 2478 cmsis_dap_usb_bulk.c:237 cmsis_dap_usb_open(): skipping interface 0, has only 1 endpoints
Debug: 115 2478 cmsis_dap_usb_bulk.c:285 cmsis_dap_usb_open(): skipping interface 1, class 10 subclass 0 protocol 0
Debug: 116 2479 cmsis_dap_usb_bulk.c:224 cmsis_dap_usb_open(): found interface 2 string 'SushiBits One Embedded CMSIS-DAP'
Debug: 117 2479 cmsis_dap_usb_bulk.c:244 cmsis_dap_usb_open(): skipping interface 2, endpoint[0] is not bulk out
Debug: 118 2644 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a40:0x0101
Debug: 119 2646 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0x2812
Debug: 120 2647 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x03eb:0x2104
Debug: 121 2647 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x046d:0xc52b
Debug: 122 2647 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x03f0:0x052a
Debug: 123 2648 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x04d8:0x9012
Debug: 124 2649 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1366:0x0101
Debug: 125 2822 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0xf003
Debug: 126 2993 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0451:0x8140
Debug: 127 3172 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1050:0x0407
Debug: 128 3352 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x2109:0x2812
Debug: 129 3533 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x2109:0x2812
Debug: 130 3534 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x046d:0x085c
Debug: 131 3706 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0451:0x8142
Debug: 132 3706 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a86:0x752d
Debug: 133 3872 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a40:0x0101
Info : 134 3881 cmsis_dap.c:788 cmsis_dap_get_caps_info(): CMSIS-DAP: SWD  Supported
Info : 135 3881 cmsis_dap.c:790 cmsis_dap_get_caps_info(): CMSIS-DAP: JTAG Supported
Info : 136 3882 cmsis_dap.c:768 cmsis_dap_get_version_info(): CMSIS-DAP: FW Version = 1.0
Info : 137 3886 cmsis_dap.c:881 cmsis_dap_swd_open(): CMSIS-DAP: Interface Initialised (SWD)
Debug: 138 3888 cmsis_dap.c:953 cmsis_dap_init(): CMSIS-DAP: Packet Size = 64
Debug: 139 3890 cmsis_dap.c:966 cmsis_dap_init(): CMSIS-DAP: Packet Count = 8
Debug: 140 3890 cmsis_dap.c:969 cmsis_dap_init(): Allocating FIFO for 3 pending packets
Info : 141 3892 cmsis_dap.c:809 cmsis_dap_get_status(): SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 1 nRESET = 1
Info : 142 3902 cmsis_dap.c:1023 cmsis_dap_init(): CMSIS-DAP: Interface ready
Debug: 143 3902 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 144 3902 core.c:1789 adapter_khz_to_speed(): have interface set up
Debug: 145 3904 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 146 3904 core.c:1789 adapter_khz_to_speed(): have interface set up
Info : 147 3904 core.c:1565 adapter_init(): clock speed 1000 kHz
Debug: 148 3904 openocd.c:143 handle_init_command(): Debug Adapter init complete
Debug: 149 3904 command.c:146 script_debug(): command - transport init
Debug: 150 3904 log.c:428 gdb_timeout_warning(): keep_alive() was not invoked in the 1000 ms timelimit (3904 ms). This may cause trouble with GDB connections.
Debug: 153 3904 transport.c:229 handle_transport_init(): handle_transport_init
Debug: 154 3904 command.c:146 script_debug(): command - dap init
Debug: 156 3904 arm_dap.c:106 dap_init_all(): Initializing all DAPs ...
Debug: 157 3908 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 158 3916 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 159 3922 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 160 3931 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 161 3937 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 162 3944 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 163 3950 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 164 3958 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 165 3963 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 166 3971 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 167 3976 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 168 3985 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 169 3991 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 170 3999 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 171 4004 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 172 4012 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 173 4019 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 174 4027 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 175 4034 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 176 4045 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 177 4052 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 178 4063 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 179 4069 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 180 4079 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 181 4084 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 182 4095 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 183 4103 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 184 4113 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 185 4120 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 186 4131 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 187 4138 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 188 4149 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 189 4155 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 190 4165 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 191 4171 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 192 4182 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 193 4188 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 194 4199 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 195 4205 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 196 4216 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 197 4223 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 198 4233 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 199 4239 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 200 4249 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 201 4255 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 202 4265 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 203 4272 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 204 4283 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 205 4290 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 206 4301 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 207 4307 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 208 4318 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 209 4325 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 210 4335 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 211 4342 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 212 4353 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 213 4360 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 214 4372 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 215 4378 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 216 4389 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 217 4395 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 218 4405 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Error: 220 4407 adi_v5_swd.c:144 swd_connect(): Error connecting DP: cannot read IDR
Debug: 221 4407 command.c:629 run_command(): Command 'dap init' failed with error code -4
User : 222 4407 command.c:694 command_run_line():
Debug: 223 4407 command.c:629 run_command(): Command 'init' failed with error code -4
User : 224 4407 command.c:694 command_run_line():
Debug: 225 4407 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 226 4412 cmsis_dap.c:848 cmsis_dap_swd_switch_seq(): SWD-to-JTAG

This dumped from macOS Big Sur amd64 running the version of OpenOCD that comes from Homebrew.
« Last Edit: May 05, 2021, 12:40:08 pm by technix »
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14434
  • Country: fr
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #15 on: May 05, 2021, 04:03:27 pm »
Sorry for chiming in with a related question... but does anybody know of any off-the-shelf probe implementing CMSIS-DAP v2 (USB HS)? The DAP v1 probes are everywhere, but I can't seem to find any decent v2 one. (I have just found ONE on Aliexpress but with questionable quality IMO and a USB male connector, I literally HATE that.)

Or, any off-the-shelf board that can be successfully programmed with a working DAP v2 firmware would also do.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #16 on: May 05, 2021, 04:09:43 pm »
V1 can work over USB HS too.
V2 adds ability to use bulk endpoints, therefore increasing throughput on USB FS considerably. It will not be any better than V1 on USB HS. At that point you start to be limited by the SWD interface mostly.

It is easy to adapt existing firmware to V2. The reason for slow adoption is that V2 starts to need drivers on Windows, which sucks.

And, no I'm not aware of any off the shelf hardware that supports V2. Again, for me the speed issue is mostly solved by using V1 with USB HS hardware.
Alex
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #17 on: May 05, 2021, 04:21:04 pm »
V1 can work over USB HS too.
V2 adds ability to use bulk endpoints, therefore increasing throughput on USB FS considerably. It will not be any better than V1 on USB HS. At that point you start to be limited by the SWD interface mostly.

It is easy to adapt existing firmware to V2. The reason for slow adoption is that V2 starts to need drivers on Windows, which sucks.

And, no I'm not aware of any off the shelf hardware that supports V2. Again, for me the speed issue is mostly solved by using V1 with USB HS hardware.
I happen to also have a board with STM32F446 and a USB HS ULPI PHY...
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #18 on: May 05, 2021, 04:29:15 pm »
For a "real" debugger, you definitely want to use USB HS. USB FS + HIDs limits you to 64 KBytes/second. This is ok for basic stuff, but if you really want to get the fast debugging, you need to run it over USB HS.

There are also a lot of optimizations in the protocol that are rarely taken advantage of by generic tools supporting multiple debugger types. They usually abstract things into simple commands, which are executed one by one. But there is not much you can do about that.
Alex
 

Offline thinkfat

  • Supporter
  • ****
  • Posts: 2150
  • Country: de
  • This is just a hobby I spend too much time on.
    • Matthias' Hackerstübchen
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #19 on: May 05, 2021, 06:04:16 pm »
This is STM32F103 over SWD:

Code: [Select]
$ openocd -d3 -f interface/cmsis-dap.cfg -c "transport select swd" -c "adapter speed 1000" -f target/stm32f1x.cfg
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
[url]http://openocd.org/doc/doxygen/bugs.html[/url]
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/local/Cellar/open-ocd/0.11.0/bin
Debug: 16 1 options.c:245 add_default_dirs(): pkgdatadir=/usr/local/Cellar/open-ocd/0.11.0/share/openocd
Debug: 17 1 options.c:246 add_default_dirs(): exepath=/usr/local/Cellar/open-ocd/0.11.0/bin
Debug: 18 1 options.c:247 add_default_dirs(): bin2data=../share/openocd
Debug: 19 1 configuration.c:42 add_script_search_dir(): adding /Users/user/Library/Preferences/org.openocd
Debug: 20 1 configuration.c:42 add_script_search_dir(): adding /Users/user/.config/openocd
Debug: 21 1 configuration.c:42 add_script_search_dir(): adding /Users/user/.openocd
Debug: 22 1 configuration.c:42 add_script_search_dir(): adding /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/site
Debug: 23 1 configuration.c:42 add_script_search_dir(): adding /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts
Debug: 24 1 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/interface/cmsis-dap.cfg
Debug: 25 1 command.c:146 script_debug(): command - adapter driver cmsis-dap
Debug: 27 1 command.c:146 script_debug(): command - transport select swd
User : 28 1 options.c:63 configuration_output_handler(): swdUser : 29 1 options.c:63 configuration_output_handler():
Debug: 30 1 command.c:146 script_debug(): command - adapter speed 1000
Debug: 32 1 core.c:1822 jtag_config_khz(): handle jtag khz
Debug: 33 1 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 34 1 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
User : 35 1 options.c:63 configuration_output_handler(): adapter speed: 1000 kHz
User : 36 1 options.c:63 configuration_output_handler():
Debug: 37 1 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/target/stm32f1x.cfg
Debug: 38 1 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/target/swj-dp.tcl
Debug: 39 1 command.c:146 script_debug(): command - transport select
Debug: 40 1 configuration.c:97 find_file(): found /usr/local/Cellar/open-ocd/0.11.0/bin/../share/openocd/scripts/mem_helper.tcl
Debug: 41 1 command.c:146 script_debug(): command - add_usage_text mrw address
Debug: 43 1 command.c:1115 help_add_command(): added 'mrw' help text
Debug: 44 1 command.c:146 script_debug(): command - add_help_text mrw Returns value of word in memory.
Debug: 46 1 command.c:1128 help_add_command(): added 'mrw' help text
Debug: 47 1 command.c:146 script_debug(): command - add_usage_text mrh address
Debug: 49 1 command.c:1115 help_add_command(): added 'mrh' help text
Debug: 50 1 command.c:146 script_debug(): command - add_help_text mrh Returns value of halfword in memory.
Debug: 52 1 command.c:1128 help_add_command(): added 'mrh' help text
Debug: 53 1 command.c:146 script_debug(): command - add_usage_text mrb address
Debug: 55 1 command.c:1115 help_add_command(): added 'mrb' help text
Debug: 56 1 command.c:146 script_debug(): command - add_help_text mrb Returns value of byte in memory.
Debug: 58 1 command.c:1128 help_add_command(): added 'mrb' help text
Debug: 59 1 command.c:146 script_debug(): command - add_usage_text mmw address setbits clearbits
Debug: 61 1 command.c:1115 help_add_command(): added 'mmw' help text
Debug: 62 1 command.c:146 script_debug(): command - add_help_text mmw Modify word in memory. new_val = (old_val & ~clearbits) | setbits;
Debug: 64 1 command.c:1128 help_add_command(): added 'mmw' help text
Debug: 65 2 command.c:146 script_debug(): command - transport select
Debug: 66 2 command.c:146 script_debug(): command - transport select
Debug: 67 2 command.c:146 script_debug(): command - transport select
Debug: 68 2 command.c:146 script_debug(): command - swd newdap stm32f1x cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x1ba01477
Debug: 69 2 tcl.c:572 jim_newtap_cmd(): Creating New Tap, Chip: stm32f1x, Tap: cpu, Dotted: stm32f1x.cpu, 8 params
Debug: 70 2 core.c:1488 jtag_tap_init(): Created Tap: stm32f1x.cpu @ abs position 0, irlen 0, capture: 0x0 mask: 0x0
Debug: 71 2 command.c:146 script_debug(): command - dap create stm32f1x.dap -chain-position stm32f1x.cpu
Debug: 72 2 command.c:146 script_debug(): command - transport select
Debug: 73 2 command.c:146 script_debug(): command - target create stm32f1x.cpu cortex_m -endian little -dap stm32f1x.dap
Debug: 74 2 command.c:376 register_command(): command 'rtt' is already registered in '<global>' context
Debug: 75 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x1000 -work-area-backup 0
Debug: 76 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 77 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 78 2 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 79 2 command.c:146 script_debug(): command - flash bank stm32f1x.flash stm32f1x 0x08000000 0 0 0 stm32f1x.cpu
Debug: 81 2 tcl.c:1319 handle_flash_bank_command(): 'stm32f1x' driver usage field missing
Debug: 82 2 command.c:146 script_debug(): command - adapter speed 1000
Debug: 84 2 core.c:1822 jtag_config_khz(): handle jtag khz
Debug: 85 2 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 86 2 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 87 2 command.c:146 script_debug(): command - adapter srst delay 100
Debug: 89 2 command.c:146 script_debug(): command - transport select
Debug: 90 2 command.c:146 script_debug(): command - reset_config srst_nogate
Debug: 92 2 command.c:146 script_debug(): command - transport select
Debug: 93 2 command.c:146 script_debug(): command - cortex_m reset_config sysresetreq
Debug: 95 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -event examine-end
# DBGMCU_CR |= DBG_WWDG_STOP | DBG_IWDG_STOP |
#              DBG_STANDBY | DBG_STOP | DBG_SLEEP
mmw 0xE0042004 0x00000307 0

Debug: 96 2 command.c:146 script_debug(): command - stm32f1x.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

Info : 97 2 server.c:312 add_service(): Listening on port 6666 for tcl connections
Info : 98 2 server.c:312 add_service(): Listening on port 4444 for telnet connections
Debug: 99 2 command.c:146 script_debug(): command - init
Debug: 101 2 command.c:146 script_debug(): command - target init
Debug: 103 2 command.c:146 script_debug(): command - target names
Debug: 104 2 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-flash-erase-start
Debug: 105 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-flash-erase-start reset init
Debug: 106 2 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-flash-write-end
Debug: 107 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-flash-write-end reset halt
Debug: 108 2 command.c:146 script_debug(): command - stm32f1x.cpu cget -event gdb-attach
Debug: 109 2 command.c:146 script_debug(): command - stm32f1x.cpu configure -event gdb-attach halt 1000
Debug: 110 2 target.c:1639 handle_target_init_command(): Initializing targets...
Debug: 111 2 semihosting_common.c:99 semihosting_common_init():
Debug: 112 2478 cmsis_dap_usb_bulk.c:157 cmsis_dap_usb_open(): found product string of 0x0002:0xda42 'SushiBits One with CMSIS-DAP'
Debug: 113 2478 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0xda42
Debug: 114 2478 cmsis_dap_usb_bulk.c:237 cmsis_dap_usb_open(): skipping interface 0, has only 1 endpoints
Debug: 115 2478 cmsis_dap_usb_bulk.c:285 cmsis_dap_usb_open(): skipping interface 1, class 10 subclass 0 protocol 0
Debug: 116 2479 cmsis_dap_usb_bulk.c:224 cmsis_dap_usb_open(): found interface 2 string 'SushiBits One Embedded CMSIS-DAP'
Debug: 117 2479 cmsis_dap_usb_bulk.c:244 cmsis_dap_usb_open(): skipping interface 2, endpoint[0] is not bulk out
Debug: 118 2644 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a40:0x0101
Debug: 119 2646 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0x2812
Debug: 120 2647 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x03eb:0x2104
Debug: 121 2647 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x046d:0xc52b
Debug: 122 2647 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x03f0:0x052a
Debug: 123 2648 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x04d8:0x9012
Debug: 124 2649 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1366:0x0101
Debug: 125 2822 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0002:0xf003
Debug: 126 2993 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0451:0x8140
Debug: 127 3172 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1050:0x0407
Debug: 128 3352 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x2109:0x2812
Debug: 129 3533 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x2109:0x2812
Debug: 130 3534 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x046d:0x085c
Debug: 131 3706 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x0451:0x8142
Debug: 132 3706 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a86:0x752d
Debug: 133 3872 cmsis_dap_usb_bulk.c:177 cmsis_dap_usb_open(): enumerating interfaces of 0x1a40:0x0101
Info : 134 3881 cmsis_dap.c:788 cmsis_dap_get_caps_info(): CMSIS-DAP: SWD  Supported
Info : 135 3881 cmsis_dap.c:790 cmsis_dap_get_caps_info(): CMSIS-DAP: JTAG Supported
Info : 136 3882 cmsis_dap.c:768 cmsis_dap_get_version_info(): CMSIS-DAP: FW Version = 1.0
Info : 137 3886 cmsis_dap.c:881 cmsis_dap_swd_open(): CMSIS-DAP: Interface Initialised (SWD)
Debug: 138 3888 cmsis_dap.c:953 cmsis_dap_init(): CMSIS-DAP: Packet Size = 64
Debug: 139 3890 cmsis_dap.c:966 cmsis_dap_init(): CMSIS-DAP: Packet Count = 8
Debug: 140 3890 cmsis_dap.c:969 cmsis_dap_init(): Allocating FIFO for 3 pending packets
Info : 141 3892 cmsis_dap.c:809 cmsis_dap_get_status(): SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 1 nRESET = 1
Info : 142 3902 cmsis_dap.c:1023 cmsis_dap_init(): CMSIS-DAP: Interface ready
Debug: 143 3902 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 144 3902 core.c:1789 adapter_khz_to_speed(): have interface set up
Debug: 145 3904 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 146 3904 core.c:1789 adapter_khz_to_speed(): have interface set up
Info : 147 3904 core.c:1565 adapter_init(): clock speed 1000 kHz
Debug: 148 3904 openocd.c:143 handle_init_command(): Debug Adapter init complete
Debug: 149 3904 command.c:146 script_debug(): command - transport init
Debug: 150 3904 log.c:428 gdb_timeout_warning(): keep_alive() was not invoked in the 1000 ms timelimit (3904 ms). This may cause trouble with GDB connections.
Debug: 153 3904 transport.c:229 handle_transport_init(): handle_transport_init
Debug: 154 3904 command.c:146 script_debug(): command - dap init
Debug: 156 3904 arm_dap.c:106 dap_init_all(): Initializing all DAPs ...
Debug: 157 3908 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 158 3916 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 159 3922 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 160 3931 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 161 3937 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 162 3944 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 163 3950 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 164 3958 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 165 3963 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 166 3971 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 167 3976 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 168 3985 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 169 3991 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 170 3999 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 171 4004 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 172 4012 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 173 4019 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 174 4027 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 175 4034 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 176 4045 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 177 4052 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 178 4063 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 179 4069 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 180 4079 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 181 4084 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 182 4095 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 183 4103 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 184 4113 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 185 4120 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 186 4131 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 187 4138 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 188 4149 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 189 4155 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 190 4165 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 191 4171 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 192 4182 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 193 4188 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 194 4199 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 195 4205 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 196 4216 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 197 4223 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 198 4233 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 199 4239 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 200 4249 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 201 4255 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 202 4265 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 203 4272 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 204 4283 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 205 4290 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 206 4301 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 207 4307 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 208 4318 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 209 4325 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 210 4335 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 211 4342 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 212 4353 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 213 4360 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 214 4372 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 215 4378 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 216 4389 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Debug: 217 4395 cmsis_dap.c:843 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Debug: 218 4405 cmsis_dap.c:647 cmsis_dap_swd_read_process(): SWD ack not OK @ 0 JUNK
Error: 220 4407 adi_v5_swd.c:144 swd_connect(): Error connecting DP: cannot read IDR
Debug: 221 4407 command.c:629 run_command(): Command 'dap init' failed with error code -4
User : 222 4407 command.c:694 command_run_line():
Debug: 223 4407 command.c:629 run_command(): Command 'init' failed with error code -4
User : 224 4407 command.c:694 command_run_line():
Debug: 225 4407 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 226 4412 cmsis_dap.c:848 cmsis_dap_swd_switch_seq(): SWD-to-JTAG

This dumped from macOS Big Sur amd64 running the version of OpenOCD that comes from Homebrew.

I guess your best option is to show up on #openocd on irc.freenode.net, or write an email to openocd-devel@lists.sourceforge.net.
Everybody likes gadgets. Until they try to make them.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #20 on: May 05, 2021, 11:03:29 pm »
I had a look at how JTAG is implemented in the CMSIS-DAP. I doubt how useful it would be outside of ARM stuff. It uses ARM specific registers for transfers, which obviously would not be present on other targets.

There are commands to just bit bang JTAG pins, but I'm not sure how well (if at all) software supports that in practice.

So far, I would assume that CMSIS-DAP is practically useful only for ARM targets.

I'll still look though it to see if it makes sense for me to even support it. I feel like it would be just poorly tested dead code.

I also rigged up a quick test, and I can access JTAG on the STM32 I have. Now it is a matter of implementing the actual commands in the debugger.
Alex
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14434
  • Country: fr
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #21 on: May 05, 2021, 11:11:07 pm »
So far, I would assume that CMSIS-DAP is practically useful only for ARM targets.

Well, as far as I know, openocd supports CMSIS-DAP as a JTAG interface and this can be used with any target that is supportd by OpenOCD. I don't know how efficient it is for targets other than ARM, but it seems much faster than if it were just bit-banged.

Similarly, I'm actually using a CMSIS-DAP adapter on some Lattice ECP5 dev board, and someone wrote an pretty handy utility for using CMSIS-DAP probes with ECP5 FPGAs: https://github.com/adamgreig/ecpdap
It works quite well. The tool is written in Rust, and I haven't taken a deep look at it, so not sure hjow they use the DAP protocol here exactly.


 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #22 on: May 05, 2021, 11:24:58 pm »
The project you linked does use JTAG Sequence command. I assume OpenOCD does the same. This is bit banging. It is not inefficient, as CMSIS-DAP is a generally well designed protocol. This still sends the raw bits.

JTAG Transfer requests are way more efficient, but only work for ARM-based APs.

It is good that there is support from tools for that though.

Also, Rust is unreadable garbage. I don't understand why people find it so attractive.
Alex
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14434
  • Country: fr
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #23 on: May 05, 2021, 11:33:16 pm »
The project you linked does use JTAG Sequence command. I assume OpenOCD does the same. This is bit banging. It is not inefficient, as CMSIS-DAP is a generally well designed protocol. This still sends the raw bits.

JTAG Transfer requests are way more efficient, but only work for ARM-based APs.

It is good that there is support from tools for that though.

Also, Rust is unreadable garbage. I don't understand why people find it so attractive.

Well, that's another topic. ;D
But it's actually kind of annoying here. I'd like to port his project for using FTDI-based probes, but I don't get Rust (or really want to use it) enough to do that...
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11234
  • Country: us
    • Personal site
Re: Does anyone have experience debugging CMSIS-DAP firmware itself?
« Reply #24 on: May 06, 2021, 01:51:52 am »
Oh, wow, this is stupid. So there are two devices on the same JTAG port. One is ARM-compatible with IR length of 4. This is the one that has ARM-specific access registers, but has no standard test registers. And then there is another one that is the actual device with IR length of 5.

By default the 5 one is selected and total IR length is 5 bits. And when you bypass that one, the 4 bit one is activated and total IR length becomes 9.

This is the stupidest hack I've seen in quite some time. ARM really screwed up JTAG.

So if you want to do boundary scan, then device behaves as you would expect, and as described by the BSDL file. But if you want to debug or even just program, it all becomes custom real fast.

Correction: IR length is actually always 9. And the 4-bit TAP is just bypassed by default, so it causes one bit delay. This also means that BSDL file for this device is a complete nonsense, since it lists it as one device with IR length = 5. But if you try to access it like one device, everything would be shifted by one bit (which is exactly what I get when reading ID code). You can't simply ignore that second device in the chain.

On a positive note, this will let me test multiple chained devices.
« Last Edit: May 06, 2021, 02:13:05 am by ataradov »
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf