Need help with M5Stack-SD-Updater?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

205 Stars 31 Forks MIT License 955 Commits 82 Opened issues


💾 Customizable menu system for M5Stack and ESP32-Chimera-Core - loads apps from the Micro SD card. Easily add you own apps

Services available


Need anything else?

Contributors list

# 17,446
802 commits
# 453,054
42 commits
# 123,963
3 commits
# 51,599
1 commit
# 401,137
1 commit
# 741,813
1 commit

License: MIT Build Status Gitter arduino-library-badge


Click to enlarge



Micro SD Card (TF Card) - formatted using FAT32. Max size 32 Gb. SDCard is recommended but the SDUpdater supports other filesystems such as SD_MMC, SPIFFS, LittleFS and PSRamFS.

Make sure you have the following libraries: - they should be installed in:


All those are available in the Arduino Library Manager or by performing a manual installation.


obsolete ~~For your own lazyness, you can use @micutil's awesome M5Burner and skip the next steps.~~ ~~ ~~... or customize your own menu and make the installation manually :~~

1) Open the

sketch from the Arduino ID Examples menu.

2) Download the SD-Content :floppy_disk: folder from the release page and unzip it into the root of the SD Card. Then put the SD Card into the M5Stack. This zip file comes preloaded with precompiled apps and the relative meta information for the menu.

3) Compile and flash the

This sketch is the menu app. It shoul reside in the root directory of a micro SD card for persistence and also executed once.

Once flashed it will copy itself on OTA2 partition and on the SDCard, then rolled back and executed from the OTA2 partition.

Thanks to @Lovyan03 this self-propagation logic is very convenient: by residing on OTA2 the

will always be available for fast re-loading.

4) Make application sketches compatible with the SD-Updater Menu .

The snippet of code in the

sketch can be used as a model to make any ESP32 sketch compatible with the SD-Updater menu.

In your sketch, find the line where the core library is included:

    // #include 
    // #include 
    // #include 
    // #include 
    // #include 
    // #include 


And add this after the include:


In your

function, find the following statements:
    // Serial.begin(115200);

And add this after serial is started:

    checkSDUpdater( SD );

Then do whatever you need to do (button init, timer, network signal) in the setup and the loop. Your app will run normally except at boot (e.g. if the

Button A
is pressed), when it can load the
binary from the filesystem, or go on with it application duties.

⚠️Touch UI has no buttons, this raises the problem of detecting a 'pushed' state when the touch is off. As a compensation, an UI lobby will be visible for 2 seconds after every

. The visibility of the lobby can be forced in the setup :
    checkSDUpdater( SD, MENU_BIN, 2000 );

Custom SD-Load scenarios can be achieved using non default values:


  SD,           // filesystem (SD, SD_MMC, SPIFFS, LittleFS, PSRamFS)
  MENU_BIN,     // path to binary (default = /menu.bin, empty string = rollback only)
  5000          // wait delay, (default=0, will be forced to 2000 upon ESP.restart() or with headless build )
  TFCARD_CS_PIN // optional for SD use only, usually default=4 but your mileage may vary)

Headless setup can bypass

lobby option with their own button/sensor/whatever detection routine.
    Serial.begin( 115200 );

