Author Topic: STM32U5 USB Mass Storage with some external QSPI or SPI flash  (Read 474 times)

0 Members and 1 Guest are viewing this topic.

Offline uer166Topic starter

  • Frequent Contributor
  • **
  • Posts: 961
  • Country: us
STM32U5 USB Mass Storage with some external QSPI or SPI flash
« on: September 07, 2024, 01:35:38 am »
I have a need for a device where: FW updates, map updates, and log extraction could be done by connecting it to a PC, and appearing as a USB stick.

The memory requirements are modest: maybe 8-64MB or so. Does anyone have any experience with such a system? Currently my FW architecture is a ISR superloop, and would love to keep it that way if possible (no FreeRTOS). Code simplicity/line count counts for a lot in this project.
On the hardware side I could use a single SPI or maybe QSPI flash memory, but other suggestions are welcome.
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3995
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32U5 USB Mass Storage with some external QSPI or SPI flash
« Reply #1 on: September 07, 2024, 09:55:43 pm »
I have a 32F417 project which has a 4MB Adesto SPI FLASH, 512 byte sectors, AT45DB321E, and you can have various device profiles on the USB client. In my case I have CDC (VCP port) and MSC (2MB FAT12 removable drive).

USB MSC is what you want.

ST Cube MX can generate most of the code for you for MSC profile, and you just need to write the interface to your FLASH. The above device is ideal because Windows wants to see 512 byte sectors.

Still, a fair bit of work, but MSC is a lot easier than CDC.

I posted various threads here about this, a few years ago. Sector write is 15ms, read is about 200us. If you dig them out, that will help you. Bits of code there, also how to implement a Busy state to the host.

The entire ST USB code is interrupt driven so you don't need an RTOS for that.

« Last Edit: September 07, 2024, 09:58:13 pm by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 
The following users thanked this post: uer166

Offline uer166Topic starter

  • Frequent Contributor
  • **
  • Posts: 961
  • Country: us
Re: STM32U5 USB Mass Storage with some external QSPI or SPI flash
« Reply #2 on: September 07, 2024, 10:59:23 pm »
Any reason for FAT12? I'm reading about the support for it in latest Windows being iffy after Win10.

 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3995
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32U5 USB Mass Storage with some external QSPI or SPI flash
« Reply #3 on: September 08, 2024, 05:42:15 am »
If you do 2MB then it has to be FAT12. If you can do 4MB then you can do FAT16, IIRC.

Not heard of Windows stopping support of FAT12 on removable drives. On system partitions, sure. I did a dig around and all I can find is this
https://answers.microsoft.com/en-us/windows/forum/all/a-change-in-fat12-file-system-from-xp-to-7/ad9e6c73-6561-e011-8dfc-68b599b31bf5
which should not affect you.
« Last Edit: September 08, 2024, 06:43:25 am by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline Njk

  • Frequent Contributor
  • **
  • Posts: 294
  • Country: ru
Re: STM32U5 USB Mass Storage with some external QSPI or SPI flash
« Reply #4 on: September 13, 2024, 01:28:03 pm »
Done that many years ago with an 8-bit MCU and SPI flash. With no OS, of course. It must be easier now because of existing pre-built libraries.

IIRC, USB MSC is a very short document, actually a stub. Basically, it states that the mass storage device shall be accessible with SCSI commands over USB. So you'll have to implement an SCSI server according to the T10 specification.
« Last Edit: September 13, 2024, 01:30:08 pm by Njk »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf