cancel
Showing results for 
Search instead for 
Did you mean: 

USB-UART STM32L0

SARTHAK KELAPURE
Associate II
Posted on February 21, 2018 at 12:41

Whenever we connect a DISCOVERY KIT to computer via USB, we see a drive by the same name as the controller. How is this achieved? 

Also, it allows drag and drop of .bin files for flash. How can this be achieved?

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on February 21, 2018 at 13:10

It's a part of mbed specification (disk abstraction provided by the st-link) to simplify device programming:

https://os.mbed.com/handbook/How-mbed-works#how-programming-works

 How programming works

When you plug in an mbed Microcontroller in to your PC using USB, it appears like a USB flash disk. This small disk is presented by the mbed Interface, and allows you to save ARM microcontroller binaries you want to run directly on to the mbed, without needing drivers. Note that when you save a binary file to the mbed disk, it is not immediately loaded in to the internal microcontroller FLASH memory.

When you hit reset, the

https://os.mbed.com/handbook/mbed-interface

looks at the disk for the newest .bin file it can find. If there is a new file, it will load it in to the microcontroller's internal FLASH memory using the JTAG interface. If the newest binary is already loaded, it won't load it again. It then starts the microcontroller running.

This means if you hit reset again, it will simply reset the target microcontroller and start it running again, as the latest binary is already loaded.

If there is no binary on the mbed disk, the target microcontroller will simply be kept held in reset.

View solution in original post

9 REPLIES 9
Posted on February 21, 2018 at 12:59

It is a faux MSC presented by the ST-LINK's STM32F103 to allow flashing of the part it has as a target. This is how it implements mbed flashing. ie it pretends to be a drive with a FAT file system

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 21, 2018 at 13:10

It's a part of mbed specification (disk abstraction provided by the st-link) to simplify device programming:

https://os.mbed.com/handbook/How-mbed-works#how-programming-works

 How programming works

When you plug in an mbed Microcontroller in to your PC using USB, it appears like a USB flash disk. This small disk is presented by the mbed Interface, and allows you to save ARM microcontroller binaries you want to run directly on to the mbed, without needing drivers. Note that when you save a binary file to the mbed disk, it is not immediately loaded in to the internal microcontroller FLASH memory.

When you hit reset, the

https://os.mbed.com/handbook/mbed-interface

looks at the disk for the newest .bin file it can find. If there is a new file, it will load it in to the microcontroller's internal FLASH memory using the JTAG interface. If the newest binary is already loaded, it won't load it again. It then starts the microcontroller running.

This means if you hit reset again, it will simply reset the target microcontroller and start it running again, as the latest binary is already loaded.

If there is no binary on the mbed disk, the target microcontroller will simply be kept held in reset.

Andrew Neil
Evangelist III
Posted on February 21, 2018 at 13:18

Just to note that the title of this thread is, 'USB-UART STM32L0' - but the drive functionality discussed is something entirely different from the USB-UART virtual serial port!

Posted on February 21, 2018 at 13:16

There's been a few threads here asking if this pseudo-drive can be accessed from the Target.

IIRC, the answer is, 'No' for ST boards (but some other mbed implementations do support it).

Posted on February 21, 2018 at 13:26

That's why it's important always ask yourself or others how do things work (under the hood).

SARTHAK KELAPURE
Associate II
Posted on February 22, 2018 at 09:39

Does this mean, connecting to STM32 using USB will need a dummy extra STM32?

Also, If connecting USB to a UART from STM will need an extra USB-UART IC(say FTDI's FT series)?
Posted on February 22, 2018 at 09:49

Your original question was specifically about the Discovery Kit.

If you look at the User Manual for the discovery kit, you will see a diagram like this:

0690X00000609mSQAQ.png

The box marked ''Embedded ST-Link/V2-1'' is what provides the USB connection to your PC

0690X00000609mTQAQ.png

If you want to directly connect your target STM32 to USB, then you will ned:

  1. An STM32 with built-in USB hardware;
  2. The appropriate USB software stack on the target STM32

The diagram doesn't show it, but the Virtual COM port works like this:

0690X00000609mhQAA.png
Posted on February 22, 2018 at 09:50

I see the following options

1. TARGET MCU(UART)--------------USB-UART-converter---------------------(USB)PC

2. TARGET MCU(UART)--------------ST-LINK-------------------------------------(USB)PC

3. TARGET MCU(USB)----------------------------------------------------------------(USB)PC

Option 2 is popular on nucleo/discovery boards as they have build-in st-link

Posted on February 22, 2018 at 10:20

Perhaps this helps to distinguish the USB connection via the on-board ST-Link from the Target microcontroller's own USB connection:

0690X00000609NYQAY.png

See:

https://community.st.com/0D50X00009XkfBTSAZ