Skip to content

Instantly share code, notes, and snippets.

@tomazursic
Last active April 13, 2021 21:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomazursic/89950af79ca7827ca05d00114d94d6ec to your computer and use it in GitHub Desktop.
Save tomazursic/89950af79ca7827ca05d00114d94d6ec to your computer and use it in GitHub Desktop.

Pycom building a firmware image

Requirements

  • Pycom MicroPython source code
  • Xtensa gcc compiler
  • Espressif IoT Development Framework

Debian/Ubuntu

sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-serial

Build environment

Make build project directory

$ cd $HOME && mkdir pycom-build

Get Pycom MicroPython source code

$ git clone https://github.com/pycom/pycom-micropython-sigfox

Check out to latest stable version (output on date 2018-07-23)

$ git tags

    1.11.0.b1
    1.12.0.b1
    1.13.0.b1
    1.6.13.b1
    v1.14.0.b1
    v1.15.0.b1
    v1.16.0.b1
    v1.17.0.b1
    v1.17.2.b1
    v1.17.3.b1
    v1.18.0
    v1.18.0.r1    <--- Check out tag
    v1.18.0.r1-0.
    v1.19.0.b2
    v1.19.0.b3
    v1.19.0.b4

$ git checkout v1.18.0.r1

Install xtensa gcc compiler

$ cd $HOME/pycom-build
$ 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/pycom-build/xtensa-esp32-elf/bin

Verify content of $PATH variables:

$ echo $PATH

Verify toolchain installation:

$ xtensa-esp32-elf-gcc -v

If command returns xtensa-esp32-elf-gcc: Command not found recheck the the export command!

Install ESP-IDF

$ cd $HOME/pycom-build
$ git clone https://github.com/pycom/pycom-esp-idf.git
$ cd pycom-esp-idf
$ git submodule update --init
$ export IDF_PATH=$HOME/pycom-build/pycom-esp-idf

More details:

Build process

1. Build mpy-cross

$ $HOME/pycom-build/pycom-micropython-sigfox
$ cd mpy-cross && make clean && make && cd ..

4. Frozen modules (OPTIONAL)

Add custom python modules to include in the firmware in following directory:

$HOME/pycom-build/pycom-micropython-sigfoxesp32/frozen

3. Board build

Currently support for the following BOARD types:

WIPY LOPY SIPY GPY FIPY LOPY4

Build process:

$ cd $HOME/pycom-build/pycom-micropython-sigfoxesp32/esp32
$ make BOARD=LOPY clean
$ make BOARD=LOPY -j5 TARGET=boot

For LoRa need to specify the LORA_BAND

# LORA_BAND=USE_BAND_868
# LORA_BAND=USE_BAND_915

$ make BOARD=LOPY -j5 LORA_BAND=USE_BAND_868 TARGET=app

4. Flash the image on board

Extension board

Pysense board

# On linux
$ make BOARD=LOPY -j5 ESPPORT=/dev/ttyACM0 flash

Connect GND to P23

# On linux
$ make BOARD=LOPY -j5 ESPPORT=/dev/ttyUSB1 flash

# On MacOSX
$ make ESPPORT=/dev/tty.usbserial-DQ008HQY flash

Reference

https://github.com/pycom/pycom-micropython-sigfox#the-esp32-version

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