1

I have been recently trying to make the Atmel ICE debugger work with openOCD under ubuntu 20.04 running on WSL2.

When running the openOCD with the atmel debugger config below

source [find interface/cmsis-dap.cfg]
set CHIPNAME atsame54p20a
source [find target/atsame5x.cfg]

i get this Error :

Error: 75 70 cmsis_dap.c:259 cmsis_dap_open(): unable to find a matching CMSIS-DAP device

Full openOCD output here:

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
User : 13 0 options.c:63 configuration_output_handler(): debug_level: 3
User : 14 0 options.c:63 configuration_output_handler():
Debug: 15 0 options.c:244 add_default_dirs(): bindir=/usr/bin
Debug: 16 0 options.c:245 add_default_dirs(): pkgdatadir=/usr/share/openocd
Debug: 17 0 options.c:246 add_default_dirs(): exepath=/usr/bin
Debug: 18 0 options.c:247 add_default_dirs(): bin2data=../share/openocd
Debug: 19 0 configuration.c:42 add_script_search_dir(): adding /home/iwahdan/.config/openocd
Debug: 20 0 configuration.c:42 add_script_search_dir(): adding /home/iwahdan/.openocd
Debug: 21 0 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/site
Debug: 22 0 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/scripts
Debug: 23 0 configuration.c:97 find_file(): found openocd.cfg
Debug: 24 0 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/interface/cmsis-dap.cfg
Debug: 25 1 command.c:146 script_debug(): command - adapter driver cmsis-dap
Debug: 27 1 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/target/atsame5x.cfg
Debug: 28 1 configuration.c:97 find_file(): found /usr/bin/../share/openocd/scripts/target/swj-dp.tcl
Debug: 29 1 command.c:146 script_debug(): command - transport select
Info : 30 1 transport.c:275 jim_transport_select(): auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Debug: 31 1 command.c:146 script_debug(): command - transport select
Debug: 32 1 command.c:146 script_debug(): command - transport select
Debug: 33 1 command.c:146 script_debug(): command - swd newdap atsame54p20a cpu -irlen 4 -expected-id 0x4ba00477
Debug: 34 1 tcl.c:571 jim_newtap_cmd(): Creating New Tap, Chip: atsame54p20a, Tap: cpu, Dotted: atsame54p20a.cpu, 4 params
Debug: 35 1 core.c:1484 jtag_tap_init(): Created Tap: atsame54p20a.cpu @ abs position 0, irlen 0, capture: 0x0 mask: 0x0
Debug: 36 1 command.c:146 script_debug(): command - dap create atsame54p20a.dap -chain-position atsame54p20a.cpu
Debug: 37 1 command.c:146 script_debug(): command - target create atsame54p20a.cpu cortex_m -endian little -dap atsame54p20a.dap
Debug: 38 1 command.c:375 register_command(): command 'rtt' is already registered in '<global>' context
Debug: 39 1 command.c:146 script_debug(): command - atsame54p20a.cpu configure -work-area-phys 0x20000000 -work-area-size 0x8000 -work-area-backup 0
Debug: 40 1 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 41 1 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 42 1 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas
Debug: 43 1 command.c:146 script_debug(): command - atsame54p20a.cpu configure -event reset-deassert-post
        atsame5 dsu_reset_deassert

