2018-02-21 03:41 AM
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?
Solved! Go to Solution.
2018-02-21 04:10 AM
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 worksWhen 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.
2018-02-21 03:59 AM
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
2018-02-21 04:10 AM
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 worksWhen 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.
2018-02-21 04:18 AM
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!
2018-02-21 05:16 AM
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).
2018-02-21 05:26 AM
That's why it's important always ask yourself or others how do things work (under the hood).
2018-02-22 12:39 AM
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)?2018-02-22 01:49 AM
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:
The box marked ''Embedded ST-Link/V2-1'' is what provides the USB connection to your PC
If you want to directly connect your target STM32 to USB, then you will ned:
The diagram doesn't show it, but the Virtual COM port works like this:
2018-02-22 01:50 AM
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
2018-02-22 02:20 AM
Perhaps this helps to distinguish the USB connection via the on-board ST-Link from the Target microcontroller's own USB connection:
See: