Page 1 of 1

(answered) Questions about OTA/bootloader

Posted: Thu Oct 31, 2019 8:15 pm
by mzimmers
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...

Re: Questions about OTA/bootloader

Posted: Fri Nov 01, 2019 1:07 am
by chegewara
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.

Re: Questions about OTA/bootloader

Posted: Fri Nov 01, 2019 2:32 pm
by mzimmers
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?

Re: Questions about OTA/bootloader

Posted: Fri Nov 01, 2019 7:53 pm
by chegewara
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.

Re: Questions about OTA/bootloader

Posted: Fri Nov 01, 2019 7:55 pm
by mzimmers
OK, so is there a write-up that shows how to code a branch from a factory partition into an OTA partition?

Thanks...

Re: Questions about OTA/bootloader

Posted: Mon Nov 04, 2019 10:29 am
by bas_KC
https://docs.espressif.com/projects/esp ... ables.html
There is the information you are looking for ;)

Re: (answered) Questions about OTA/bootloader

Posted: Fri Jun 19, 2020 3:22 am
by axellin
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

Re: (answered) Questions about OTA/bootloader

Posted: Fri Jun 19, 2020 12:52 pm
by mzimmers
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.