Debug: 44 1 command.c:146 script_debug(): command - reset_config srst_gates_jtag
Debug: 46 1 command.c:146 script_debug(): command - adapter speed 2000
Debug: 48 1 core.c:1822 jtag_config_khz(): handle jtag khz
Debug: 49 1 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 50 1 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 51 1 command.c:146 script_debug(): command - transport select
Debug: 52 1 command.c:146 script_debug(): command - cortex_m reset_config sysresetreq
Debug: 54 1 command.c:146 script_debug(): command - flash bank atsame54p20a.flash atsame5 0x00000000 0 1 1 atsame54p20a.cpu
Debug: 56 1 tcl.c:1319 handle_flash_bank_command(): 'atsame5' driver usage field missing
Info : 57 1 server.c:311 add_service(): Listening on port 6666 for tcl connections
Info : 58 1 server.c:311 add_service(): Listening on port 4444 for telnet connections
Debug: 59 1 command.c:146 script_debug(): command - init
Debug: 61 1 command.c:146 script_debug(): command - target init
Debug: 63 1 command.c:146 script_debug(): command - target names
Debug: 64 1 command.c:146 script_debug(): command - atsame54p20a.cpu cget -event gdb-flash-erase-start
Debug: 65 1 command.c:146 script_debug(): command - atsame54p20a.cpu configure -event gdb-flash-erase-start reset init
Debug: 66 1 command.c:146 script_debug(): command - atsame54p20a.cpu cget -event gdb-flash-write-end
Debug: 67 1 command.c:146 script_debug(): command - atsame54p20a.cpu configure -event gdb-flash-write-end reset halt
Debug: 68 1 command.c:146 script_debug(): command - atsame54p20a.cpu cget -event gdb-attach
Debug: 69 1 command.c:146 script_debug(): command - atsame54p20a.cpu configure -event gdb-attach halt 1000
Debug: 70 1 target.c:1639 handle_target_init_command(): Initializing targets...
Debug: 71 1 semihosting_common.c:99 semihosting_common_init():
Debug: 72 3 cmsis_dap_usb_bulk.c:111 cmsis_dap_usb_open(): could not open device 0x1d6b:0x0003: Access denied (insufficient permissions)
Debug: 73 6 cmsis_dap_usb_bulk.c:156 cmsis_dap_usb_open(): found product string of 0x03eb:0x2141 'Atmel-ICE CMSIS-DAP'
Debug: 74 6 cmsis_dap_usb_bulk.c:176 cmsis_dap_usb_open(): enumerating interfaces of 0x03eb:0x2141
Debug: 75 7 cmsis_dap_usb_bulk.c:223 cmsis_dap_usb_open(): found interface 0 string 'Atmel-ICE CMSIS-DAP'
Debug: 76 7 cmsis_dap_usb_bulk.c:243 cmsis_dap_usb_open(): skipping interface 0, endpoint[0] is not bulk out
Debug: 77 8 cmsis_dap_usb_bulk.c:243 cmsis_dap_usb_open(): skipping interface 1, endpoint[0] is not bulk out
Debug: 78 24 cmsis_dap_usb_bulk.c:176 cmsis_dap_usb_open(): enumerating interfaces of 0x0483:0x3753
Debug: 79 72 cmsis_dap_usb_bulk.c:111 cmsis_dap_usb_open(): could not open device 0x1d6b:0x0002: Access denied (insufficient permissions)
Error: 80 72 cmsis_dap.c:259 cmsis_dap_open(): unable to find a matching CMSIS-DAP device
Debug: 81 72 command.c:628 run_command(): Command 'init' failed with error code -4
User : 82 72 command.c:694 command_run_line():
Debug: 83 72 target.c:2172 target_free_all_working_areas_restore(): freeing all working areas

pulling up the dmesg log i found:

[ 1588.445948] usb 1-2: new high-speed USB device number 3 using vhci_hcd
[ 1588.605960] usb 1-2: SetAddress Request (3) to port 1
[ 1588.639106] usb 1-2: New USB device found, idVendor=03eb, idProduct=2141, bcdDevice= 
1.01
[ 1588.639529] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1588.639913] usb 1-2: Product: Atmel-ICE CMSIS-DAP
[ 1588.640129] usb 1-2: Manufacturer: Atmel Corp.
[ 1588.640308] usb 1-2: SerialNumber: J42700004736
[ 1588.646303] hid-generic 0003:03EB:2141.0001: device has no listeners, quitting

As you can see there seems to be a problem:

hid-generic 0003:03EB:2141.0001: device has no listeners, quitting

