Problem with LPC-LINK2/CMSIS-DAP with OpenOCD and VirtualBox/Vagrant

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with LPC-LINK2/CMSIS-DAP with OpenOCD and VirtualBox/Vagrant

4,508 Views
philmcmillan
Contributor II

I am trying to set up a few debug probes with OpenOCD under Vagrant (using VirtualBox).  Mostly this has been very successful.  I have the following working:
- LPC-Link2 using J-Link firmware with VirtualBox
- FRDM-K28F using CMSIS-DAP firmware with VirtualBox

- LPC-Link2 using CMSIS-DAP firmware (on the host directly, without VirtualBox)

LPC-Link2 using CMSIS-DAP firmware *does not work* using VirtualBox.  Given that it works fine on the host with the same configuration when VirtualBox is *not* used, this would seem to rule out common issues with the USB cabling, host hardware etc.

Looking for some guidance in where the problem with the specific LPC-Link2 + CMSIS-DAP + VirtualBox configuration is not working.  Given that all other combinations work flawlessly, I expect this is a bug somewhere.  I'd like to get this working because CMSIS-DAP on LPC-Link2 under Vagrant/VirtualBox is my preferred configuration.

I note also that when HID enumerates the LPC-Link2 and FRDM-K28F board with CMSIS-DAP firmware, LPC-Link2 shows up as 3 devices/paths, whereas the Freedom board shows up as only 1.  So there may be some architectural difference between the two implementations that is causing the failure.

Debug on the failing configuration shows that although the enumeration of the LPC-Link2 seems to work correctly under VirtualBox, the LPC-Link2 isn't receiving a reply from the USB transfer associated with the GET_INFO request, and is timing out.

More details below:

LPC-Link2 with CMSIS-DAP Firmware with OpenOCD with VirtualBox

This is the failing configuration.

vagrant@vagrant-ubuntu-trusty-64:~$ openocd -f interface/cmsis-dap.cfg -c "transport select swd" -c "adapter_khz 500" -f target/kx.cfg
Open On-Chip Debugger 0.10.0+dev-00910-g4dbcb1e (2019-06-15-02:46)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 500 kHz

Info : add flash_bank kinetis kx.pflash
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: CMSIS-DAP command CMD_INFO failed.

vagrant@vagrant-ubuntu-trusty-64:~$

With debug...

vagrant@vagrant-ubuntu-trusty-64:~$ openocd -d -f interface/cmsis-dap.cfg -c
openocd -d -f interface/cmsis-dap.cfg -c "transport select swd" -c "adapter_khz 500" -f target/kx.cfg
...
<<many lines deleted>>
...
Debug: 200 1041 cmsis_dap_usb.c:409 cmsis_dap_usb_xfer(): error reading data: (null)
Error: 201 1042 cmsis_dap_usb.c:503 cmsis_dap_cmd_DAP_Info(): CMSIS-DAP command CMD_INFO failed.
Debug: 202 1044 command.c:630 run_command(): Command 'init' failed with error code -107


Review of the OpenOCD / HIDAPI code indicates a timeout is occurring without data being received from the command (I have confirmed this by changing the timeout from 1 second default to 5 seconds and noting the same failure after 5 seconds).

LPC-Link2 with CMSIS-DAP Firmware with OpenOCD on the host (no VirtualBox)

When VirtualBox is not used, this configuration works as expected.

phil@pop-os:~$ sudo openocd -f interface/cmsis-dap.cfg -c "transport select swd" -c "adapter_khz 500" -f target/kx.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 500 kHz
Info : add flash_bank kinetis kx.flash
adapter speed: 1000 kHz
none separate
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.10
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x0bc11477
Info : MDM: Chip is unsecured. Continuing.
Info : kx.cpu: hardware has 2 breakpoints, 2 watchpoints
^C
phil@pop-os:~$

LPC-Link2 with J-Link Firmware with OpenOCD with VirtualBox

This works perfectly under VirtualBox/OpenOCD.

vagrant@vagrant-ubuntu-trusty-64:~$ openocd -f interface/jlink.cfg -c "transport select swd" -c "adapter_khz 500" -f target/kx.cfg
Open On-Chip Debugger 0.10.0+dev-00910-g4dbcb1e (2019-06-15-02:46)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 500 kHz

Info : add flash_bank kinetis kx.pflash
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link LPC-Link 2 compiled Sep 23 2016 12:15:22
Info : Hardware version: 1.00
Info : VTarget = 3.300 V
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x0bc11477
Info : MDM: Chip is unsecured. Continuing.
Info : kx.cpu: hardware has 2 breakpoints, 2 watchpoints
Info : kx.cpu: external reset detected
Info : Listening on port 3333 for gdb connections

