Can I use OTA firmware space for logging?

I’m looking to extend my logging capability beyond the space allocated for the emulated EE and SRAM.

After reviewing the memory map, I was thinking about using the space allocated for OTA firmware. I’m okay with loosing logged data when an upgrade is required. I’d have to add some guards to prevent writing (logging) while an image is being transferred or upgrade is in progresses.

Is this a crazy idea that should not be attempted?

If you’re content with the logging being a “best effort” rather than guaranteed retainment, then I think it’s a good idea.

The system will provide system events when OTA update is about to start so you know to either save the data elsewhere or cancel the OTA update.

1 Like

Awesome! “best effort” is exactly what I was hoping for. So I could subscribe to a system call from functions provided from system/inc/system_event.h ?
for example: system_subscribe_event(firmware_update_pending, myStopLoggingFunction, NULL);

To start logging again, can I assume after a reset and when my application code starts running, the OTA flash space if free to use? or should I also subscribe to firmware_update to resume logging?

Thanks for your feedback!

Yes, after reset the OTA region is free to use again, so you only need to know when the system is about to start using it.

There is also an event for failed OTA, in which case the system doesn’t reset, so you’ll probably want to listen to that and resume logging.