7 ms·
Updating STM32 Over-The-Air using ESP32
- deleted 6y ago[deleted]
- huntik17 6y agoEnable firmware update of STM32Fxx series MCUs (includes the famous BluePill) Over-the-Air using ESP32.
- pantalaimon 6y agoActually 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_update https://github.com/RIOT-OS/RIOT/tree/master/examples/suit_up...
- ArgyleSound 6y agoSorry 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.
- nickff 6y agoSTM32 is available with more, and better peripherals and interfaces than the ESP32. Embedded microcontrollers perform a wide variety of tasks, aside from simple digital communication. [0] I am an embedded engineer who works with STM32 and bluetooth modules
- pantalaimon 6y agoThe esp32 has quite a rich set of peripherals on its own.
- nickff 6y agoI would describe the ESP32 as having a basic peripheral set. The ADCs and DACs are not great, and there are basically no other analog peripherals. The timers are meager, and low-power functionality is lacking. The documentation is horrible, which is very important when you compare it to NXP and STM which both put out fantastic 2k-3k page reference manuals.
- pantalaimon 6y agoYes it's a shame. The hardware is quite capable for the price but the documentation is lacking, so one has to resort to reverse-engineering - which is totally ridiculous. Traditional MCU vendors have set quite a high standard to the quality and availability of documentation. I know good documentation takes effort, but the lack thereof is hampering the product. One can only hope that with Espressif trying to become more mainstream, they will improve in that department.
- nickff 6y agoA datasheet is a contract, not just documentation. If they put something on the datasheet, they need to write the document, then test the parameter, and guarantee that performance. If I receive 10k of a part that does not satisfy specified performance parameters, I will return the reels, and never design that manufacturer's parts into any future product.
- garaetjjte 6y agoOh, surely they're not contracts. They're full of disclaimers like: "MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND [..], RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE." And then they publish 50 pages errata including: "Ethernet functionality in 64-pin packages is not available." ...
- nickff 6y ago
- boromi 6y agowhat's your reccomendation ?
- nickff 6y agoDepends on your application and requirements.
- boromi 6y agoJust a basic board comparable to the ESP32 modules you can but for DIY stuff
- nickff 6y agoI generally recommend going for the highest-spec board that suits your requirements. The STM32L4+, STM32L5, and STM32H7 are all amazing microcontrollers.
- renw0rp 6y agoI'm playing with STM32 Cube IDE right now. I got surprised that it works well on Linux (ok, I did only basic stuff, but did not have any trouble setting it up). However I was wondering what would be totally open source toolchain and development setup? That might be too advanced for me now (and I'm happy with graphical peripheral selection in ST tools), but would like to try it in the future
- pantalaimon 6y agogcc and OpenOCD work well. There are plenty of open source projects for STM32 There is https://www.openstm32.org https://www.openstm32.org Also there are plenty of Open Source RTOS projects that come with a HAL, so you can write code that is vendor independent. Zephyr is probably the largest full-featured RTOS, it's backed by the Linux Foundation and several hardware vendors (NXP, Nordic, Intel, Ti and SiFive), but the community provides support for other vendor's chips too. RIOT-OS is more popular in the academic sector, targeting sensor networks. NuttX tries to bring a POSIX environment to your MCU and of course STM32 is supported there too. there is of course ARM Mbed, but that feels more like a framework than an integrated OS. Heck you can even run Linux on the larger STM32s (M4, M7) if you attach some external RAM - kernel support was provided by ST themselves.
- mosselman 6y agoSo this is totally off-topic and a bit you are going to think I am very rude for intruding: I was just looking around whether it is possible to create custom apps (on phones) to sync with smart watches (generic ones from places like aliexpress). I have no experience with bluetooth, but is there anything that would prevent you from making something like that? Even if it is just for myself, I don't need to release or anything. Do you happen to know if it is possible and where I can look?
- nickff 6y agoThere are no hardware obstacles to doing that, and BLE (BT4 and 5) support custom protocols. That said, I think you will find that working with the proprietary operating systems and architectures on watches and phones is much more difficult than you anticipate.
- mosselman 6y agoI figured it is most likely too difficult. For the amount of work it would take I could just buy an Apple watch and be done with the privacy concerns I have with cheaper trackers, but once the seed of an idea is planted it starts having a life of its own. I think this is an idea I shouldn't water though ;).
- naraic0o 6y agotry gadgetbridge, it's an OSS project that already does this for cheap fitness trackers and some watches. https://gadgetbridge.org/ https://gadgetbridge.org/
- mosselman 6y agoWow this is amazing! It is exactly what I was looking for except for it being on Android only, but at least I now have a whole code base to learn from. Thanks!
- ComputerGuru 6y agoIt’s notoriously not a friendly or easy perform to develop for and despite its capabilities, the ESP32 has largely been relegated to daughterboard status in most embedded situations.
- octorian 6y agoOkay, as someone who has used the ESP32 before (but not the STM32), I'm genuinely curious as to why you're stating this as an assertion. What exactly is it about the ESP32 that makes it unfriendly or difficult? (FWIW, all my ESP32 development has been in C with FreeRTOS. I'm not one of those people who insists on shoving the Arduino stack onto everything.)
- ComputerGuru 6y agoI’m not an Arduino fan either but I primarily work on the opposite end of the spectrum working with the bare metal directly. ESP32’s documentation is nonexistent compared to STM32 and the ARM Cortex core in the STM32 chips has infinitely better tooling than anything with an Xtensa (this more than anything else was the deciding factor in my book).
- pantalaimon 6y agoOn RIOT we’ve put quite some work into implementing the peripheral APIs on the esp8266/esp32 just like on any other supported platform. So no matter if you are on stm32, esp* or ATmega, you can run the same code.
- sunsetonsaturn 6y agoWould I be able to build something that leverages Bluetooth mesh functionality with RIOT and ESP32? Is this use-case supported well?
- pantalaimon 6y agoI'm afraid Bluetooth for esp32 hasn't been implemented yet (only WiFi and ESP-Now - patches welcome…). https://api.riot-os.org/group__cpu__esp32.html#esp32_features https://api.riot-os.org/group__cpu__esp32.html#esp32_feature... You could do a mesh with ESP-Now and RPL though.
- LeifCarrotson 6y agoBetter 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 6y agoIf 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?
- rounakdatta 6y agoWell, 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
- deleted 6y ago[deleted]
- huntik17 6y agoSorry, 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
- markrages 6y agoOr you can use an esp8266 module as a full debugger for the STM32: https://github.com/markrages/blackmagic/blob/esp8266/src/platforms/esp8266/Readme.md https://github.com/markrages/blackmagic/blob/esp8266/src/pla...
- renw0rp 6y agothanks 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)
- agustamir 6y agoCool project! If I need physical access to the board, why would I not program it with a physical interface
- brokenmachine 6y agoWhy do you need physical access to use this?
- agustamir 6y agofor switching BOOT0, reset etc?
- huntik17 6y agoYou can automate that using flipflops or maybe MOSFETs.
- agustamir 6y agoNot 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 6y agoYou'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.
- huntik17 6y agoThis project is a part of a commercial usage, where the entire product was located remotely, thus it was not possible to manually flash the STM everytime.