Idea for an "end user" bootloader (mass storage device)

Bootloader for boards that don't have the addition hardware found on the Maple mini, which resets the USB
User avatar
Vassilis
Posts: 294
Joined: Thu May 21, 2015 6:42 am
Location: Thessaloniki, Greece
Contact:

Re: Idea for an "end user" bootloader (mass storage device)

Postby Vassilis » Thu Sep 17, 2015 1:14 pm

Maybe using the serial port programming is a good solution for firmware updating your project.
That approach gives you the safety you want to avoid the stm32 brick.
Moreover, the only additional hardware you need is a cheap usb-to-serial converter.

The software for programming the stm32 seams very simple and compact. I have not tested it yet.
https://github.com/MightyDevices/STBootLib/releases

After a second thought, the sequence of pressing the reset and boot0 buttons is not very user-friendly way to do a firmware update.

Anyway, it is up to you what you finally choose. Every uploading method has advantages and disadvantages.

madias
Posts: 812
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Idea for an "end user" bootloader (mass storage device)

Postby madias » Thu Sep 17, 2015 2:45 pm

Looks ok, but Windows only (ok, compiling should be possible for other OS)
Drawback: Nearly all USB-TTL converter need at least under Windows a additional driver.
For my project I can manage it to upload the firmware via MIDI ;) All you need is time and a coffee. So getting via sysex the new firmware, writing it to my 4-mb flash (next to the original firmware) and then update it via software. Another method could be: Just put the firmware on SD card.

User avatar
martinayotte
Posts: 1162
Joined: Mon Apr 27, 2015 1:45 pm

Re: Idea for an "end user" bootloader (mass storage device)

Postby martinayotte » Thu Sep 17, 2015 3:00 pm

Another possibility is to do the opposite : having some USB OTG Mass Storage where end-user simply plug an USB dongle where the new firmware has been uploaded/copied, then the firmware can access to the USB Storage, see that new firmware is present, and offer choice to upgrade thru LCD menu or Serial menu.

victor_pv
Posts: 1061
Joined: Mon Apr 27, 2015 12:12 pm

Re: Idea for an "end user" bootloader (mass storage device)

Postby victor_pv » Fri Sep 18, 2015 12:13 am

madias wrote:Looks ok, but Windows only (ok, compiling should be possible for other OS)
Drawback: Nearly all USB-TTL converter need at least under Windows a additional driver.
For my project I can manage it to upload the firmware via MIDI ;) All you need is time and a coffee. So getting via sysex the new firmware, writing it to my 4-mb flash (next to the original firmware) and then update it via software. Another method could be: Just put the firmware on SD card.


If you are including a 4Mb flash, and have enough space, what I probably do is include the mass storage in your sketch.
If the user writes a file there, the sketch saves it to a reserved area of the 4Mb flash (checking a checksum or something to confirm is all good).
If it is good, then it sets a flag somewhere to indicate new FW is available in the spi flash.

Then in your bootloader, on boot up, just check if there is a new fw in the spi flash, if it is, copy it to the mcu flash (skipping the bootloader area) and clear the flag.

For the user, is as simple as write update file to the mass storage device, reboot device. Done.

As for presenting the masstorage to the computer, it does not need to be there all the time, but only if you press a certain button during boot up, or select an option in a menu. Then the device presents itself as a storage device and waits for the right file to be written to it.

So the user intervention would be such as:
1.-Press certain button or select fw update in menu.
2.-Write fw update file to the mass storage device.
3.-Reboot and let it update.
4.-Reboot again with updated fw.

User avatar
Vassilis
Posts: 294
Joined: Thu May 21, 2015 6:42 am
Location: Thessaloniki, Greece
Contact:

Re: Idea for an "end user" bootloader (mass storage device)

Postby Vassilis » Fri Sep 18, 2015 5:52 am

victor_pv wrote:If you are including a 4Mb flash, and have enough space, what I probably do is include the mass storage in your sketch.
If the user writes a file there, the sketch saves it to a reserved area of the 4Mb flash (checking a checksum or something to confirm is all good).
If it is good, then it sets a flag somewhere to indicate new FW is available in the spi flash.

Then in your bootloader, on boot up, just check if there is a new fw in the spi flash, if it is, copy it to the mcu flash (skipping the bootloader area) and clear the flag.

For the user, is as simple as write update file to the mass storage device, reboot device. Done.

As for presenting the masstorage to the computer, it does not need to be there all the time, but only if you press a certain button during boot up, or select an option in a menu. Then the device presents itself as a storage device and waits for the right file to be written to it.

So the user intervention would be such as:
1.-Press certain button or select fw update in menu.
2.-Write fw update file to the mass storage device.
3.-Reboot and let it update.
4.-Reboot again with updated fw.


The Victor's solution is very nice! You can have also the firmware encrypted for protecting your project from being cloned. The decryption and the programing steps can be done after the firmware is copied to the spi flash (on the next reboot).

User avatar
zoomx
Posts: 366
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Idea for an "end user" bootloader (mass storage device)

Postby zoomx » Fri Sep 18, 2015 10:11 am

Only if the STM32 has a flag to avoid the copy of the internal flash. Otherwise you can decompile the algorytm or run it in a emulator.

victor_pv
Posts: 1061
Joined: Mon Apr 27, 2015 12:12 pm

Re: Idea for an "end user" bootloader (mass storage device)

Postby victor_pv » Fri Sep 18, 2015 11:33 am

zoomx wrote:Only if the STM32 has a flag to avoid the copy of the internal flash. Otherwise you can decompile the algorytm or run it in a emulator.


Internal flash can be protected from read, so Vassilis idea is really good if you want to protect a product while allowing updates.


Return to “Generic bootloader”

Who is online

Users browsing this forum: No registered users and 1 guest