FRDM-K28F Board with CMSIS-DAP Firmware under OpenOCD/Vagrant/VirtualBox

This configuration works perfectly.

vagrant@vagrant-ubuntu-trusty-64:~/hidapi/hidtest$ openocd -f interface/cmsis-dap.cfg -c "transport select swd" -c "adapter_khz 500" -f target/kx.cfg
Open On-Chip Debugger 0.10.0+dev-00910-g4dbcb1e (2019-06-15-03:10)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 500 kHz

Info : add flash_bank kinetis kx.pflash
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : MDM: Chip is unsecured. Continuing.
Info : kx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : kx.cpu: external reset detected
Info : Listening on port 3333 for gdb connections

HIDAPI Enumerations under VirtualBox

I notice that the LPC-Link2 and FRDM-K28F enumerate differently for both HIDRAW and LIBUSB modes.  The LPC-Link2 board presents itself as three devices/paths, whereas the Freedom Board only one.

For LPC-Link2

vagrant@vagrant-ubuntu-trusty-64:~/hidapi/hidtest$ ./hidtest-hidraw
Device Found
  type: 1fc9 0090
  path: /dev/hidraw0
  serial_number: I3F4AXOR
  Manufacturer: NXP Semiconductors
  Product:      LPC-LINK2 CMSIS-DAP V5.224
  Release:      100
  Interface:    0

Device Found
  type: 1fc9 0090
  path: /dev/hidraw2
  serial_number: I3F4AXOR
  Manufacturer: NXP Semiconductors
  Product:      LPC-LINK2 CMSIS-DAP V5.224
  Release:      100
  Interface:    3

Device Found
  type: 1fc9 0090
  path: /dev/hidraw1
  serial_number: I3F4AXOR
  Manufacturer: NXP Semiconductors
  Product:      LPC-LINK2 CMSIS-DAP V5.224
  Release:      100
  Interface:    4

vagrant@vagrant-ubuntu-trusty-64:~/hidapi/hidtest$ ./hidtest-libusb
Device Found
  type: 1fc9 0090
  path: 0001:0002:00
  serial_number: I3F4AXOR
  Manufacturer: NXP Semiconductors
  Product:      LPC-LINK2 CMSIS-DAP V5.224
  Release:      100
  Interface:    0

Device Found
  type: 1fc9 0090
  path: 0001:0002:04
  serial_number: I3F4AXOR
  Manufacturer: NXP Semiconductors
  Product:      LPC-LINK2 CMSIS-DAP V5.224
  Release:      100
  Interface:    4

Device Found
  type: 1fc9 0090
  path: 0001:0002:03
  serial_number: I3F4AXOR
  Manufacturer: NXP Semiconductors
  Product:      LPC-LINK2 CMSIS-DAP V5.224
  Release:      100
  Interface:    3
...
vagrant@vagrant-ubuntu-trusty-64:~/hidapi/hidtest$


For FRDM-K28F

vagrant@vagrant-ubuntu-trusty-64:~/hidapi/hidtest$ ./hidtest-hidraw
Device Found
  type: 0d28 0204
  path: /dev/hidraw0
  serial_number: 0224000032044e450034700a997b002e6781000097969900
  Manufacturer: ARM
  Product:      DAPLink CMSIS-DAP
  Release:      1000
  Interface:    3

vagrant@vagrant-ubuntu-trusty-64:~/hidapi/hidtest$ ./hidtest-libusb
Device Found
  type: 0d28 0204
  path: 0002:0002:03
  serial_number: 0224000032044e450034700a997b002e6781000097969900
  Manufacturer: ARM
  Product:      DAPLink CMSIS-DAP
  Release:      1000
  Interface:    3

7 Replies

3,333 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Yes, NXP does develop and maintain the CMSIS-DAP based firmware that we provide for LPC-Link2 (softloadable using MCUXpresso IDE, and programmable into flash on the LPC-Link2 probe using LPCScrypt).  This firmware has been in the field and being used by many thousands of customers for many years now, working on Windows, Mac and Linux hosts. Our focus is always that debugging works on native OS installs, though I can confirm that we don't see issues on the VM systems that we use ourselves (though we don't use VirtualBox here). 

However from what you have already written, the issues that you are seeing seem to be specific to using VirtualBox on specific host platforms. As you have already commented, it sounds like this issue is one for the VirtualBox team.

Regards,

MCUXpresso IDE Support

0 Kudos

3,333 Views
philmcmillan
Contributor II

Thanks a lot for the reply, just to confirm with VirtualBox on the Mac, I can replicate the same issue - but the issue occurs much less frequently (perhaps one failure every 5 attempts).

