How to enable end users to reprogram MCU without an IDE

nicolas_soundforce
Sun Apr 15, 2018 5:23 pm
Hi guys,

This is a bit of a dream and I am wondering if it would be possible and also how to get started.
I am using this fantastic Arduino core to program STM32F103’s in some products I am making. All the MCUs are programmed with the bootloader.

Imagine I would like to develop an application for users to reprogram the MCU “in the field”. I would deliver them with the file of the compiled program.

I would like to make a simple program where they can load the .bin in the MCU to update/upgrade the firmware. But I also found out about a STM32 driver that allows the user to reprogram the MCU from a sd card.

How would I start doing something like that ? I am willing to put the time in this and make it available.

The goal is to avoid having to ask users to use external programs or instal an IDE etc…

Thanks in advance,
Nicolas.


stevestrong
Sun Apr 15, 2018 8:04 pm
Maybe this can be of interest: viewtopic.php?f=19&t=3003.

Or this: viewtopic.php?f=2&t=3493


nicolas_soundforce
Mon Apr 16, 2018 6:08 am
Thanks Steven.

Yesterday I found a device that uses STM32 and advertised the possibility of updating the firmware using an sd card.
After googling I found this stm32 document :
http://www.st.com/content/ccc/resource/ … 282546.pdf


stevestrong
Mon Apr 16, 2018 9:02 am
But you know that it reserves 45kB only for the IAP loader…

edogaldo
Mon Apr 16, 2018 8:58 pm
Hi Nicolas, maybe I’m missing the point but looks like you want to develop a new upload tool, correct?
If yes, my question is: since there are already several existing (at least one for each upload method), why developing a new one? What’s wrong with the existing ones?

Best, E.


RogerClark
Mon Apr 16, 2018 9:14 pm
The IDE just runs bat or jar files in the tools folder

You could easily write a wrapper tool to use these, albeit the jar needs java to be installed, so you should not use that.

All you need to do is send the magic reset command via serial and then run dfu util

However both the Serial need drivers to be installed

If you change the bootloader to the brand new HID bootloader that has been posted on the form, you would not need to install a driver for the upload but if you use serial you would still need a driver.

Ps, the hid bootloader was only posted a few days ago, so still needs some finessing by its author


nicolas_soundforce
Wed Apr 18, 2018 3:33 pm
[stevestrong – Mon Apr 16, 2018 9:02 am] –
But you know that it reserves 45kB only for the IAP loader…

I wasn’t aware… thanks for pointing it out. I guess it is just viable for the biggest chips, F4 and such.


nicolas_soundforce
Wed Apr 18, 2018 3:36 pm
[RogerClark – Mon Apr 16, 2018 9:14 pm] –
The IDE just runs bat or jar files in the tools folder

You could easily write a wrapper tool to use these, albeit the jar needs java to be installed, so you should not use that.

All you need to do is send the magic reset command via serial and then run dfu util

However both the Serial need drivers to be installed

If you change the bootloader to the brand new HID bootloader that has been posted on the form, you would not need to install a driver for the upload but if you use serial you would still need a driver.

Ps, the hid bootloader was only posted a few days ago, so still needs some finessing by its author

This is great news, I will lookout for the new HID bootloader.

EDIT: looks great but need to access the jumpers… I would like to be able to reprogram without accessing the PCB. The USB bootloader does work for that at the moment.


nicolas_soundforce
Wed Apr 18, 2018 3:36 pm
[edogaldo – Mon Apr 16, 2018 8:58 pm] –
Hi Nicolas, maybe I’m missing the point but looks like you want to develop a new upload tool, correct?
If yes, my question is: since there are already several existing (at least one for each upload method), why developing a new one? What’s wrong with the existing ones?

Best, E.

I just want to make a small app to upload the .bin program file to the chip, without having to ask the user to isntall IDE/drivers/libraries…


RogerClark
Wed Apr 18, 2018 9:20 pm
The HID bootloader would work if you modified it to use a timeout like the existing bootloaders do

nicolas_soundforce
Mon Jul 23, 2018 6:48 pm
I am working on this and I acheived some succes with the serial upload method.
I used Electron : https://electronjs.org/ as I didn’t want to learn too many cross-platform specific things and wanted get something simple going on very fast.

I am able to list serial ports, run the script and display the console messages.

Script :

#!/bin/bash
cd "$(dirname "$0")"
./serial_upload cu.SLAB_USBtoUART {upload.altID} {upload.usbID} ./firmware.bin


zoomx
Fri Jul 27, 2018 2:49 pm
I believe that you can use the same utility used by the IDE.

nicolas_soundforce
Wed Dec 19, 2018 1:19 pm
So I finally got satisfiying results. I spent quite some time to develop an app that runs a script using Electron. It all worked until I tried to distribute the app and then it all started to go wrong, all that time writing code for nothing…

So I took a much simpler approach:

On MAC:

– I first request my users to install homebrew and then libusb
– I made an “app” using Platypus that allows me to embed a script and needed files (as found under Arduino_STM32-master/tools/macosx) into a standard mac applications.

The Platypus generated app runs this script (similar to what the Arduino IDE does) :
./maple_upload cu.SLAB_USBtoUART 2 1EAF:0003 ./my_firmware_file.bin

All the scripts and the firmware file are at the root and can be accessed by the app. I can even set an image for the icon.
The app displays the output messages from the script. So the user can know if the upload was successful or not.


On Windows:

– I first request my user to install the drivers (as found in Arduino_STM32-master/drivers/win) for the DFU upload and JAVA
– I then ask them to run the script below that opens a console in Windows :

maple_upload cu.SLAB_USBtoUART 2 1EAF:0003 SFC_1_V1.0.ino.bin

In the same folder I included the “maple_upload”, “maple_loader” , etc… as found under Arduino_STM32-master/tools/win

It’s not classy but it works. I looked at Kivy for Python but I don’t have the resources to start learning a new platform from scratch.


Leave a Reply

Your email address will not be published. Required fields are marked *