HOWTO: M5Stack Fire - use the full 16MB with the Arduino IDE (UPDATED)



  • For reasons unclear to me, the M5Stack Fire support added to the Board Manager does not change the size of the flash from the original M5Stack Core. What that means is that you cannot use all that extra flash (Fire has 16 MB, classic M5Stack has 4 MB).

    Here's how to use the extra space:

    Find the directory that on my Mac is at

    ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.0/tools/partitions

    (It's probably named slightly different on Windows machines, don't use those.)

    There, add a file called default_16MB.csv and put the following lines in it:

    # Name,   Type, SubType, Offset,  Size, Flags
    nvs,      data, nvs,     0x9000,  0x5000,
    otadata,  data, ota,     0xe000,  0x2000,
    app0,     app,  ota_0,   0x10000, 0x640000,
    app1,     app,  ota_1,   0x650000,0x640000,
    eeprom,   data, 0x99,    0xc90000,0x1000,
    spiffs,   data, spiffs,  0xc91000,0x36F000,
    

    and add another file called large_spiffs_16MB.csv and put in it:

    # Name,   Type, SubType, Offset,  Size, Flags
    nvs,      data, nvs,     0x9000,  0x5000,
    otadata,  data, ota,     0xe000,  0x2000,
    app0,     app,  ota_0,   0x10000, 0x480000,
    app1,     app,  ota_1,   0x490000,0x480000,
    eeprom,   data, 0x99,    0x910000,0x1000,
    spiffs,   data, spiffs,  0x911000,0x6EF000,
    

    Now go two directories up (so for me that would be ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.0) and edit the file boards.txt.

    search for m5-stack-fire.upload.maximum_size and replace that line with:

    m5stack-fire.upload.maximum_size=6553600
    

    Then replace the (next) line (m5stack-fire.upload.maximum_data_size) with:

    m5stack-fire.upload.maximum_data_size=4521984
    

    Then find m5stack-fire.build.partitions and replace that line with:

    m5stack-fire.build.partitions=default_16MB
    

    Then insert the following new section between the PSRAM and UploadSpeed sections:

    m5stack-fire.menu.PartitionScheme.default=Default (2 x 6.5 MB app, 3.6 MB SPIFFS)
    m5stack-fire.menu.PartitionScheme.default.build.partitions=default_16MB
    m5stack-fire.menu.PartitionScheme.large_spiffs=Large SPIFFS (7 MB)
    m5stack-fire.menu.PartitionScheme.large_spiffs.build.partitions=large_spiffs_16MB
    m5stack-fire.menu.PartitionScheme.large_spiffs.upload.maximum_size=4685824
    

    And then restart the IDE and you can use the full flash: I chose 2 x 6.5 MB OTA partitions, 3.6 MB SPIFFS. So now the M5ez demo program uses only 18% of one OTA partition. Or opt for a SPIFFS partition that will hold a whopping 7 MB. Nice...

     

    I have filed a pull request at https://github.com/espressif/arduino-esp32 with these changes.

     

    M5Stack people: I know you don't answer questions or talk to us in general, but this is something you people should be doing, not some dude in the community...



  • Thanks for the how-to. Did you made also a ticket on the arduino gitlab to merge it into the code? If not, at least this is the job of M5Stack stuff to properly support their device in the IDE.



  • I hesitate because I really don't know how much RAM to allow. Shall I just subtract as much (or a little more) as they did for the 400 kB version? I will if there's no reaction (which would be typical, I'm afraid), but this is stuff that M5Stack should do.

    I mean: we don't even have a decent list of what's out there in terms of models and revisions, we don't get answers when we ask questions. I understand they're busy – always on the next version – but I'm beginning to feel someone should redo this whole thing as a true open source / open hardware project.



  • This post is deleted!


  • Further info:

    Partition tables are documented in the esp idf:
    https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/partition-tables.html

    RAM
    ESP32 has 512 kB RAM. This is divided into IRAM (instruction RAM), DRAM (data RAM), and RTC memory.
    From the Rechnical Reference pp25 only 328 kB is available as SRAM in two blocks. So 320kB is reasonable. I assume it is only used as an indicator in Arduino for the RAM percentage. PSRAM is only switched on or off, there is no check of size involved.



  • I updated the post (the SPIFFS was the original size while I had made space to make it bigger) and added a menu option for 7MB SPIFFS. Have also filed the pull request at espressif, all detailed in the edited lead post.



  • Not all is so smooth. Try this sketch. When compiled under Fire it gives wrong M5Bala library operation, resulting at least in wrong angle measurements. With M5stack-Core-ESP32 all OK.
    Test.ino



  • @Kabron I don't have the BALA hardware so cannot test. Can you better explain what you mean by:

    it gives wrong M5Bala library operation

    Does it work it you use the original (smaller) partition scheme on the Fire? I.e.: do we know it is connected to the partitioning at all? Or could it be some other difference between the Core and the Fire?



  • @ropHOWTO: M5Stack Fire - use the full 16MB with the Arduino IDE (UPDATED) 中说:

    @Kabron I don't have the BALA hardware so cannot test. Can you better explain what you mean by:

    it gives wrong M5Bala library operation

    Does it work it you use the original (smaller) partition scheme on the Fire? I.e.: do we know it is connected to the partitioning at all? Or could it be some other difference between the Core and the Fire?

    Not now, maybe tomorrow.



  • Well, on my office PC I had to reinstal ESP32 package and I found that your suggestions allready icluded in the new
    release. Now, regardless of choosen board( M5-Stack-Core/Fire/ESP32-Dev) I got this stange behaviour.
    It looks like very huge negative value(about 30 digits)of measured angle, which begins to rize in positive direction,
    until it reach correct value. From this point, the program could or could not continue normal run.
    I'll try to roll back the package install to see what happened.



  • @kabron
    Have you installed the gitlab repository code or the release version https://github.com/espressif/arduino-esp32/releases ?
    Because the v1.0.0 Release has a huge I2C bug that affects all readings on the bus and is only corrected in the repository



  • I istalled release, but I guess I find another reason.
    In the M5BALA stack there are three IP5306 IC on the 5V BUS.
    And one of these IC is controlled by ESP32.
    During reboot procedure trouble things occured at 5V bus Brownout
    As (thanks to M5 team) we do not still have all fucking schematics, nobody could resolve what is going on there.
    Now, the situation looks like the following: one time it could start working normally or another time it could not. Unpredictable.



  • @Kabron
    Install the github repository. The Arduino ESP32 v1.0.0 release version does not recover from failed reads on the I2C bus until the power is cycled.
    Don't know what is the purpose of multiple power management ICs if you have only one battery. But the registers of this IP 5306_I2C are similar to the IP5108 covered in http://forum.m5stack.com/post/1464
    Maybe to prevent the battery charging during boot is a workaround



  • May I suggest creating a new thread for this? It does seem like this has nothing to do with partitioning, and this will confuse people...



  • It seems that esp32 only provide 4MB flash as read only rom.As you change the app0 partition size to 6.5MB,the esp linker under arduino can only produce the max size 4MB of your code.In the file \esp32\tools\sdk\ld\esp32_out.ld,the following lines declare the max size of the readonly flash rom.
    /* Flash mapped constant data */
    drom0_0_seg (R) : org = 0x3F400018, len = 0x400000-0x18