I have the J-Link firmware (latest from Segger website) for OpenSDAv2 on FRDM-K64F. On Windows 7 I can connect to the board with KDS with the JLink debug connection. That works great. However, on Ubuntu 12.04 running in Virtual Box, It cannot connect. I double checked that my VirtualBox settings are allowing it to see the Segger JLink USB device is connected, however the GDB Server isn’t able to connect. I also tried installing the latest JLink software and running the command line JLinkExe utility, but it also can’t connect.
Here is the output from the console showing the error:
-----GDB Server start settings----- GDBInit file: none GDB Server Listening port: 2331 SWO raw output listening port: 2332 Terminal I/O port: 2333 Accept remote connection: localhost only Generate logfile: off Verify download: on Init regs on start: on Silent mode: off Single run mode: on Target connection timeout: 5 sec. ------J-Link related settings------ J-Link Host interface: USB J-Link script: none J-Link settings file: none ------Target related settings------ Target device: MK64FN1M0xxx12 Target interface: SWD Target interface speed: 30kHz Target endian: little
Connecting to J-Link... Connecting to J-Link failed. Connected correctly? GDBServer will be closed... Shutting down...
The issue is related to the USB hand-over between Windows and my Ubuntu Virtual Machine.
Segger said that “Under special circumstances, when the J-Link first enumerates under windows and then manually attaches to the VM by clicking add removable devices, we see the connection problem. When power-cycling the USB, it enumerates directly in the virtual machine (Linux) and from now it’s working as expected:”
Usually, I start Ubuntu VM from Virtual Box, then capture the Segger USB device in the Devices…USB Devices… menu in the VM. Thus power cycling does not help, because if I unplug the USB cable and plug it back in, it enumerates back in Windows.
However, a colleague mentioned that in the Virtual Box Manager, you can add the Segger USB device to enumerate directly in Ubuntu VM without having to capture it. This is done by first plugging in the cable, then in the Virtual Box Manager, go to Settings…USB… (click add icon) and select the Segger usb device.
After making this settings change, if I start up Ubuntu VM with the USB cable already connected, I still have to unplug and re-plug it for it to work. However, if I start up Ubuntu VM first before plugging in the cable, it works.