├── Dockerfile ├── LICENSE └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | LABEL Name=esp32-micropython-image-builder Version=0.0.1 3 | ENV ESPIDF /data/esp-idf 4 | ENV MICROPYTHON /data/micropython 5 | 6 | RUN apt update && apt -y install git build-essential python-virtualenv gcc git wget make libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-cryptography python-future python-pyparsing libffi-dev libssl-dev && rm -rf /var/lib/apt/lists/* 7 | 8 | RUN mkdir -p ${ESPIDF} && mkdir -p ${MICROPYTHON} 9 | 10 | RUN git clone -b v1.12 https://github.com/micropython/micropython.git ${MICROPYTHON} && wget --quiet -O ${MICROPYTHON}/ports/esp32/modules/urequests.py https://raw.githubusercontent.com/micropython/micropython-lib/master/urequests/urequests.py 11 | 12 | RUN git clone https://github.com/espressif/esp-idf.git ${ESPIDF} && cd ${ESPIDF} && git checkout $(grep 'ESPIDF_SUPHASH_V3 :=' ${MICROPYTHON}/ports/esp32/Makefile | awk '{print $3}') && git submodule update --init --recursive 13 | 14 | RUN wget --quiet -O /data/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz && tar xzf /data/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz -C /data 15 | 16 | ENV PATH /data/xtensa-esp32-elf/bin:${PATH} 17 | 18 | RUN cd ${MICROPYTHON}/mpy-cross && make mpy-cross 19 | 20 | RUN cd ${MICROPYTHON}/ports/esp32 && make submodules 21 | 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Derek Morton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # esp32-micropython-image-builder 2 | Build ESP32 Micropython images with your custom code included 3 | 4 | This repository creates two separate images: 5 | - `stable` - this image is built from the most recently tagged release of MicroPython 6 | - `unstable` - this image is built from the tip of the master MicroPython repository 7 | 8 | ## Example Code 9 | - Create a `Dockerfile` alongside your code to copy your file(s) into the image: 10 | 11 | ``` 12 | FROM dcmorton/esp32-micropython-image-builder:stable 13 | 14 | COPY main.py ${MICROPYTHON}/ports/esp32/modules 15 | 16 | WORKDIR ${MICROPYTHON}/ports/esp32 17 | 18 | ENTRYPOINT ["make", "PYTHON=python"] 19 | ``` 20 | 21 | - Build the image from the `Dockerfile` 22 | ``` 23 | $ docker build -t esp32-image . 24 | ``` 25 | 26 | - Run docker container with above docker image 27 | ``` 28 | docker run -v $PWD/output:/data/micropython/ports/esp32/build-GENERIC/ esp32-image 29 | ``` 30 | 31 | - The firmware file will be in `$PWD/output/firmware.bin`. 32 | 33 | ## More Examples 34 | The [esp32-dht22-upython](https://github.com/dcmorton/esp32-dht22-upython) project uses a similar [Dockerfile](https://github.com/dcmorton/esp32-dht22-upython/blob/master/Dockerfile) and [GitHub Action](https://github.com/dcmorton/esp32-dht22-upython/blob/master/.github/workflows/build.yml) to build a firmware image and upload the image to AWS S3. 35 | --------------------------------------------------------------------------------