below is the output of the lsusb :

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=vhci_hcd/8p, 5000M
ID 1d6b:0003 Linux Foundation 3.0 root hub
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=vhci_hcd/8p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
|__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 480M
    ID 03eb:2141 Atmel Corp. ICE debugger
|__ Port 2: Dev 3, If 1, Class=Vendor Specific Class, Driver=, 480M
    ID 03eb:2141 Atmel Corp. ICE debugger

Any Idea what might be wrong here?

2
  • 1
    Welcome to Ask Ubuntu! I'm more surprised that lsusb is showing the debugger at all. You don't seem to be running USB/IP, right? Oct 6, 2022 at 18:14
  • Imported USB devices ==================== libusbip: error: fopen libusbip: error: read_record Port 00: <Port in Use> at High Speed(480Mbps) Atmel Corp. : ICE debugger (03eb:2141) 1-1 -> unknown host, remote port and remote busid -> remote bus/dev 005/002
    – iwahdan
    Oct 8, 2022 at 9:40

1 Answer 1

1

You need to recompile the Microsoft Linux kernel found here within WSL. Uncomment the option CONFIG_USB_HIDDEV=y from the config-wsl file.

Full instructions below:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git build-essential flex bison libssl-dev libelf-dev bc dwarves
git clone https://github.com/microsoft/WSL2-Linux-Kernel wsl2
cd wsl2
  • Open Microsoft/config-wsl with the text editor of your choice. I prefer to use Vim.

  • Search for the commented out line that says # CONFIG_USB_HIDDEV is not set.

  • Uncomment it and change it to CONFIG_USB_HIDDEV=y.

  • You will also want to change your kernel name.

  • Save your changes and run:

    make O=out KCONFIG_CONFIG=Microsoft/config-wsl
    

    This will start building the new kernel image. You might get prompted about NEW features to be included. I chose to decline each one. Compilation will probably take around 20 to 30 minutes.

  • Once it is done compiling, there will be a file called bzImage in the out/arch/x86/boot directory. Copy this file to somewhere on your Windows computer. I just did:

    cp out/arch/x86/boot/bzImage /mnt/c/Users/username/Desktop
    

    This copied the file straight to my Windows desktop.

  • Rename bzImage to kernel.

  • Close out of WSL2 and type wsl --shutdown to make sure WSL2 is properly shutdown.

  • Go to C:\Windows\System32\lxss\tools and rename the current kernel file to stock-kernel.old

  • Copy and paste your generated kernel file into this directory.

  • Relaunch Ubuntu.

  • You might get an error that says Process cannot access the file because it is being used by another process. If that's the case, run cmd in admin mode and type netsh winsock reset.

  • Then restart your computer.

  • Open Ubuntu and you will be greeted with your custom kernel name.

You can verify that the Atmel Ice is enumerated properly after you attach it by typing dmesg.

This is what my output shows:

[    7.193727] usb 1-1: New USB device found, idVendor=03eb, idProduct=2141, bcdDevice= 1.01
[    7.193731] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    7.193733] usb 1-1: Product: Atmel-ICE CMSIS-DAP
[    7.193734] usb 1-1: Manufacturer: Atmel Corp.
[    7.193735] usb 1-1: SerialNumber: J42700061718
[    7.197202] hid-generic 0003:03EB:2141.0001: hiddev96: USB HID v1.11 Device
[Atmel Corp. Atmel-ICE CMSIS-DAP] on usb-vhci_hcd.0-1/input0
2
  • Welcome to Ask Ubuntu! Likely a good answer (I haven't tested it myself, but everything looked right to me), but do hit the Edit button and note the changes in formatting that I made for readability. In general, you'll want to format multi-step instructions as a list. And use triple-backticks to make multi-line code blocks, rather than using single-backticks on each line. Just something to take note of as I hope you'll post answers here in the future. See the Formatting Guide for more details. Thanks! Nov 23, 2022 at 16:01
  • Also curious (based on my earlier look at the question) - Did this require USB/IP for you? Or are you able to access the device directly somehow? Nov 23, 2022 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.