2018-09-06 07:03 AM
Setup:
(custom hardware based on STM32f373 with a USB A female port)
STM32F407 Discovery Board with additional micro-B to A cable for the USB drive
Keil uVision 5 and STM32CubeMX
What I want to do:
Plug in a USB thumb drive into the USB port to upgrade the firmware on the STM32f373.
This way, the STM32 acts as a USB host and pulls the firmware from the USB drive. I don't want to use a computer to program the microcontroller (using DfuSe).
I am using the STM32F4 discovery with a micro-B to A cable to test this feature before moving to my custom hardware.
What I found out so far:
My questions:
2018-09-06 07:42 AM
> Where are the source code files referenced in AN3990?
[en.stsw-stm32068.zip]\STM32F4-Discovery_FW_V1.1.0\Project\FW_upgrade\
Note that it's based on the older SPL "library", not on Cube.
> Is it true that DFU only works with the microcontroller as a slave?
Yes.
JW
2018-09-06 09:57 AM
MSC != DFU
The MSC Host would permit you to read a DFU file off the media, and act on it. Read the docs on the .DFU format. Done it with DFU files on MicroSD cards here.
HAL Example of reading from USB Flash Stick
STM32Cube_FW_F4_V1.21.0\Projects\STM32F4-Discovery\Applications\FatFs\FatFs_USBDisk\readme.txt
2018-09-06 09:59 AM
All examples I see for F3 are Device, not Host. Check if it supports Host/OTG operation at all.
2018-09-06 01:46 PM
> The MSC Host would permit you to read a DFU file off the media, and act on it.
What's the point, why would be the DFU file format more appropriate than e.g. intelhex?
JW
2018-09-06 02:38 PM
That I don't have to provide something in multiple formats? DFU also has a longitudinal CRC check, integrity can check before starting, and the binary data is easy to manage, addressed, no requirement to parse thousands of lines, with memory that my be sparse and out-of-order.
I could use a ZIP file if I wanted too, got code for that.
2018-09-06 03:32 PM
> That I don't have to provide something in multiple formats?
Yes that might be a point in certain cases. The rest is mostly fulfilled by the more common hex or sfile.
JW
2018-09-06 04:08 PM
With Keil, you can easily get a .bin file.
Enter the following in the project settings, post-make command:
$K\ARM\ARMCC\bin\fromelf.exe --bin --output=$L@L.bin !L
The output file is a plain binary image that begins from the starting flash address in project settings.
A good smart student in our lab did this sort of updater for F4 recently, based on that AN3990 example.
He also produced a python script that appends a header to that binary, with a CRC, version and so on (the updater discards this header after checking the update file).
Then it took me some time to convert it to a normal CubeMX project & USB host & fatfs from the Cube repo.
-- pa
2018-09-06 11:32 PM
> HAL Example of reading from USB Flash Stick
> STM32Cube_FW_F4_V1.21.0\Projects\STM32F4-Discovery\Applications\FatFs\FatFs_USBDisk\readme.txt
Where is this file? I am only able to find cloned stuff on some people's Github accounts.
2018-09-07 01:38 AM
In your CubeMX repository.
JW