Unfortunately I don't think I'll have much luck with resolving with VirtualBox when the same LPC-Link2 works correctly under virtualbox with J-Link firmware.  And given that Kinetis freedom boards running DAPlink, ST links and J-Link probes all work 100% under virtualbox, it is most likely the interaction between VirtualBox and this specific board/firmware combination causing the issue.  So although I would prefer to use LPC-Link2 under this arrangement it is probably best to look to one of these other probes and put this down to a subtle bug that will most likely be impossible to rectify.

0 Kudos

3,334 Views
brendonslade
NXP TechSupport
NXP TechSupport

Hi Phil,

is there a reason not to use J-link on LPC-Link2? There is some loss of functionality (power measurement), but for most debug functions your needs should be met by this option...?

regards,

Brendon

3,334 Views
philmcmillan
Contributor II

Hi Brendon -

Technically the JLink option on the LPC-Link2 is a good solution.   

Unfortunately the licensing agreement is not - my understanding is that this firmware is only licensed for educational use with NXP components.  I am looking for an inexpensive and open solution without these restrictions on its use.  This is the appeal of CMSIS-DAP in this situation. 

0 Kudos

3,334 Views
BlackNight
NXP Employee
NXP Employee

The J-Link EDU is indeed restricted to non-commercial/educational usage (J-Link EDU for educational use | SEGGER - The Embedded Experts and mini: J-Link EDU Mini | SEGGER - The Embedded Experts ), but is not limited to NXP devices.

I hope this helps,

Erich

0 Kudos

3,333 Views
philmcmillan
Contributor II

Just updating this question with some more info.   

Logged an issue under on the CMSIS_5 GitHub page LPC-Link2 Communication Issue with VirtualBox · Issue #613 · ARM-software/CMSIS_5 · GitHub , although they have advised that the LPC-Link2 firmware is maintained by NXP and I should direct accordingly.  Hoping this can be looked at.

I have taken USBMON captures at the host with both the non-VirtualBox (working) configuration and VirtualBox (not working) configurations. These are shown below. It looks like the DAP capability request is being sent from the VM but the LPC-Link2 will not respond correctly to it. In fact, the LPC-Link2 continues to send empty data until the board is disconnected.

Any help in rectifying or letting me know where to continue looking would be much appreciated.
I'd be pleased to provide any additional info or additional testing as required.

On Local Linux (no VirtualBox) - this is the working configuration

phil@pop-os:~/kinetis$ lsusb
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 006: ID 1fc9:0090 NXP Semiconductors
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 2232:1024 Silicon Motion
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


phil@pop-os:~/kinetis$ openocd -f interface/cmsis-dap.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: Interface Initialised (JTAG)
Info : CMSIS-DAP: FW Version = 1.10
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Error: CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed.

Communication works correctly. (ignore failure message, this is related to not setting interface speed in openocd. You can observe correct response to the "00f0" capability request below, the line starting with 000113, which inducates support for SWD and JTAG)

 

phil@pop-os:~/kinetis$ sudo cat /sys/kernel/debug/usb/usbmon/3u > ~/usb.novm.out
phil@pop-os:~/kinetis$ cat ~/usb.novm.out
ffff883b8ae52f00 3349649709 S Ii:3:006:1 -115:8 1024 <
ffff883b9c751540 3349708212 S Io:3:006:1 -115:8 64 = 00f00000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b9c751540 3349708738 C Io:3:006:1 0:8 64 >
ffff883b8ae52f00 3349708782 C Ii:3:006:1 0:8 1024 = 00011300 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b9c751540 3349708898 S Io:3:006:1 -115:8 64 = 02020000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b8ae52f00 3349709199 S Ii:3:006:1 -115:8 1024 <
ffff883b9c751540 3349709723 C Io:3:006:1 0:8 64 >
ffff883b8ae52f00 3349709780 C Ii:3:006:1 0:8 1024 = 02020000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b9c751540 3349709863 S Io:3:006:1 -115:8 64 = 00040000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b8ae52f00 3349710185 S Ii:3:006:1 -115:8 1024 <
ffff883b9c751540 3349710723 C Io:3:006:1 0:8 64 >
ffff883b8ae52f00 3349710780 C Ii:3:006:1 0:8 1024 = 0005312e 31300000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b9c751540 3349710864 S Io:3:006:1 -115:8 64 = 00ff0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b8ae52f00 3349711144 S Ii:3:006:1 -115:8 1024 <
ffff883b9c751540 3349711725 C Io:3:006:1 0:8 64 >
ffff883b8ae52f00 3349711781 C Ii:3:006:1 0:8 1024 = 00020004 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b9c751540 3349711867 S Io:3:006:1 -115:8 1024 = 00fe0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b8ae52f00 3349712147 S Ii:3:006:1 -115:8 1024 <
ffff883b9c751540 3349712753 C Io:3:006:1 0:8 1024 >
ffff883b8ae52f00 3349712784 C Ii:3:006:1 0:8 1024 = 00010400 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b9c751540 3349712821 S Io:3:006:1 -115:8 1024 = 10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b8ae52f00 3349713136 S Ii:3:006:1 -115:8 1024 <
ffff883b9c751540 3349713751 C Io:3:006:1 0:8 1024 >
ffff883b8ae52f00 3349713781 C Ii:3:006:1 0:8 1024 = 108f0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b9c751540 3349713870 S Io:3:006:1 -115:8 1024 = 11000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b8ae52f00 3349714147 S Ii:3:006:1 -115:8 1024 <
ffff883b9c751540 3349714746 C Io:3:006:1 0:8 1024 >
ffff883b8ae52f00 3349714788 C Ii:3:006:1 0:8 1024 = 11ff312e 31300000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b8ae52f00 3349715232 S Ii:3:006:1 -115:8 1024 <
ffff883b8ae52f00 3349716642 C Ii:3:006:1 -2:8 0
phil@pop-os:~/kinetis$

