We will install all esp32 dependencies into ~/esp (you can change if you like)
mkdir -p ~/esp
cd ~/esp
From ~/esp, download esp-idf:
git clone https://github.com/espressif/esp-idf.git
From ~/esp, install ESP32 toolchain:
tar -xzf ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
Add these to .profile and then source ~/.profile
export IDF_PATH=$HOME/esp/esp-idf
export PATH="$HOME/esp/xtensa-esp32-elf/bin:$PATH"
Determine the git hash we need for esp-idf:
$ make
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
The ESPIDF variable has not been set, please set it to the root of the esp-idf repository.
See README.md for installation instructions.
Supported git hash: 6b3da6b1882f3b72e904cc90be67e9c4e3f369a9
Makefile:40: *** ESPIDF not set. Stop.
Checkout that hash from the ~/esp/esp-idf repo and install submodules:
git checkout <hash-from-previous-step>
git submodule update --init --recursive
Then build the firmware using the the git hash reported above (6b3da6b1882f3b72e904cc90be67e9c4e3f369a9 in the example):
ESPIDF=$HOME/esp/esp-idf make
Lastly, we need to erase the firmware currently on the m5stack and replace it with build/firmware.bin
To do this we need to install the Python esptool package (use a virtual environment if you like):
pip install esptool
Next we need to find the serial port where we can connect our m5stack. Run the following command once with the board unplugged, plug the board in and run it again. The difference between the outputs is the serial port (in this example /dev/ttyUSB0):
python -m serial.tools.list_ports
# output:
# first time:
/dev/ttyS0
# second time:
/dev/ttyS0
/dev/ttyUSB0
Use esptool to erase current firmware:
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 erase_flash
Use esptool to upload build/firmware.bin to the port from 2 steps above:
esptool.py --chip esp32 --port <port-from-2-steps-above> --baud 460800 write_flash -z 0x1000 build/firmware.bin