Self-updating flash from micropython (how to read and write flash WITHOUT using FreeRTOS ?)

cndgeek
Posts: 3
Joined: Sun Jul 17, 2022 1:27 pm

Self-updating flash from micropython (how to read and write flash WITHOUT using FreeRTOS ?)

Postby cndgeek » Sat Jan 13, 2024 1:57 pm

I want to suspend all interrupts and FreeRTOS events etc, and run some bare-metal code to move bytes from one place in flash to another...

The "target" location is the "firmware" (A FreeRTOS build of MicroPython) - aka 0x1000 (sector 1) for a length of 1737664 bytes.

The "source" for the move is the stream of bytes which is hte firmware (it arrived as a (possibly fragmented) file onto littlefs or fatfs filesystem) and my code already understands how to reconstruct the original binary from direct flash reads (for both fat and littlefs with it's in-sector added bytes)

I suspect that I cannot simply call flash_erase and flash_write and flash_read because I'm guessing that all of those will stop working the instant my update overwrites the flash location where those FreeRTOS spiflash routines live ?

Hence my question: does anyone know what machine instructions are needed to read, erase, and write spi flash directly from the CPU, without using any RTOS calls ?

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Self-updating flash from micropython (how to read and write flash WITHOUT using FreeRTOS ?)

Postby ESP_Sprite » Sun Jan 14, 2024 2:04 am

Can I ask why you don't want to use the OTA functionality in ESP-IDF? That is made for that purpose.

MicroController
Posts: 1725
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Self-updating flash from micropython (how to read and write flash WITHOUT using FreeRTOS ?)

Postby MicroController » Sun Jan 14, 2024 2:09 pm

You want to update the firmware 'in-place', i.e. without switching to a second 'OTA' partition?

Who is online

Users browsing this forum: No registered users and 352 guests