SimpleOTA client v1.2.0
Shared core of the SimpleOTA Arduino and ESP-IDF clients
Loading...
Searching...
No Matches
sota_image.h File Reference

Writing an update into the next app slot. More...

Go to the source code of this file.

Functions

bool sota_image_begin (size_t expected, uint32_t *slot, uint32_t *running)
 Start writing the slot after the running one.
 
bool sota_image_accepts (const uint8_t *head, size_t len)
 Whether a download that starts with these len bytes can be an image for this device, so one built for another chip is dropped after its first bytes, not after all of it.
 
bool sota_image_write (const uint8_t *buf, size_t len)
 Write the next bytes, in order.
 
void sota_image_abort (void)
 Give up the write.
 
bool sota_image_finish (void)
 End the write and check the image is one the bootloader can start.
 

Detailed Description

Writing an update into the next app slot.

Implemented by the platform port (esp_ota_* on ESP32) and the host tests' fake.

One write at a time. Nothing here makes the image bootable: the engine saves the trial record first and then switches the slot (sota_boot.h).

Function Documentation

◆ sota_image_begin()

bool sota_image_begin ( size_t  expected,
uint32_t *  slot,
uint32_t *  running 
)

Start writing the slot after the running one.

expected is the image size, 0 when unknown. *slot gets the flash address written to, and *running the running image's.

◆ sota_image_accepts()

bool sota_image_accepts ( const uint8_t *  head,
size_t  len 
)

Whether a download that starts with these len bytes can be an image for this device, so one built for another chip is dropped after its first bytes, not after all of it.

The engine asks once, with the first read. True also when len is too short to tell: sota_image_finish() has the last word.

◆ sota_image_finish()

bool sota_image_finish ( void  )

End the write and check the image is one the bootloader can start.

The write is over either way.