Today I tried to use the libusb usbdk backend (1.021 release build using
MSYS2 32bit) and it seems to work. You will notice the driver switching
sound when you run openocd.
For the test, I downloaded the OpenOCD 0.10.0-rc1 Windows binary from
Freddie and replace libusb-1.0.dll with the one I built using MSYS2 (with
--enable-usbdk option).
1) Install USBDK
2) Build libusb 1.0.21 release with --enable-usbdk
3) Run cmd.exe as admin and go to USBDK directory
c:\Program Files\UsbDk Runtime Library>UsbDkController.exe -i
Installing UsbDk driver
UsbDk driver installation succeeded
c:\Program Files\UsbDk Runtime Library>UsbDkController.exe -n
Enumerate USB devices
Found 5 USB devices:
0. FilterID: 3, Port: 1, ID: 045e:0773, Configs: 1, Speed: 2
USB\VID_045E&PID_0773 1
Descriptor for configuration #0: size 84
1. FilterID: 3, Port: 3, ID: 1366:0101, Configs: 1, Speed: 2
USB\VID_1366&PID_0101 0077000044
Descriptor for configuration #0: size 32
2. FilterID: 5, Port: 5, ID: 058f:6366, Configs: 1, Speed: 3
USB\VID_058F&PID_6366 058F63666433
Descriptor for configuration #0: size 32
3. FilterID: 5, Port: 7, ID: 13d3:5130, Configs: 1, Speed: 3
USB\VID_13D3&PID_5130 7
Descriptor for configuration #0: size 569
4. FilterID: 7, Port: 1, ID: 0b05:1788, Configs: 1, Speed: 2
USB\VID_0B05&PID_1788 1C4BD6065A96
Descriptor for configuration #0: size 216
4) Now replace libusb-1.0.dll in Freddie's binary with the newly
build libusb-1.0.dll file, I have to copy MSYS2's libgcc_s_dw2-1.dll
as well since MSYS2 is using a different compiler toolchain than
Freddie's cross-compiler.
5) Without changing J-Link's vendor driver (Segger J-Link
driver -- Jlinkx64.sys in my Windows 10 64bit system), you
can run openocd now.
You will notice driver switching during the one (Windows system sound).
H:\work\openocd\openocd-0.10.0-rc1\bin>openocd.exe -f openocd_stm32sk.cfg
Open On-Chip Debugger 0.10.0-rc1
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To
override use 'transport select <transport>'.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link ARM V7 compiled Jun 20 2012 19:45:53
Info : Hardware version: 7.00
Info : VTarget = 3.274 V
Info : clock speed 1000 kHz
Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b
(ARM Ltd.), part: 0xba00, ver: 0x3)
Info : JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020
(STMicroelectronics), part: 0x6410, ver: 0x1)
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
adapter speed: 1000 kHz
Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b
(ARM Ltd.), part: 0xba00, ver: 0x3)
Info : JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020
(STMicroelectronics), part: 0x6410, ver: 0x1)
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
adapter speed: 8000 kHz
Info : device id = 0x20036410
Info : flash size = 128kbytes
stm32x mass erase complete
dumped 131072 bytes in 1.811999s (70.640 KiB/s)
verified 131072 bytes in 0.455134s (281.236 KiB/s)
wrote 131072 bytes from file dump.bin in 4.605238s (27.794 KiB/s)
verified 131072 bytes in 0.510375s (250.796 KiB/s)
20480 bytes written at address 0x20000000
downloaded 20480 bytes in 0.252001s (79.365 KiB/s)
shutdown command invoked
6) It is also easy to uninstall usbdk. Run as admin.
c:\Program Files\UsbDk Runtime Library>UsbDkController.exe -u
Uninstalling UsbDk driver
UsbDk driver uninstall succeeded
c:\Program Files\UsbDk Runtime Library>UsbDkController.exe -n
Enumerate USB devices
Driver file operation error. Failed to open device symlink \\.\UsbDk
(The system cannot find the file specified. Error code = 2)
Enumeration failed
7) Now run openocd again and it will fail.
H:\work\openocd\openocd-0.10.0-rc1\bin>openocd.exe -f openocd_stm32sk.cfg
Open On-Chip Debugger 0.10.0-rc1
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To
override use 'transport select <transport>'.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Driver file operation error. Failed to open device symlink \\.\UsbDk
(The system cannot find the file specified. Error code = 2)
Error: Failed to retrieve device list: LIBUSB_ERROR_OTHER.
Error: USB device discovery failed.
Error: jaylink_discovery_scan() failed: JAYLINK_ERR.
--
Xiaofan
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel