This repository adds a board definition for the M5Stack Tough for use with lv_micropython.
Note
These instructions assume you are working on a Mac with Apple silicon. For different architectures or operating systems, it may be helpful to start from LV-MicroPython's setup documentation.
Clone this repository:
git clone https://github.com/solanus-systems/micropython-m5tough.gitClone LV-MicroPython, including its submodules:
git clone --recursive https://github.com/lvgl/lv_micropython.gitClone esp-idf, including its submodules. Check the lv_micropython README for the latest versions of esp-idf known to work.
git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.gitInstall esp-idf:
# in esp-idf/
./install.shInstall cmake using Homebrew:
brew install cmakeLink the m5tough custom board definition into the LV-MicroPython boards directory:
ln -s /path/to/micropython-m5tough /path/to/lv_micropython/ports/esp32/boards/M5STACK_TOUGHBuild the micropython cross-compiler:
# in lv_micropython/
make -C mpy-crossEnsure the ESP-IDF environment is set up:
# in esp-idf/
source ./export.shCompile the firmware:
# in lv_micropython/ports/esp32
make submodules
BOARD=M5STACK_TOUGH make -j $(nproc)Firmware will be output to lv_micropython/ports/esp32/build-M5STACK_TOUGH/firmware.bin.
Note
Check the port name of your M5Tough before running the following commands. You
can find it by running ls /dev/tty.usb* in the terminal when the M5 is connected
to your computer via USB cable.
Erase existing firmware on the M5Tough (if e.g. UIFlow is currently installed):
# in lv_micropython/ports/esp32
esptool.py --port /dev/tty.usbserial-54D80277501 --baud 115200 --before default_reset --after hard_reset --chip esp32 erase_flashDeploy the firmware to the M5Tough:
# in lv_micropython/ports/esp32
esptool.py --port /dev/tty.usbserial-54D80277501 --baud 115200 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size 16MB --flash_freq 80m 0x1000 build-M5STACK_TOUGH/bootloader/bootloader.bin 0x8000 build-M5STACK_TOUGH/partition_table/partition-table.bin 0x10000 build-M5STACK_TOUGH/micropython.binTo update the micropython version, you need to perform these steps in the lv_micropython directory:
git checkout v1.20.0 # or the version you want to update to
git submodule update --recursive
make -C mpy-crossThe process to update esp-idf is similar:
git checkout release/v4.4 # or the version you want to update to
git submodule update --recursive
./install.shThen, you can build the firmware as described above.