(answered) Questions about OTA/bootloader

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

(answered) Questions about OTA/bootloader

Postby mzimmers » Thu Oct 31, 2019 8:15 pm

Hi all -

Our first product based on the ESP32 is nearing an end. Unfortunately, so is the amount of available flash memory. My program has grown to over 1MB, and as such, I don't have room to keep copies in factory, ota_0 and ota_1. In fact, when I add syslog functionality, I'll probably have to eliminate one of these.

I've been reading the docs on the bootloader and OTA, and I get the gist of how this works, but I have some questions:

1. do I absolutely need a factory app? Could I just flash my app to one of the OTA partitions instead? If so, how do I inform the bootloader which partition to use?

2. If I do need a factory app, can I make it a very small one that essentially just jumps to one of the OTA partitions? If so, where do I get the information that tells me which one to use?

I'm hoping that perhaps someone else has run into this problem, and has already addressed it. But I welcome any ideas on how best to take care of this.

Currently using V3.3, but could easily migrate if necessary.

Thanks...
Last edited by mzimmers on Fri Nov 15, 2019 4:03 pm, edited 1 time in total.

chegewara
Posts: 2238
Joined: Wed Jun 14, 2017 9:00 pm

Re: Questions about OTA/bootloader

Postby chegewara » Fri Nov 01, 2019 1:07 am

1. No, you don't need factory partition; it's useful in case of bricking device and may have flashed simple app to download and re-flash device app.

You don't need to do any special preparations, bootloader will start from first valid partition.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: Questions about OTA/bootloader

Postby mzimmers » Fri Nov 01, 2019 2:32 pm

Hi Chegewara -

Thanks for the reply. I'm not sure I understand your answer about the factory partition -- are you saying that it's possible to install a minimal application in the factory partition that just accepts a flash download to go to one of the OTA partitions?

chegewara
Posts: 2238
Joined: Wed Jun 14, 2017 9:00 pm

Re: Questions about OTA/bootloader

Postby chegewara » Fri Nov 01, 2019 7:53 pm

Yes, that's the idea.
In esp-idf v3.3 or v4.x it's been introduced factory rest with button. Having simple http client on factory partition let you do OTA flash and start your regular app.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: Questions about OTA/bootloader

Postby mzimmers » Fri Nov 01, 2019 7:55 pm

OK, so is there a write-up that shows how to code a branch from a factory partition into an OTA partition?

Thanks...

bas_KC
Posts: 2
Joined: Thu Oct 31, 2019 9:30 am

Re: Questions about OTA/bootloader

Postby bas_KC » Mon Nov 04, 2019 10:29 am

https://docs.espressif.com/projects/esp ... ables.html
There is the information you are looking for ;)

axellin
Posts: 197
Joined: Mon Sep 17, 2018 9:09 am

Re: (answered) Questions about OTA/bootloader

Postby axellin » Fri Jun 19, 2020 3:22 am

mzimmers wrote:
Thu Oct 31, 2019 8:15 pm
Hi all -

Our first product based on the ESP32 is nearing an end. Unfortunately, so is the amount of available flash memory. My program has grown to over 1MB, and as such, I don't have room to keep copies in factory, ota_0 and ota_1. In fact, when I add syslog functionality, I'll probably have to eliminate one of these.
Hi,
Just curious if you do syslog to a spiffs, fatfs, or raw partition?
Is it stable to do frequently write on the filesystem (or raw partition) on flash?

Thanks,
Axel

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: (answered) Questions about OTA/bootloader

Postby mzimmers » Fri Jun 19, 2020 12:52 pm

Hi Alex - in my case, I just used the NVS. My app maintains a circular buffer of 1024 entries of the following format:

Code: Select all

typedef int32_t ENTRY_INDEX;
struct LogEntry
{
    ENTRY_ID id;                // unique number to identify entry.
    time_t  timestamp;          // unix time.
    uint8_t msgLength;          // 0-255 bytes
    char msg[MAX_LOGMSG_LEN];   // null-terminated C string.
};
The need for a timestamp AND an entry ID is due to the fact that some logs are generated before the system acquires NTP, so I can't use the timestamp for finding the head of the queue.

Who is online

Users browsing this forum: DrMickeyLauer, ESP_Roland and 134 guests