if(digitalRead(BUTTON_A_PIN) == 0) {
  Serial.println("Will Load menu binary");

Headless setup can also be customized in complex integrations:

    Serial.begin( 115200 );

SDUCfg.setFS( &amp;SD );
SDUCfg.setWaitForActionCb( mySerialActionTrigger ); // set your own serial input trigger

SDUpdater sdUpdater( &amp;SDUCfg );

sdUpdater.checkSDUpdaterHeadless( MENU_BIN, 30000 ); // wait 30 seconds for serial input

Use one of following methods to get the app on the filesystem:

  • Have the app copy itself to filesystem using BtnC from the lobby or implement

    saveSketchToFS( SD, "/my_application.bin" );
    from an option inside your app.
  • Manually copy it to the filesystem:

    • In the Arduino IDE menu go to "Sketch / Export Compiled Binary".
    • Rename the file to remove unnecessary additions to the name. The filename will be saved as "filename.ino.esp32.bin". Edit the name so it reads "filename.bin". This is purely for display purposes. The file will work without this change.

⌾ SD-Updater customizations:

These callback setters are populated by default but only fit the best scenario (M5Stack with display+buttons).

⚠️ If no supported combination of display/buttons exists, it will fall back to headless behaviour and will only accept update/rollback signals from Serial.

As a result, any atypical setup (e.g. headless+LittleFS) should make use of those callback setters:

  SDUCfg.setFS          ( &FS );                // fs::FS* (SD, SD_MMC, SPIFFS, LittleFS, PSRamFS)
  SDUCfg.setProgressCb  ( myProgress );         // void (*myProgress)( int state, int size )
  SDUCfg.setMessageCb   ( myDrawMsg );          // void (*myDrawMsg)( const String& label )
  SDUCfg.setErrorCb     ( myErrorMsg );         // void (*myErrorMsg)( const String& message, unsigned long delay )
  SDUCfg.setBeforeCb    ( myBeforeCb );         // void (*myBeforeCb)()
  SDUCfg.setAfterCb     ( myAfterCb );          // void (*myAfterCb)()
  SDUCfg.setSplashPageCb( myDrawSplashPage );   // void (*myDrawSplashPage)( const char* msg )
  SDUCfg.setButtonDrawCb( myDrawPushButton );   // void (*myDrawPushButton)( const char* label, uint8_t position, uint16_t outlinecolor, uint16_t fillcolor, uint16_t textcolor )
  SDUCfg.setWaitForActionCb( myActionTrigger ); // int  (*myActionTrigger)( char* labelLoad, char* labelSkip, unsigned long waitdelay )

Set custom action trigger for

lobby options:
  // int myActionTrigger( char* labelLoad,  char* labelSkip, unsigned long waitdelay )
  // return values: 1=update, 0=rollback, -1=skip
  SDUCfg.setWaitForActionCb( myActionTrigger );


static int myActionTrigger( char* labelLoad,  char* labelSkip, char* labelSave, unsigned long waitdelay )
  int64_t msec = millis();
  do {
    if( Serial.available() ) {
      String out = Serial.readStringUntil('\n');
      if(      out == "update" )  return  1; // load "/menu.bin"
      else if( out == "rollback") return  0; // rollback to other OTA partition
      else if( out == "save")     return  2; // save current sketch to SD card
      else if( out == "skip" )    return -1; // do nothing
      else Serial.printf("Ignored command: %s\n", out.c_str() );
  } while( msec > int64_t( millis() ) - int64_t( waitdelay ) );
  return -1;

void setup() { Serial.begin(115200);

SDUCfg.setAppName( "My Application" ); // lobby screen label: application name SDUCfg.setBinFileName( "/MyApplication.bin" ); // if file path to bin is set for this app, it will be checked at boot and created if not exist

SDUCfg.setWaitForActionCb( myActionTrigger );

checkSDUpdater( SD );


Set custom progress (for filesystem operations):

  // void (*myProgress)( int state, int size )
  SDUCfg.setProgressCb( myProgress );

Set custom notification/warning messages emitter:

  // void (*myDrawMsg)( const String& label )
  SDUCfg.setMessageCb( myDrawMsg );

Set custom error messages emitter:

  // void (*myErrorMsg)( const String& message, unsigned long delay )
  SDUCfg.setErrorCb( myErrorMsg );

Set pre-update actions (e.g. capture display styles):

  // void (*myBeforeCb)()
  SDUCfg.setBeforeCb( myBeforeCb );

Set post-update actions (e.g. restore display styles):

  // void (*myAfterCb)()
  SDUCfg.setAfterCb( myAfterCb );

Set lobby welcome message (e.g. draw UI welcome screen):

  // void (*myDrawSplashPage)( const char* msg )
  SDUCfg.setSplashPageCb( myDrawSplashPage );

Set buttons drawing function (useful with Touch displays)

  // void (*myDrawPushButton)( const char* label, uint8_t buttonIndex, uint16_t outlinecolor, uint16_t fillcolor, uint16_t textcolor )
  SDUCfg.setButtonDrawCb( myDrawPushButton );

📚 SD-Menu loading usage:

Default behaviour: when an app is loaded in memory, booting the M5Stack with the

Button A
pushed will load and run
from the filesystem (or from OTA2 if using persistence).

Custom behaviour: the

Button A
push event car be replaced by any other means (Touch, Serial, Network, Sensor).

Ideally that SD-Menu application should list all available apps on the sdcard and provide means to load them on demand.

For example in the SD-Menu application provided with the examples of this repository, booting the M5Stack with the

Button A
pushed will power it off.

The build-in Download utility of the SD-Menu is currently limited to ESP32-Wrover builds as it uses a significant part of memory and flash space. While it is being reworked and moved to an external app, moving the files manually is the only solution for non-psram devices.

Along with the default SD-Menu example of this repository, some artwork/credits can be added for every uploaded binary. The default SD-Menu application will scan for these file types:

  • .bin compiled application binary

  • .jpg image/icon (max 200x100)

  • .json file with dimensions descriptions:

{"width":128,"height":128,"authorName":"tobozo","projectURL":"http://short.url","credits":"** http://very.very.long.url ~~"}

⚠️ The jpg/json file names must match the bin file name, case matters! jpg/json meta files are optional but must both be set if provided. The value for "credits" JSON property will be scrolled on the top of the screen while the value for projectURL JSON property will be rendered as a QR Code in the info window. It is better provide a short URL for projectURL so the resulting QR Code has more error correction.


  • SD Library limits file names (including path) to 32 chars but 16 is recommended.
  • Short file names may be treated as 8.3 (e.g 2048.bin becomes 2048.BIN).
  • FAT specifications prevent having more than 512 files on the SD Card, but this menu is limited to 256 Items anyway.
  • Long file names will eventually get covered by the jpg image, better stay under 16 chars (not including the extension).


  • The lobby screen at boot can be customized using
    . When set, the app name and the binary path will be visible on the lobby screen, and an extra button
    Button C
    is added to the UI. Pushing this button while the M5Stack is booting will create or overwrite the sketch binary to the SD Card. This can be triggered manually by using
    saveSketchToFS(SD, fileName, TFCARD_CS_PIN)
  SDUCfg.setAppName( "My Application" ); // lobby screen label: application name
  SDUCfg.setBinFileName( "/MyApplication.bin" ); // if file path to bin is set for this app, it will be checked at boot and created if not exist
  • It can also be disabled (although this requires to use the early callback setters):
#include "M5StackUpdater.h"
  • Although not recommended (because not extensevely tested), the default binary name to be loaded (
    ) can be changed at compilation time by defining the
#define MENU_BIN "/my_custom_launcher.bin"
#include "M5StackUpdater.h"
  • The JoyPSP and M5Stack-Faces Controls for M5Stack SD Menu necessary code are now disabled in the menu example but the code stays here and can be used as a boilerplate for any other two-wires input device.


  • SD was not declared in this scope
    : make sure your
    is made before including
  • Serial message
    [ERROR] No filesystem selected
    [ERROR] No valid filesystem selected
    : try
    SDUCfg.setFS( &SD )
    prior to calling the SDUpdater


  • Completely detach the UI/Display/Touch/Buttons from the codebase
  • Support gzipped binaries
  • Migrate Downloader / WiFiManager to external apps
  • esp-idf support
  • Contributors welcome!


| | | | | ------------ |:------------------------ | :------------------------------------------- | | :clapper: | Video demonstration | | | :clapper: | Video demo of Pacman + sound | Source | | :clapper: | Video demo of NyanCat | Source | | 🎓 | Macsbug's article on M5Stack SD-Updater | 🇯🇵 🇬🇧 (google translate)|


| | | | | | ------ |:------------------- | :--------------- | :------------------------------------------- | | 👍 | M5Stack | M5Stack | | | 👍 | M5StackSam | Tom Such | | | 👍 | ArduinoJSON | Benoît Blanchon | | | 👍 | QRCode | Richard Moore | | | 👍 | @Reaper7 | Reaper7 | | | 👍 | @PartsandCircuits | PartsandCircuits | | | 👍 | @lovyan03 | らびやん | | | 👍 | @matsumo | Matsumo | |

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.