cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4R7 USB device composite CDC + MSC and File System

ALohr.1
Associate II

I am in the process of building quite a complex device requiring many features all bundled into one unit. Generally speaking, the device needs to be seamlessly connected to the PC for both debugging and file transfer/storage. I've done some digging and I can't find much information that is relevant to the system I have in mind.

The device in question contains a STM32L4R7 MCU with an external NAND flash memory attached to its FMC interface (as well as a swath of other hardware). More specifically I'd like to have the following features:

  • Through development (and for further support) I'd like to have the device appear as a standard CDC port on the PC for displaying debug information as well as accepting commands.
  • It would be ideal to use the USB MSC device class to allow for easy access to the external flash memory from a PC (Ie. drag and drop files in/out).
  • The external flash will store configuration files, data logs, etc. on a standard file system (FAT32 or similar)
  • MCU to interface with the external flash using File System API (to read config files, create new files, etc)
  • Changes that the MCU makes to the memory will be reflected when viewed on PC. I know that the PC and MCU access have to be strictly controlled, so I'm hoping that the USB API will allow me to deny the MCU access to the memory when plugged into PC.

Is this sort of set up even possible? I've not seen an example of this similar to what I need anywhere. The only configurations I can think of are the following:

1)  A fully composite CDC + MSC device, then using the ST FAT-FS middleware to access the external flash. This is assuming that the format of ST (or other) File System API compatible with PC

2) CDC and MSB USB device classes are exclusive. Using a hardware switch to enable CDC or MSC mode. Then, again using ST (or other) FS API compatible with PC

3) (if unable to achieve either 1 or 2) Ignore trying to use CDC all together and just use a single device class.

 

The other problem is the firmware.

Due to the complexity of the whole system, I'm most likely going to be using some sort of RTOS to run the device. So, the solution would have to be RTOS compatible. For example, it seems that Azure RTOS has file system API and USB device API, but I've no experience with this. FreeRTOS (which I have used) does have FAT FS library, but no USB device API. I'm not sure if I even need RTOS level API to manage the USB and the File System.

From what I can see in the STM32Cube, I cannot use CDC and MSC at the same time when using the ST library. Is there something I'm missing here when looking through the STM32Cube? Or would I need to setup external libraries to achieve this?

 

In summary, is this setup possible? I don't have enough experience working with USB let alone something as complex as this. If it is possible, what might be the easiest (I can work on performance later) way to implement this in terms of the HAL and RTOS setup?

Thanks for reading.

0 REPLIES 0