stlink-org / stlink

Open source STM32 MCU programming toolset
BSD 3-Clause "New" or "Revised" License
4.41k stars 1.24k forks source link

libusb_set_configuration() failed - usb microframes interval mismatch #427

Closed multivac61 closed 8 years ago

multivac61 commented 8 years ago

I have a STMicroelectronics NUCLEO-L152RE development board. My OS is Ubuntu, I'm running the 4.4.0-22-generic kernel and I just pulled the newest stlink v1.2.0 branch. When running ./st-util I receiven an error saying that "libusb_set_configuration() failed" (see Output). My default user (and root) is both in the dialouṭ and ̣plugdeṿ groups as you ask about in this issue.

I have the newest version of libusb available on apt, 2:1.0.20-1.

Output:

sudo ./st-util 
setting new configuration (0 -> 1)
2016-06-04T22:47:22 WARN src/stlink-usb.c: libusb_set_configuration() failed
[!] send_recv
2016-06-04T22:47:22 INFO gdbserver/gdb-server.c: Chip ID is 00000000, Core ID is  00000000.
[!] send_recv
2016-06-04T22:47:22 INFO gdbserver/gdb-server.c: Listening at *:4242...
^C[!] send_recv

Please let me know what I can do to help.

xor-gate commented 8 years ago

Could you try with latest master ? There have been some changes in the loader for STM32L0xx. It seems a different problem but maybe it works. As stated by the libusb documentation itself, it seems another application has claimed the usb device: libusb_set_configuration doc. I'm not sure which causes this. Could you check /etc/udev* folder if there are rules which probably claim the device?

multivac61 commented 8 years ago

The only file now in /etc/udev/rules.d is 49-stlinkv2.rules and I've executed the udevadm commands as well. On the latest master I get the exact same error

sudo ./st-util 
setting new configuration (0 -> 1)
2016-06-06T09:59:43 WARN src/usb.c: libusb_set_configuration() failed
[!] send_recv
2016-06-06T09:59:43 INFO src/gdbserver/gdb-server.c: Chip ID is 00000000, Core ID is  00000000.
[!] send_recv
2016-06-06T09:59:43 INFO src/gdbserver/gdb-server.c: Listening at *:4242...

I also found out that I am not able to run this command unless the ST dev board is connected to the computer, otherwise I get the following error:

2016-06-06T10:01:20 WARN src/usb.c: Couldn't find any ST-Link/V2 devices

which I guess makes sense..

xor-gate commented 8 years ago

I have no real clue what causes the problem. Have you tried st-info --probe ?

multivac61 commented 8 years ago

When running st-info --probe I get Found 1 stlink programmers.

xor-gate commented 8 years ago

It seems the programmer is claimed when found. It should show something like this (on my stm32l1 discovery):

Jerrys-MacBook-Pro:stm32l1-discovery-basic-template jerry$ ../texane_stlink/build/st-info --probe
Found 1 stlink programmers
 serial: 503f7206506752553329033f
openocd: "\x50\x3f\x72\x06\x50\x67\x52\x55\x33\x29\x03\x3f"
  flash: 262144 (pagesize: 256)
   sram: 32768
 chipid: 0x0427
  descr: L1 Medium-Plus-density device
multivac61 commented 8 years ago

Found the bug... When I run dmesg | tail after plugging in my development board I got this error message:

[  583.583636] usb 1-3: new full-speed USB device number 11 using xhci_hcd
[  583.713138] usb 1-3: New USB device found, idVendor=0483, idProduct=374b
[  583.713147] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  583.713151] usb 1-3: Product: STM32 STLink
[  583.713155] usb 1-3: Manufacturer: STMicroelectronics
[  583.713158] usb 1-3: SerialNumber: 0670FF495056805087193849
[  583.713556] usb 1-3: ep 0x84 - rounding interval to 1024 microframes, ep desc says 2040 microframes
[  583.714124] usb 1-3: can't set config #1, error -71

which meant that the kernel wasn't picking up the device. Googled around for similar bugs and tried another usb cable. Now the kernel picks up the board and the output from st-util is the following:

sudo ./st-util 
2016-06-07T11:18:39 INFO src/common.c: Loading device parameters....
2016-06-07T11:18:39 INFO src/common.c: Device connected is: L152RE, id 0x10006437
2016-06-07T11:18:39 INFO src/common.c: SRAM size: 0x14000 bytes (80 KiB), Flash: 0x80000 bytes (512 KiB) in pages of 256 bytes
2016-06-07T11:18:39 INFO src/gdbserver/gdb-server.c: Chip ID is 00000437, Core ID is  2ba01477.
2016-06-07T11:18:39 INFO src/gdbserver/gdb-server.c: Target voltage is 3238 mV.
2016-06-07T11:18:39 INFO src/gdbserver/gdb-server.c: Listening at *:4242...

Thanks for the help @xor-gate, appreciate it!

xor-gate commented 8 years ago

I'm happy it has finaly been found. Sometimes it takes some investigation. Thank you for your contribution!