esptool write_flash: error: argument : Address "{upload.erase_cmd}" must be a number



  • I am having problems with the IDE 2.0 uploading to a M5STACK Paper. I researched this error and found one fix. The first fix said to download the Nightly Build so I did.

    The error is:

    esptool write_flash: error: argument : Address "{upload.erase_cmd}" must be a number



  • Have you updated Xcode and python (assuming you are on a Mac)



  • Your are correct. I have a Mac running Monterey 12.3.1. python --version returns 2.7.14. Xcode is 13.4.1



  • Hi, I'm on an M1 iMac, Monterey.
    Goto Pthyon.org and follow the easy instructions and install Python3.x.x, painlessly.
    hope this helps



  • Thanks. I did this and also dug out an old windows laptop running Arduino 1.8.19. I downloaded the M5Stack boards file using https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json and then installed the M5STACK libraries and the M5EPD library from GitHub. This setup gives the very same error.



  • Have you set the environment variable to point to python 3?

    Also the new OS X is a pain!



  • I would not know where to set that is but since the same error occurs in the Windows version of the IDE I am thinking that it isn't a problem with the MAC. Also this only fails with the Paper device if I select the Core 2 I can program the Paper just fine however the external I2C doesn't work so IDK if this is because I said the Paper was a Core 2 or not.



  • same error.
    Brand new user (just received my M5StickC 7 hours ago)
    My development environment is freshly minted (3 hours ago) on a USB drive plugged into a Raspberry Pi4B.
    New OS. New install of Arduino IDE 1.8.19.
    Add platform "M5Stack Arduino" and Library "M5StackCPlus" by following these instructions.

    the sketch is very basic
    '''
    void setup() { }

    void loop() { }
    '''

    the error is:
    usage: esptool write_flash [-h] [--erase-all]
    [--flash_freq {keep,40m,26m,20m,80m}]
    [--flash_mode {keep,qio,qout,dio,dout}]
    [--flash_size FLASH_SIZE]
    [--spi-connection SPI_CONNECTION] [--no-progress]
    [--verify] [--encrypt]
    [--encrypt-files <address> <filename> [<address> <filename> ...]]
    [--ignore-flash-encryption-efuse-setting]
    [--compress | --no-compress]
    <address> <filename> [<address> <filename> ...]
    esptool write_flash: error: argument <address> <filename>: Address "{upload.erase_cmd}" must be a number
    esptool write_flash: error: argument <address> <filename>: Address "{upload.erase_cmd}" must be a number

    Please assist with getting my shiny new device to work.



  • the file does actually show the "-e". What should it be?
    ~/.arduino15/packages/m5stack/hardware/esp32/2.0.5/boards.txt

    m5stick-c.menu.EraseFlash.none=Disabled
    m5stick-c.menu.EraseFlash.none.upload.erase_cmd=
    m5stick-c.menu.EraseFlash.all=Enabled
    m5stick-c.menu.EraseFlash.all.upload.erase_cmd=-e



  • Dear M5: please repair the board information for the M5Stick-C-plus. See errors above.

    other users: switching to the M5Stick-C (no "-plus") platform allowed me to upload new sketches to the device.
    0_1665178518532_3412d667-e1c3-43ad-88dd-97a04a107d2d-image.png



  • Me too. Thanks for sharing or I would go insane.
    I have seen this in other M5Stack Products
    There is a user felmue that helps keep things straight, maybe he can help?



  • This problem seems to be caused by the esp32 2.0.5 update.

    I don't think M5Stack are to blame, this was not a mandatory setting before.

    After this update was installed I had the same problem with some of my M5Stack boards, but not all of them. A menu setting for erasing flash before upload or not must now be set. It seems that this menu setting must be sent to esptool, if this is not provided then esptool fails with the Address "{upload.erase_cmd}" must be a number error
    There is a simple fix, if you can find your hidden arduino boards.txt file.
    The path to the file will be different on Windows, Linux and OSX.
    You need to add the following to boards.txt for ALL types of M5Stack/M5Stamp boards and then uploads should work again:

    <board_name>.menu.EraseFlash.none=Disabled
    <board_name>.menu.EraseFlash.none.upload.erase_cmd=
    <board_name>.menu.EraseFlash.all=Enabled
    <board_name>.menu.EraseFlash.all.upload.erase_cmd=-e

    Replace <board_name> with the correct name for each type of board in the complete list. You can see what the name should be in the section for each M5Stack board.

    After editing and saving boards.txt in the correct place, you need to restart the arduino IDE. You will then see in the Tools menu Erase All Flash Before Sketch Upload: Disabled/Enabled. This is the missing required setting for esptool.

    Make a copy of your boards.txt before you make any edits so you can recover from any incorrect changes.

    Good Luck!



  • Hi @veryalien,

    For the record, I was getting this error with the M5StickC PLUS and your suggested edits to boards.txt fixed the problem. Thanks! Note that for whatever reason, I was not getting this error with an M5Atom.

    Do you know how/when M5Stack does new releases that incorporates bug fixes such as these? Do we need to somehow notify them or do they regularly read the community forum? I'm aware of at least one library bug that someone has found a fix for in the forum. In that case, the user did a pull request on GitHub and the fix was pulled into the repository, but a new version of the library has not been released.



  • Thank you!

    I was getting this on my M5StickC-Plus, on the 10th/Oct/2022, with all the latest board/library updates.

    I hope everyone else can find this thread!

    For me the file I had to add those lines to was:

    C:\Users[login name]\AppData\Local\Arduino15\packages\m5stack\hardware\esp32\2.0.5\boards.txt



  • The esp32 bord defs in Arduino are controlled by espressif and it looks like they broke a few things.