Skip to content

Instantly share code, notes, and snippets.

@tomazursic
Last active August 28, 2018 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomazursic/1335b5442be4d84018c46870ca345a0a to your computer and use it in GitHub Desktop.
Save tomazursic/1335b5442be4d84018c46870ca345a0a to your computer and use it in GitHub Desktop.
Notes for building micropython

MicroPython

Build

Install dependences

# Debian/ubuntu
$ sudo apt-get install build-essential libreadline-dev libffi-dev git pkg-config

Get cross compiler for ESP

$ cd $HOME
$ wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
$ tar -xzf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
$ export PATH=$PATH:$HOME/xtensa-esp32-elf/bin

Get ESPIDF

$ git clone https://github.com/espressif/esp-idf

Clone source

$ git clone --recurse-submodules https://github.com/micropython/micropython.git

# Set paths and varibles
$ export IDF_PATH=$HOME/workspace/esp-idf
$ export PATH=$PATH:$HOME/workspace/xtensa-esp32-elf/bin

IDF git tag

Check for supported ESP IDF git tag

$ cd ports/esp32

Get supported branch for `esp-idf`:

$ make idf-version

Or chack inisde Make file and find ESPIDF_SUPHASH

# Example
ESPIDF_SUPHASH := 30545f4cccec7460634b656d278782dd7151098e

Inside esp-idf source directory run:

git checkout -b <HASH from Makefile>
git submodule update --init --recursive

Make cross

$ cd micropython
$ make -C mpy-cross

LoRa driver

Source: https://github.com/rcludwick/Lora_driver_for_MicroPython_on_ttgo

  • Link src/examples and src/sx127x directories into the ports/esp32/modules directory.
  • Also link drivers/display (from micropython) into the ports/esp32/modules directory.
$ cd ports/esp32/modules
$ ln -s ../../../../LoRa_Driver_MicroPython_esp32/src/examples .
$ ln -s ../../../../LoRa_Driver_MicroPython_esp32/src/sx127x .
$ ln -s ../../../drivers/display .

Custom build

Follow the micropython instructions for building the esp32 port.

$ cd ports/esp32
$ make -j4
$ make erase
$ make deploy


# Flash to a TTGO Module

# Connect to REPL for the TTGO and run examples.duplex.test.main()

Debug:

cd esp-idf/components/esptool_py/esptool 
python espefuse.py --port /dev/ttyUSB0 summary
python espefuse.py --port /dev/ttyUSB0 dump

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment