HOW DO OTA UPDATES HAPPEN IN THE ESP32? | ADVANCED ESP32

Описание к видео HOW DO OTA UPDATES HAPPEN IN THE ESP32? | ADVANCED ESP32

How do OTA Updates happen in the ESP32?
In this video, we will learn about the use case of OTA Updates in the ESP32. Then we will learn about the Partition Tables and Bootloader of the ESP32. Finally, we will learn the OTA update mechanism in the ESP32.

(If you liked this video and would like to buy our course, you are in for a pleasant surprise. Please click on the link below to buy the course for $25 ONLY. Original price is $195.
https://utm.io/upz1)

A fantastic feature of any WiFi-enabled microcontroller like the ESP32 is the possibility of using the same WiFi Feature to flash a new program.This will eliminate the need for a physical connection between the device and a PC. So, implementing the OTA Update feature in an ESP32 board will be extremely useful especially if you are into product development.

Just imagine that you manage a company which makes smart thermostats and more than 10000 devices are on the field. Let's say that you found a security vulnerability in your device and want to patch this bug with an update on all your customer’s devices. In this case, it is not practical to ask the customer to manually update by connecting the thermostat to a PC. Furthermore, your company may have to employ technicians to help customers with this update.

The simple solution is to implement an OTA Update feature before the product reached the market. Then we can simply update all our devices over the air using WiFi. Is it that simple?
In practice, it is not that simple as we can’t simply overwrite the current firmware with the security update. There are two reasons for this.

The first reason is that the current firmware is actually the one running and responsible for performing the network retrieval of data. Thus, while we overwrite with new firmware, the network retrieval instructions might get corrupted and will result in an incomplete update that can disable OTA functionality altogether.

The second problem is that something could go wrong with the data transmission and we would end up with a partial update which likely would not boot. So, what is the workaround to these hurdles?

The solution is to load our new code in a completely separate, but equally sized, area of flash memory. If the download of the new code completes successfully, only then use the new partition as the boot partition.

Before, we look at how this is implemented in ESP32, let's learn what happens inside the flash memory when a new code is flashed via the USB Cable.

Whenever a new code is flashed to the ESP32, the code is stored inside the flash memory that is attached to the SPI Bus of the ESP32 chip. The flash memory is a non-volatile memory, unlike the RAM inside the ESP32 Chip. Thus, even when the ESP32 is switched off, the code will be safe in the Flash Memory. The Sparkfun ESP32 Thing has a flash memory of size 4 MegaBytes.

A single ESP32’s flash can contain multiple apps, as well as many different kinds of data like calibration data, file systems, parameter storage, etc. As all these data are present in single flash memory, the ESP32 chip needs a map to locate the position of different data sets. This is done in ESP32 through a concept called Partition Tables. It is just like the Index page of a big book, but with more details of the content, it’s pointing to. The partition table starts at a default offset of 32768 Bytes. It has a size of 3072 bytes with a maximum of 95 distinct table entries. Each table entry is 32 bytes long, thus all the 95 entries together takes 3040 bytes. The last 32 bytes are MDF Checksum used for checking the integrity of the partition table. If you want to know more about the partition tables please visit the link in the resources.

Summary
In this video, we have covered the following topics
● Why implement OTA Programming in the ESP32
● Partition Tables and Bootloader in the ESP32
● The OTA Update Mechanism in the ESP32

(If you liked this video and would like to buy our course, you are in for a pleasant surprise. Please click on the link below to buy the course for $25 ONLY. Original price is $195.
https://utm.io/upz1)

Check us out on
Website : https://makerdemy.com
Catalogue : https://makerdemy1.teachable.com
Facebook :   / makerdemy  
Twitter :   / makerdemy  
LinkedIn :   / makerdemy  
Instagram :   / makerdemy  
Email : [email protected]

Комментарии

Информация по комментариям в разработке