December 5, 2020

USB - Sources of information

My sources are several.
We have the chip reference manuals for various STM32 chips.
We have source code for various open source drivers.
We have online articles, books, and the USB specification itself.
We even have videos from ST explaining their USB library.

A variety of projects include source code for F411 and/or F103 chips. (I will begin abbreviating STM32F411 as simply "F411"). All of the projects I have looked at so far include USB libraries written by ST. My study of this code so far indicates that this code was written in what I can only describe as an odd and difficult to read style. And the code I have seen follows an absurd but all too common rule of placing include files in some far away isolated directory. This is both frustrating and a large part of what motivates this project.

There are any number of online tutorials and articles. A person rapidly finds themself immersed in a sea of USB jargon, and it will be a part of my purpose to sort out and explain all of this.

USB is much like a little network, but a network written on the planet Mars. So USB has layers, upper levels handling USB states and lower levels dealing with specific hardware. This is additionally complicated by the fact that USB devices can be "hot plugged", i.e. unplugged at any time.

Projects

The following projects include significant and interesting USB driver code. Of the above, I feel drawn to libusb_stm32 (on first glance) because it is not the "code from hell" that the other projects use from ST.

USB Tutorial

This probably doesn't deserve a whole section all on its own. The first section on USB basics seems pretty good, and his host side schemes may bear looking at. That he is using a "blue pill" is what first drew me to it.

It is an interesting web writeup on USB and microcontrollers. He works with the STM32F103 "blue pill" along with LibOpenCM3.
But trouble starts soon. He uses Visual Studio Code along with PlatformIO as an extension (whatever the heck it is) and writes C++ code (never the right thing for an embedded system).

Articles

"USB Made Simple" is a widely recommended tutorial and I found it very good.

The "Bare Metal" blog works up code for an STM32L052, so it is hard to say how relevant this will be, but his code looks clean and straightforward. The STM32L052 is an ultra low power part (note the "L" in the middle of the part number). It has 32K of flash and 8K of ram and runs at 32 Mhz.

Videos

This popped up on Hackaday and looks pretty good: The following series looks very good at first glance. I find it almost impossible to understand what the person talking is saying. So, if you are willing to simply look at the slides these are useful in a limited way.

Books

I do have a book, but I don't like it much and have not found it terribly useful. I rely less on books these days, but I used to always "want a book" when I started learning about anything.

"USB Complete", by Jan Axelson -- Fourth Edition, 2009, 504 pages.


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org