cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f7 USB Host controlling 4G Modem

Danish1
Lead II
Posted on December 18, 2017 at 15:55

I'm trying to link my stm32f7 to a Telit LE910 modem over USB. I can already do this over a UART but I want to increase the data rate.

My hope is to use the stm32 USB Host CDC drivers.

I can enumerate the device and I see:

No shield USBH library started. Starting MSC Demo Starting MSC Demo USB Device Attached PID: 1201h VID: 1bc7h Address (&sharp1) assigned. Manufacturer : Android Product : Android Serial Number : 0123456789ABCDEF Enumeration done.

This device has only 1 configuration. Default configuration set. No registered class for this device which wants ff.

In order to link a Linux system to this modem, you're supposed to add the Telit Vendor-ID, Product-ID (i.e. 1bc7:1201) combination into /sys/bus/usb-serial/drivers and then tell ppp to use that USB serial interface.

To my naive way of thinking, this tells me that Linux should be able to talk to the modem using a standard protocol (my guess is CDC) and start talking AT commands to it.

The device class of the modem is 0xff which means vendor-specifc. And yet Linux only needs to be told to use its usb-serial driver. So the question then is how might I associate the modem's VID:PID pair with the CDC interface? I don't see a way without e.g. editing usbh_core.c yet I'd have thought it's a relatively common task.

USBH_StatusTypeDef  USBH_Process(USBH_HandleTypeDef *phost)

  case HOST_CHECK_CLASS:

The modem reveals 7 interfaces. So after that I'd need to pick out the right interface and endpoint. But none of them are USB CDC. All have Class 0xFF, subclasses:protocols are 0xFF:0xFF, 0x42:0x01, 0xFF:0xFF, 0x00:0x00

, 0x00:0x00

, 0x00:0x00

, 0x00:0x00

So I'd probably also need to hack USBH_FindInterface as well.

Has anyone been down this path who is willing to share information?

Thanks in advance,

Danish

#cdc #usb-host #usb-cube-host-cdc #modem
22 REPLIES 22
Danish1
Lead II
Posted on December 19, 2017 at 12:41

Telit modems with this PID use the Qualcomm-proprietary QMI protocol, for which there is a Linux driver according to their Linux user guide.

Doug Kehn
Senior
Posted on December 19, 2017 at 14:07

Are you using CubeMX?

In any case, somewhere USBH_Init(), USBH_RegisterClass(), and USBH_Start() need to be called to get the USB Host peripheral up and running. USBH_RegisterClass() needs a USBH_ClassTypeDef. USBH_ClassTypeDef is where you can initialize the callbacks needed to enumerate and interface with the Telit modem. The (*Init) function is what you are interested in. (*Init) can validate the VID/PID, select interface, open pipes, etc. USBH_FindInterface() can be called; but, it really doesn't need to be since there is only one interface. No, hacking of HAL is needed.

Look at the example code in the Firmware Library.

Posted on December 19, 2017 at 14:38

Thanks for that.

I started with STM32Cube_FW_F7_V1.7.0

From what I can see, USBH_Process() chooses a driver only on the basis of

phost->device.CfgDesc.Itf_Desc[0].bInterfaceClass

even when the 

bInterfaceClass is 0xFF i.e. vendor-specific.

So for this project, which only has the one vendor-specific USB device that can be attached, I can write my own modem driver and register the modem driver to have the interface-class of 0xFF and let USBH_Process tie them together.

I was hoping to piggy-back on top of the CDC driver, but if I have to write my own then so be it.

 - Danish

mark_dubo
Associate II

Hi,

Wondering if you got anywhere with this? I am using a SIM7100 modem, which use a Qualcomm chipset. Similarly to you we can talk to the modem over the UART connection, but the speed is not high enough for our application so we need to connect over the USB interface. SIMCOM provide windows and linux drivers for their module, but I haven't found any information which will allow us to write our own drivers for the STM32.

Would be interested to hear your progress.

Thanks

-Mark

No, sorry. I have not put any more effort into this so far - too many higher-priority issues.

Regards,

Danish

Pavel A.
Evangelist III

@mark_dubo​ You wrote that a Linux driver exists for this device. Is the source available? If yes, this is *the* information. Find a consultant (contractor) to do the porting work, if it is too hard or too boring.

-- pa

What speed do you actually need, the UART on the modem is probably good to a few Mbaud.

Writing a USB Host driver is not for the meek, and the STM32 ihas limited end-points. Why aren't you just using a low end embedded linux box for the task?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Everyone will say "as fast as you can get". No I know that's not a useful answer.

I'm currently running at 921600 bits/s which I have found reliable. A 4G link should be capable of several times that.

Telit LE910 claim support for faster rates (2900000, 3200000, 3686400, 4000000) but I did not find them reliable. I don't think it was baud-rate error, or limited slew rate either before or after the level-shifter (both checked by 'scope; for rate comparing TX and RX). It could have been issues with PPP on LWIP - I have not re-checked since upgrading to 2.1.2. Or maybe the version of LE910 or its firmware; I didn't re-check on LE910v2.

But sometimes I want a second channel to issue some AT commands e.g. to do with GPS, without having to escape out of the PPP stream. And USB could have multiple virtual serial ports.

Danish

We are running the UART at 4M, but it's still not fast enough. One of the problems being, after sending a packet of data (1.5k max I think), we should wait for an acknowledgment from the module. This can take over 20ms.