Using SDMMC in custom bootloader (ESP32-WROOM)

vpascucci
Posts: 5
Joined: Fri Apr 09, 2021 6:12 am

Using SDMMC in custom bootloader (ESP32-WROOM)

Postby vpascucci » Fri Apr 26, 2024 10:01 pm

Hello,

I should preface that what I intend to do might not be the easiest way to achieve my goal, so if you have better ideas feel free to chime in.

I have a custom board based on an ESP32-WROOM module. I was thinking of a really cheap way to update the firmware and I thought about using an sd-card for that. I would like to make a custom bootloader that checks if an SD card is present, mounts it, checks if a new main application binary is present and, in that case, flashes it to the SPI flash, then loads the main application.

I have seen in the Espressif documentation that the bootloader does not see the various components offered by ESP-IDF for the main application, and indeed if I try to include SDMMC related headers in bootloader_components/bootloader_start.c I get an error as the files are not found.

What would be the necessary steps to enable SDMMC access within my custom bootloader? or are there better ways to achieve my ultimate goal of updating the firmware through an SD card?

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: Using SDMMC in custom bootloader (ESP32-WROOM)

Postby boarchuz » Sat Apr 27, 2024 4:25 pm

Either implement a basic bootloader SDMMC component from scratch by studying the SDMMC component and TRM, or copy the existing SDMMC component to bootloader_components and go through it replacing all incompatible dependencies (eg. any FreeRTOS stuff, GPIO functions from the driver component, etc) with bootloader-compatible replacements.

If it's just a personal project and your design happens to have a USB connector already you might give https://github.com/boarchuz/bo_dfu a try.

vpascucci
Posts: 5
Joined: Fri Apr 09, 2021 6:12 am

Re: Using SDMMC in custom bootloader (ESP32-WROOM)

Postby vpascucci » Sat Apr 27, 2024 8:05 pm

Hello Boarchuz,

Thank you for your answer. I see that achieving my goal through the bootloader might be harder than I initially thought and possibly a little beyond my skill level. I believe I would be better served by setting up an OTA partition scheme and having the update check and mechanism run right away in the main() function, that way I would be able to take advantage of the full ESP-IDF framework. My application is currently about 650kB and I don't expect it to grow dramatically going forward. What do you think?

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: Using SDMMC in custom bootloader (ESP32-WROOM)

Postby boarchuz » Sun Apr 28, 2024 2:29 am

It sounds like you'll have plenty of flash available for 2 app partitions and that will definitely be the easier and more reliable approach. If the only motivation for updating via the bootloader was reducing the flash footprint of app partitions then this is the way to go.

I hope I haven't talked you out of it entirely though. Bootloader SD updates would be a rewarding and interesting project if you have time to revisit this in future.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 95 guests