5 years, 11 months ago.

How to use file systems to create LocalFileSystem visible in Windows when USB connected to ST-LINK?

Hello all,

Objective Under Mbed OS 2 there was a great utility called "LocalFileSystem" which provided access to the micro's USB disk drive. This utility doesn't seem to be present under Mbed OS 5, so looking for guidance/tips/references on how to recreate it using the more modern file and storage access under Mbed OS 5.

Many examples use SD cards as example block devices. This unfortunately won't work for my architecture and specifically interested in creating file i/o through the USB connection presented by the ST-LINK interface.

Background The underlying goal I am looking to accomplish is creating file i/o similar to how .bin files are loaded onto Nucelo boards. I would like to host a configuration file (human readable text) which resides on the Nucelo and is visible to the user when the ST-LINK USB is connected. The use case I am trying to address is providing easy access to configuration parameters which can be changed in the field without having to recompile code, etc. The Nucelos aren't easily accessible in our design, so (unfortunately) an SD card solution isn't ideal.

Platform NUCLEO-F446RE

1 Answer

5 years, 11 months ago.

The local filesystem that is visible on the USB socket used for drag & drop programming is only available on the original LCP1768 and LPC11u24 mbed modules. These devices had an EEPROM connected to the flash programmer part that could temporarily hold the bin files or any other filetypes.

The STM boards dont work that way. The ST-Link only appears to be a memory stick, but in fact the bin file you drag&drop is immediately flashed into the target processor (ie the F446 in your example). It is not visible anymore after programming completes. Files that dont have the correct bin format will be rejected. What you can do instead is use the USB device support feature that is provided by the target and use that to emulate a memory stick. The actual data (ie your config file) can be stored on an internal SD card (or EEPROM) that doesnt have to be accessible to a regular user. You may want to block/hide the original ST-Link USB connector and use it only for flashing new code. You need to locate the USB device libs and SD filesystem libs on mbed, add them to your project, add the USB socket wiring, add the SD card & holder wiring and provide a separate powersupply to the target/ST-Link from the new USB socket.

Accepted Answer

+1 for Wim's excellent answer

The LocalFileSystem is still present in mbed-os 5, and is integrated into the FileSystem API just like the other file systems. However as Wim mentioned, it is only available on the LPC1768 and LPC11u24. The more recent interface chips don't have their own storage.

posted by Christopher Haster 25 May 2018