How do you compile and flash micropython to M5StickC plus?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
kkdao
Posts: 2
Joined: Mon Mar 22, 2021 11:08 pm

How do you compile and flash micropython to M5StickC plus?

Post by kkdao » Mon Mar 22, 2021 11:15 pm

Hello,

I am wondering how to compile and flash micropython (https://github.com/micropython/micropython) to an M5StickC plus using the ESP-IDF, or even Arduino IDE - I just figured there would be more info using with esp-idf.

I don't mind following commands, I am just unsure exactly how to find the correct firmware for the board, and then flash it using ESP-IDF - I've only used it a couple times following guides.

Any pointers/help is greatly appreciated!

kkdao
Posts: 2
Joined: Mon Mar 22, 2021 11:08 pm

Re: How do you compile and flash micropython to M5StickC plus?

Post by kkdao » Tue Mar 23, 2021 7:01 pm

nevermind, i figured it out! this article helped me - i had to make some tweaks though: https://www.microdev.it/wp/en/2018/08/0 ... for-esp32/

here are the steps i took if anyone else is interested:

~]$ sudo mkdir Micropython
~]$ cd Micropython
Micropython]$ sudo mkdir esp32
Micropython]$ cd esp32


esp32]$ sudo git clone https://github.com/micropython/micropython

esp32]$ cd micropython/ports/esp32
esp32]$ sudo make
idf.py -D MICROPY_BOARD=GENERIC -B build-GENERIC build
make: idf.py: No such file or directory
make: *** [Makefile:24: all] Error 127

esp32]$ . $HOME/esp/esp-idf/export.sh
bash: /home/<username>/esp/esp-idf/export.sh: No such file or directory


esp32]$ sudo git clone -b v4.0.2 --recursive https://github.com/espressif/esp-idf.git

esp32]$ cd esp-idf
esp-idf]$ ./install.sh

All done! You can now run:

. ./export.sh

esp-idf]$ source export.sh
IDF_PATH is set to '/home/<username>/esp/esp-idf', but it is not a valid directory.
If you have set IDF_PATH manually, check if the path is correct.

esp-idf]$ . ./export.sh
IDF_PATH is set to '/home/<username>/esp/esp-idf', but it is not a valid directory.
If you have set IDF_PATH manually, check if the path is correct.

esp-idf]$ . $HOME/Micropython/esp32/esp-idf/export.sh
IDF_PATH is set to '/home/<username>/esp/esp-idf', but it is not a valid directory.
If you have set IDF_PATH manually, check if the path is correct.

esp-idf]$ export IDF_PATH=~/Micropython/esp32/esp-idf
esp-idf]$ . $HOME/Micropython/esp32/esp-idf/export.sh

Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

idf.py build

esp-idf]$ make
make: *** No targets specified and no makefile found. Stop.
esp-idf]$ cd ..
esp32]$ make
make: *** No targets specified and no makefile found. Stop.
esp32]$ ls
esp-idf micropython
esp32]$ cd micropython/ports/esp32
esp32]$ make
permission error

esp32]$ sudo make
.../mpy-cross, please build it first

esp32]$ sudo make -C mpy-cross
make: *** mpy-cross: No such file or directory. Stop.

esp32]$ sudo make
.../mpy-cross, please build it first

esp32]$ ls
esp-idf micropython

esp32]$ cd micropython

micropython]$ sudo make -C mpy-cross

micropython]$ cd ports/esp32

esp32]$ sudo make submodules

esp32]$ sudo make

"sudo idf.py -p /dev/ttyUSB0 flash" didn't work so tweaked the output of this command and used it in the next command

to flash m5stickC plus:
"/home/<username>/.espressif/python_env/idf4.0_py3.9_env/bin/python ../../../esp-idf/components/esptool_py/esptool/esptool.py -p /dev/ttyUSB0 -b 115200 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build-GENERIC/bootloader/bootloader.bin 0x8000 build-GENERIC/partition_table/partition-table.bin 0x10000 build-GENERIC/micropython.bin"

don't mind the errors that is for my own benefit, and apologies if the style is messy!

mak3r
Posts: 1
Joined: Thu Mar 17, 2022 7:40 pm

Re: How do you compile and flash micropython to M5StickC plus?

Post by mak3r » Thu Mar 17, 2022 7:56 pm

I realize this is a year old but I found it immensely helpful and so I put it all in a docker container for ease of re-use on all my dev systems. https://github.com/mak3r/micropython-esp32-dev

Thanks,

--
mak3r

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: How do you compile and flash micropython to M5StickC plus?

Post by scruss » Wed Jul 27, 2022 7:26 pm

I uploaded the esp32/GENERIC firmware binary, and I'm getting reliable operation. Even though it has the ESP32-PICO, the M5StickC and M5StickCplus don't have SPIRAM

Post Reply