5 years, 7 months ago.

Get USB to Work on DISCO-F429ZI

I am trying a very simple example:

#include "mbed.h"
#include "USBSerial.h"
USBSerial serial;
int main() { while (1); }

In theory, that should enable the USB Hardware as CDC Device and allow Windows to find it (at least). Note: USBHid or any other Devicetype shows exactly the same behaviour.

Issues: 1. MBED runs into a halt: "This board does not have a hardware USB driver" (mbed_usb_phy.cpp:26). This can be fixed easily by changing the file "tragets.json" adding "USBDEVICE" to the "device_has_add"-List for the DISCO-F429 board. Then, it runs at least, but still does not enumerate in windows. 2. Now, windows at least recognizes that there is something hanging at the USB port and tries to enumerate it, but it cannot be recognized. The "USB Device Tree Viewer" says that there was an error requesting the device description.

Running the same Board with a CubeMX generated basic project works fine, so it clearly is no Hardware issue. I also tried the identical code on the Nucleo-F429ZI (same µC, different PCB and preipheral connections) and it works as expected beeing recognized in Windows immediately.

To dig deeper, I tried to replace all USB related HAL-Files (that I recognized) by known working versions from the CubeMX generated code without any success. Debugging showed that the USB related IRQ gets executed several times, but I don't see what's wrong. It never calls the function providing the descriptor data.

To me, it looks like that there is a issue with the USB-HS Module that is used here instead of the typically used USB-FS Module (e.g. on the Nucleo-F429ZI). The MBED code supports the USB-HS-Module, but inside the code itself, it looks more like a place-holder, e.g. The HS-Module has a much larger FIFO Memory, but the code only uses the amount that is also available in the FS-Modules. Replacing that part of the code by the cubeMX generated code also did not help. Maybe there is something else that is missing for USB-HS.

Any hint would be highly appreciated.

Thanks,

Thomas

Question relating to:

The STM32F429 Discovery kit (STM32F429I-DISC1) allows users to easily develop applications with the STM32F429 high-performance MCUs with ARM®Cortex®-M4 core.

It seems that I found solution. If a add next idle hook asign to empty function USB detected properly: rtos::Kernel::attach_idle_hook(my_idle_hook);

posted by Slava Popov 02 Jul 2019

Can you post an example? I tried that idle_hook on my Disco429 but it did not work, but maybe I did it wrong.

posted by Thomas Buck 02 Jul 2019

My main.cpp

#include "mbed.h"
#include "USBCDC_ECM.h"

/* Ethernet II frame */
typedef struct {
    uint8_t dst_mac[6];
    uint8_t src_mac[6];
    uint16_t eth_type;
    char payload[12];
} packet_t;

static packet_t packet = {
    .dst_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
    .src_mac = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc},
    .eth_type = 0xaaaa, /* unused EtherType */
    .payload = "Hello world"
};

void my_idle_hook() {

}

int main()
{
  rtos::Kernel::attach_idle_hook(my_idle_hook);

  USBCDC_ECM ecm;
  while (true) {
    ecm.send((uint8_t *)&packet, sizeof(packet));
    wait(1.0);
  }
}
posted by Slava Popov 03 Jul 2019

1 Answer

5 years, 5 months ago.

Have the same issue but with STM32F446VE. Did you find solution?

Accepted Answer

No, not yet. I gave up and use FreeRTOS from CubeMX, but I am not happy with it.

posted by Thomas Buck 30 Jun 2019