In VirtualBox (but keeping USBMON in same position on the host) - this is the failing configuration

On the VM

vagrant@ubuntu-xenial:~$ openocd -f interface/cmsis-dap.cfg
Open On-Chip Debugger 0.10.0+dev-00920-g6ea4372 (2019-06-23-11:11)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: CMSIS-DAP command CMD_INFO failed.

vagrant@ubuntu-xenial:~$

On the Host

phil@pop-os:~/kinetis$ lsusb
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 007: ID 1fc9:0090 NXP Semiconductors
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 2232:1024 Silicon Motion
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
phil@pop-os:~/kinetis$ sudo cat /sys/kernel/debug/usb/usbmon/3u > ~/usb.vm.out
^C
phil@pop-os:~/kinetis$ wc -l ~/usb.vm.out
1006 /home/phil/usb.vm.out
phil@pop-os:~/kinetis$ head -30 ~/usb.vm.out
ffff883b8ae526c0 3916360551 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae52540 3916398115 S Io:3:007:1 -115:8 64 = 00f00000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff883b8ae52540 3916398523 C Io:3:007:1 0:8 64 >
ffff883b8ae526c0 3916398633 C Ii:3:007:1 0:8 0
ffff883b94ed6b40 3916399999 S Ii:3:007:1 -115:8 1024 <
ffff883b94ed6b40 3916400637 C Ii:3:007:1 0:8 0
ffff883b8ae526c0 3916401993 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae526c0 3916402639 C Ii:3:007:1 0:8 0
ffff883b8ae52540 3916403941 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae52540 3916404671 C Ii:3:007:1 0:8 0
ffff883b8ae52840 3916405969 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae52840 3916406669 C Ii:3:007:1 0:8 0
ffff883b8ae52900 3916407959 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae52900 3916408708 C Ii:3:007:1 0:8 0
ffff883b8ae52e40 3916410056 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae52e40 3916410707 C Ii:3:007:1 0:8 0
ffff883b8ae520c0 3916412060 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae520c0 3916412633 C Ii:3:007:1 0:8 0
ffff883b8ae520c0 3916413934 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae520c0 3916414672 C Ii:3:007:1 0:8 0
ffff883b94ed6b40 3916416068 S Ii:3:007:1 -115:8 1024 <
ffff883b94ed6b40 3916416670 C Ii:3:007:1 0:8 0
ffff883b94ed60c0 3916417941 S Ii:3:007:1 -115:8 1024 <
ffff883b94ed60c0 3916418662 C Ii:3:007:1 0:8 0
ffff883b94ed6540 3916419899 S Ii:3:007:1 -115:8 1024 <
ffff883b94ed6540 3916420669 C Ii:3:007:1 0:8 0
ffff883b807dde40 3916421936 S Ii:3:007:1 -115:8 1024 <
ffff883b807dde40 3916422641 C Ii:3:007:1 0:8 0
ffff883b8ae520c0 3916423997 S Ii:3:007:1 -115:8 1024 <
ffff883b8ae520c0 3916424708 C Ii:3:007:1 0:8 0
phil@pop-os:~/kinetis$

The "jabberring" from the LPC-Link2 continues and the file becomes very large, requires disconnection and reconnection to fix.

0 Kudos

3,333 Views
philmcmillan
Contributor II

After more testing:  I can confirm that the LPC-Link2 with CMSIS-DAP firmware works correctly with VirtualBox on the Mac.
It does not work correctly with VirtualBox on Linux.

I believe that this is most likely a bug with VirtualBox for Linux.

I will raise a bugtracker with the VirtualBox team to try to get this looked into. 

0 Kudos