Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years ago.
Cannot get the Nucleo F401RE to work as a USB device
Hello,
For the life of me, I cannot get the Nucleo F401RE to work as a USB Device.
I have tried running many examples from the official USBDevice library, none of them successfully. After poking around the source code, it seems that the device "hangs" when the USBHal::connect method is called. Internally, the st32f4 usbhal tries to enable an IRQ and... fails? I have no idea.
The thing that bugs me is that, people seem to have made this work. Can anybody guide me through this? Am I missing something here?
Extra info: My connections are as follows: 1) Vcc -> CN7 pin 6 (E5V) (edit: and JP5 set to external voltage) 2) D+ -> CN10 pin 12 (PA12) 3) D- -> CN10 pin 14 (PA11) 4) GND -> CN10 pin 20 (GND)
No capacitors anywhere.
No external crystal in the X3 slot.
I have updated to the latest firmware, using the latest libraries.
If anybody can contribute some knowledge or experience, I'd be grateful!
Question relating to:
2 Answers
10 years ago.
Working here, but only after hooking up VBus to PA9 as well as the GND, D+, D- connections as you have them. I'm powering via CN1.
[58051.716370] usb 1-1.5.7: new full-speed USB device number 82 using dwc_otg [58051.832230] usb 1-1.5.7: New USB device found, idVendor=0021, idProduct=0011 [58051.832251] usb 1-1.5.7: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [58051.832261] usb 1-1.5.7: Product: HID DEVICE [58051.832269] usb 1-1.5.7: Manufacturer: mbed.org [58051.832277] usb 1-1.5.7: SerialNumber: 0123456789 [58051.861803] input: mbed.org HID DEVICE as /devices/platform/bcm2708_usb/usb1/1-1/1-1.5/1-1.5.7/1-1.5.7:1.0/input/input41 [58051.862456] hid-generic 0003:0021:0011.002A: input,hidraw3: USB HID v1.11 Keyboard [mbed.org HID DEVICE] on usb-bcm2708_usb-1.5.7/input0
It's a little unreliable, stopping sending characters after a while, but maybe that's my cabling. Will investigate further...
Hey David,
thanks for answering! So, just to confirm, you power up through the usual USB port of the st-link, and then connect the USB +5V to PA9. I've tried that but still no dice, which leads me to believe that my soldering of the external USB connector is somehow interfering (no shorts when I checked with a multimeter though).
Would you be so kind as to post a picture of your setup, just to have a reference? I'd greatly appreciate that!
Again, thanks a lot, I had almost given up on getting this board to work. Cheers!
posted by 29 Nov 2014Hi Marios. I can't see how to post a picture here, but I can confirm the wiring:
Powering via the mini-B USB (st-link port) All four wires from the USB type A plug attached to CN10: Red wire VBUS to PA9 (CN10-21), Green wire D+ to PA12 (CN10-12), White wire D- to PA11 (CN10-14), Black wire GND to CN10-20.
The USBKeyboard example works, but is by no means reliable, quickly freezing. After a few black-button resets, USB-A re-inserts etc you should see something on screen (& in dmesg if you use linux).
I've noticed some improvement by inserting delays between key-down & key-up events, and between characters. Using keyboard._putc() seems more reliable than keyboard.printf(), but it's early days, and I'm certainly interested to hear how it behaves for others!
posted by 29 Nov 2014Hello again!
So, I slashed up a usb cable, attached some female connectors at the stripped wires, and had the same, partial success! :)
Partial success means: the device is not recognised on Mac OS X, and sometimes works on windows, for a little bit. I used the sample that sends Caps Lock (here: http://developer.mbed.org/handbook/USBKeyboard) , and it locks up after a few seconds.
Moral of the story, I'm not expecting much from this microcontroller any longer. I will try to implement the HID device I had in mind, but in the mean time, I'll be ordering a freescale platform (either the kl25z or the k22z).
Also, Maxime may actually be correct. However, my soldering skills are not up to snuff, and I'd probably destroy the board outright if I tried to connect the c33/c34 caps. Such a pity it doesn't come with the crystal & caps already fitted, it'd be well worth it for a couple of dollars more. :(
So, again, thanks a lot for your help, and for anybody out there considering this board for USB usage, be warned, would not really recommend.
Cheers!
posted by 01 Dec 201410 years ago.
In order to get reliable USB communication, you probably need to use an external crystal. I don't think the internal oscillator is good enough.
Although I've seen people using the board without the external crystal ... I suspect you're right. For anything reliable probably the external oscillator is necessary.
Thanks for contributing!
posted by 01 Dec 2014I think STM32F0xx and STM32L0xx have a crystal-less USB device capability. It works by auto tuning on the host SOF duration. Those devices are low end STM32 (Cortex M0/M0+ core), but it might be enough for a keyboard type of function. They have their own nucleo boards. Otherwise, I am afraid you will need to use your iron..
posted by 01 Dec 2014According to the Nucleo user manual, one of the clocking options is the 8MHZ xtal on the st-link portion of the board - see 5.7.1 "MCO from ST-LINK". Doesn't look too difficult to perform... I assume something needs changing in the mbed lib so that the mcu uses ext clock not internal?
Edit1 : After further digging, it appears I have an older rev C-01 401 board. The newer board is wired for external clock from the st-link's MCO, and is fitted with low speed xtal for rtc. See http://developer.mbed.org/users/kenjiArai/notebook/nucleo-series-clock-structure-and-xtal-oscillation.
I also found http://developer.mbed.org/users/dreschpe/code/ST_401_84MHZ/file/b9343c8b85ec/ST_F401_84MHZ.cpp with info how to change from internal to external clocks.
Edit 2: Marios, if you have a C-02 board, I think you simply need to change the mcu clocking to external for stable 48MHz USB.
posted by 01 Dec 2014Hello David,
this seems like a good find! I have a C-01 board, so I'll try your suggestion of soldering SB16 and SB50 and report my findings. The USB saga continues...
Cheers!
posted by 05 Dec 2014Hi Mario. http://developer.mbed.org/users/kenjiArai/code/Nucleo_F411RE_SysClk/ reports how the mcu is clocked. Run it before/after mod. No code change is necessary, mbed will set up the mcu for ext 8MHz if it is present.
posted by 08 Dec 2014
For posterity, I was able to make a USB HID device using this controller. My opinion of the USB capabilities of this board get a definite "maybe".
Project home: http://developer.mbed.org/users/eimaiosatanas/code/USBJoystick_mod/
posted by MARIOS SATANAS 03 Dec 2014Hi Marios - I put a blob of solder on SB16 & SB50, and now my Nucleo 401 is working reliably as a USB peripheral, no software mods, perfect timing from the st-link's 8MHz crystal :D
posted by David Lowe 04 Dec 2014