Best Microcontroller family for USB Documentation/Tutorial - Page 1
Forum section: electronics / general

author: MattHollands
author_rank: Frequent Contributor
timestamp: April 15, 2019, 01:09:33 am
content: Hey! I have a project in mind that will need to be a usb mass storage device. I have a book on the usb MSD protocol but it’s a bit old so the hardware is out dated. Can anyone suggest a good 32-bit arm Microcontroller family for writing your own USB device firmware? I’ve tried NXP before but I found their UsB documentation was pretty poor.To be clear, I want don’t want a pre-written MSD driver (although it doesn’t hurt). A) I want to learn more about UsB by writing my own, and B) I have some specific requirements about how SCSI requests are handled.I’m looking for a well documented USB peripheral basically with some good tutorials. Thanks!!

author: westfw
author_rank: Super Contributor
timestamp: April 16, 2019, 08:59:02 am
content: The silence is deafening...FTDI has a nice tutorial on USB (https://www.ftdichip.com/Support/Documents/TechnicalPublications/USBDesignByExample.htm) for their VNC2 chips, but (last I checked) they don't actually document their chip peripheral (or CPU!), so the "bottom level" of the tutorial code is proprietary FTDI libraries. So that's probably not what you want.The NXP USB code is supposed to be more-or-less based on the LUFA code that Dean Camera wrote for the 8bit AVRs (Dean wrote the NXP libraries too, I think?), so I would have thought that that would be better documented than most. But again, I guess it's more about providing an abstraction on top of the particular hardware than extensively explaining the hardware.(http://www.fourwalledcubicle.com/LUFA.php)But perhaps that sort of abstraction is where you want to operate. You don't "implement mass storage for an STM32Fxxx USB peripheral", you implement USB Mass Storage based on Jan Axelson's books, using some USB primitives that you implement separately for each piece of actual hardware... (http://janaxelson.com/usbc.htm)(so... I have read "some" of each of the above references, but I've only gotten to the point where I go "eww! How big was the committee that came up with THIS? Maybe I'll just use the XXX library that's already written that mostly, even though most of their code sucks.")

author: josip
author_rank: Regular Contributor
timestamp: April 16, 2019, 09:41:33 am
content: Quote from: MattHollands on April 15, 2019, 01:09:33 amYou can find explained upper USB layer (functions) for any device, but not explained source code examples on lower level (for example likethis).I didn't know anything about USB, and books only confuse me more, so I take source code of MSP430 USB stack, and inserted (UART) logs everywhere. At the end I wrote my own USB stack from zero in assembler. I am using CDC.Later I switched to Kinetis devices, and done it again, for CM0+ from zero in assembler. MSP430 USB experience help me, but every USB hardware module is different animal, so it was far from copy/paste. I selected Kinetis because I need dual supply (USB module 3.3V supply is different from VDD) and some other things, but identical USB hardware module can be found in Microchip/Atmel devices.Original USB stack source code (for every vendor I know) is bloated and hard to read. And AFAIK, you can find in USB stack from any vendor, USB mass storage device class open source example.

author: colorado.rob
author_rank: Frequent Contributor
timestamp: April 16, 2019, 02:44:13 pm
content: There are lots of example code for USB mass storage on STM32 devices, along with projects and code for many of their Nucleo and Discovery boards.

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 16, 2019, 03:01:45 pm
content: I second the STM32 option.https://www.st.com/resource/en/user_manual/dm00108129.pdf

author: nctnico
author_rank: Super Contributor
timestamp: April 16, 2019, 03:22:18 pm
content: Quote from: MattHollands on April 15, 2019, 01:09:33 amIMHO the NXP Lufa stack is a good place to start. I have used it in a couple of projects as a host. Sure the documentation isn't much to write home about but the structure of the library isn't bad and takes a lot of the low-level USB stuff away. There is plenty left to sink your teeth in. IIRC there is an example of a mass storage driver together with the NXP Lufa stack.Edit: some NXP devices have a USB library in their ROM. It seems NXP's approach is not to let people write their own low-level USB stuff but concentrate on the high level only.

author: rsjsouza
author_rank: Super Contributor
timestamp: April 16, 2019, 03:43:40 pm
content: I am familiar with theTM4C devicesand their USB implementation. They have a very long user's guide about it and, although it talks about their software implementation, IMO it goes into a decent level of functional detail.http://www.ti.com/lit/ug/spmu297d/spmu297d.pdfIf you are also interested in the signaling itself, another device (OMAPL138) has some documents that talk about the compliance checks ad measurements:http://www.ti.com/lit/an/sprab17/sprab17.pdfhttp://www.ti.com/lit/an/sprab50/sprab50.pdfhttp://www.ti.com/lit/an/sprab51/sprab51.pdf

author: badman
author_rank: Newbie
timestamp: April 25, 2019, 06:40:00 pm
content: I also have a MSD project with a unique SCSI requirement. I'm currently portinghttps://github.com/hathach/tinyusbto WCH CH568. I'm just now seeing you said ARM, but this chip is based on the less known NDS32 architecture. I got an evaluation board for free from them but it cost a ton to ship to the US. I've found porting the tinyUSB project to this new chip has helped me learn the USB protocol pretty well. I'd love to hear what your unique SCSI requirement is, PM me.