
Updating STM32 Over-The-Air using ESP32 - huntik17
https://github.com/laukik-hase/OTA_update_STM32_using_ESP32
======
markrages
Or you can use an esp8266 module as a full debugger for the STM32:

[https://github.com/markrages/blackmagic/blob/esp8266/src/pla...](https://github.com/markrages/blackmagic/blob/esp8266/src/platforms/esp8266/Readme.md)

~~~
renw0rp
thanks for the link! I have some never used esp8266 laying around! I might try
to use it for my stm32 tinkering! (I have a couple of discovery boards around
as well)

------
ArgyleSound
Sorry if this question sounds stupid but why not just use the ESP32 for
whatever the STM32 is being used for? It can even update itself over the air.

~~~
LeifCarrotson
Better support, documentation, and peripherals.

The ESP32 datasheet is 62 pages. The STM32F4 datasheet is 1729 pages, and
that's not counting the reference manuals.

The ESP32 datasheet contains about 3 paragraphs about the ADC, which basically
say that it has an accuracy of +/-6%, see example code for ways to calibrate
it (which probably amounts to a linear interpolation between two sample counts
with the pin pulled to ground and AVDD). In the STM32 manual, the section on
the ADCs is much longer than the entire ESP32 datasheet, and goes into gory
details about every possible nonlinearity/ missing counts/ slope/ offset/
noise/ reference voltage and other various potential sources of error you
might encounter. If you wanted to build, for example, a wireless machine that
included a precision scale, you can see why you'd want to use the STM32F4 ADC
instead of the ESP32 ADC because a thorough understanding of that peripheral
is critical to your application.

If you want to drop in someone else's ESP32 code and use it to push bytes over
the air, it's a great tool. If you want to actually develop some application
for it that doesn't exist yet, you're on your own.

~~~
monocasa
If you're throwing an ESP on there anywhere, wouldn't an I2C or SPI ADC be way
cheaper than a whole nother MPU for the same performance?

~~~
magicalhippo
Actually not that clear cut.

You can get a small STM32 with multiple multiplexed 12bit ADC channels, with
~2MSPS sampling speed and 256x hardware oversampling (~16bit), for less than
half a buck (per 1000)[1].

Cheapest independent 12bit ADC with >500kSPS I could find on DigiKey were all
over a buck (per 1000)[2], and they were all single-channel parts.

Now keep in mind that the ADC only does ADC, while the STM32G030 has several
16bit hardware timers and other peripherals.

[1]: [https://www.digikey.com/product-
detail/en/stmicroelectronics...](https://www.digikey.com/product-
detail/en/stmicroelectronics/STM32G030J6M6/497-STM32G030J6M6-ND/10326687)

[2]: [https://www.digikey.com/products/en/integrated-circuits-
ics/...](https://www.digikey.com/products/en/integrated-circuits-ics/data-
acquisition-analog-to-digital-converters-
adc/700?FV=-8%7C700%2C153%7C80383%2C348%7C120395%2C348%7C126808%2C348%7C131756%2C348%7C136065%2C348%7C156878%2C348%7C157986%2C348%7C160758%2C348%7C164419%2C348%7C164927%2C348%7C165029%2C348%7C168185%2C348%7C176195%2C348%7C182208%2C348%7C183408%2C348%7C185640%2C348%7C185641%2C348%7C185700%2C348%7C189593%2C348%7C189876%2C348%7C192939%2C348%7C193713%2C348%7C201015%2C348%7C202083%2C348%7C206099%2C348%7C208339%2C348%7C213218%2C348%7C216279%2C348%7C217160%2C348%7C221250%2C348%7C221734%2C348%7C221802%2C348%7C227807%2C348%7C236685%2C348%7C239323%2C348%7C240171%2C348%7C240493%2C348%7C242056%2C348%7C243182%2C348%7C243507%2C348%7C245510%2C348%7C246482%2C348%7C248579%2C348%7C255826%2C348%7C259241%2C348%7C259901%2C348%7C262355%2C348%7C263681%2C348%7C264156%2C348%7C264936%2C348%7C266776%2C348%7C270610%2C348%7C272940%2C348%7C275927%2C348%7C277406%2C348%7C286202%2C348%7C294333%2C348%7C299143%2C348%7C299411%2C348%7C41520%2C348%7C42950%2C348%7C45085%2C348%7C45645%2C348%7C47366%2C348%7C48535%2C348%7C49825%2C348%7C55277%2C348%7C57541%2C348%7C58694%2C348%7C61021%2C348%7C73556%2C1989%7C0&quantity=1000&ColumnSort=1000011&page=1&pageSize=25)

~~~
derefr
What're the comparative impacts on battery life of those?

~~~
magicalhippo
Kinda hard to compare, since the external ADC doesn't do much without speaking
to a microcontroller...

The STMG030 running full tilt at 64MHz, with ADC and one timer (4 channels)
enabled takes about 6.7mA at 3.3V according to the simulator.

However looking at consumption in the sim with and without the ADC enabled at
full speed, the ADC peripheral itself seems to consume a bit over 100uA. In
comparison the ADS7042 datasheet says about 200uA at 1MSPS.

I haven't hooked up the STM32G030 (just got some), so I can't verify the
simulator. Would be a fun project though.

Of course the STM32 has power-saving sleep modes etc, which reduces the
overall chip consumption to a few uA.

------
rounakdatta
Well, coincidentally, I too did the same project recently and even wrote a
documentation for it - might want to give it a read ;)
[https://rounakdatta.github.io/ota-update-
stm32-esp32.html](https://rounakdatta.github.io/ota-update-stm32-esp32.html)

------
huntik17
Sorry, for going a little off topic here but the same implementation was also
done for AVR MCUs (include the famous Arduino UNO & MEGA). Feel free to check
it out here -

[https://github.com/laukik-
hase/OTA_update_AVR_using_ESP32](https://github.com/laukik-
hase/OTA_update_AVR_using_ESP32)

------
huntik17
Enable firmware update of STM32Fxx series MCUs (includes the famous BluePill)
Over-the-Air using ESP32.

~~~
pantalaimon
Actually you can do that with RIOT-OS (and probably Zephyr too) if you attach
an SPI radio or Ethernet module.

[https://github.com/RIOT-
OS/RIOT/tree/master/examples/suit_up...](https://github.com/RIOT-
OS/RIOT/tree/master/examples/suit_update)

------
agustamir
Cool project! If I need physical access to the board, why would I not program
it with a physical interface

~~~
brokenmachine
Why do you need physical access to use this?

~~~
agustamir
for switching BOOT0, reset etc?

~~~
huntik17
You can automate that using flipflops or maybe MOSFETs.

~~~
agustamir
Not my point though. Use case for over the air update is when one has no
access to the device or its debug interfaces. So, the implementation must
provide for a way to remotely handle entering programming mode, etc. IMO, the
disclaimer section should be a part of the implementation.

~~~
brokenmachine
You're entitled to your opinion.

My opinion is that if you read the page, which is only like 10 paragraphs
anyway, you can clearly see how it works and decide for yourself if it's
useful for you.

