Last active
June 14, 2020 01:25
-
-
Save tdamsma/b49359448924d7aa816d50be2170a610 to your computer and use it in GitHub Desktop.
Dockerfile for building pfalcon's branch of micropython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:bionic | |
ARG DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update -qq \ | |
&& apt-get install -qqy \ | |
autoconf \ | |
automake \ | |
bash \ | |
bison \ | |
build-essential \ | |
bzip2 \ | |
flex \ | |
g++ \ | |
gawk \ | |
gcc \ | |
git \ | |
gperf \ | |
help2man \ | |
libexpat-dev \ | |
libffi-dev \ | |
libtool \ | |
libtool-bin \ | |
make \ | |
ncurses-dev \ | |
pkg-config \ | |
python \ | |
python-dev \ | |
python-serial \ | |
python3 \ | |
python3-pip \ | |
sed \ | |
texinfo \ | |
unrar-free \ | |
unzip \ | |
wget \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN pip3 install pyparsing | |
RUN useradd --no-create-home micropython | |
RUN mkdir /esp | |
RUN chown -R micropython:micropython esp | |
USER micropython | |
WORKDIR /esp | |
# Download crosstool-NG and build it: | |
RUN git clone -b xtensa-1.22.x https://github.com/espressif/crosstool-NG.git | |
RUN cd crosstool-NG && ./bootstrap && ./configure --enable-local && make install | |
# Build the toolchain: | |
RUN cd crosstool-NG && ./ct-ng xtensa-esp32-elf | |
RUN cd crosstool-NG && ./ct-ng build | |
RUN cd crosstool-NG && chmod -R u+w builds/xtensa-esp32-elf | |
ARG BRANCH=master | |
# Find correct version of esp-idf, depends on selected branch | |
ADD --chown=micropython:micropython https://raw.githubusercontent.com/pfalcon/micropython/$BRANCH/ports/esp32/Makefile /tmp/ESP32-Makefile | |
RUN git clone https://github.com/espressif/esp-idf.git | |
RUN cd esp-idf && cat /tmp/ESP32-Makefile | grep "^ESPIDF_SUPHASH_V4" | awk '{print $NF}' | xargs git checkout | |
RUN cd esp-idf && git submodule update --init --recursive | |
ENV PATH="${PATH}:/esp/crosstool-NG/builds/xtensa-esp32-elf/bin" | |
ENV ESPIDF="/esp/esp-idf" | |
# Cache buster for git clone #https://stackoverflow.com/questions/36996046/how-to-prevent-dockerfile-caching-git-clone | |
ADD https://api.github.com/repos/pfalcon/micropython/git/refs/heads/$BRANCH version.json | |
RUN git clone --recursive https://github.com/pfalcon/micropython.git \ | |
&& cd micropython && git checkout $BRANCH && git submodule update --init | |
RUN make --directory /esp/micropython -C mpy-cross | |
RUN make --directory /esp/micropython/ports/unix | |
# add modules to be frozen in the built firmware, customize as required | |
RUN cd /esp/micropython/ports/unix && ./pycopy -m upip install -p ../esp32/modules \ | |
micropython-uasyncio \ | |
micropython-uaiohttpclient \ | |
micropython-logging | |
# add drivers to be frozen in the built firmware, customize as required | |
RUN ln /esp/micropython/drivers/display/ssd1306.py /esp/micropython/ports/esp8266/modules/ssd1306.py | |
RUN ln /esp/micropython/drivers/sdcard/sdcard.py /esp/micropython/ports/esp8266/modules/sdcard.py | |
# or download from github | |
RUN wget -O /esp/micropython/ports/esp8266/modules/bmp280.py https://raw.githubusercontent.com/dafvid/micropython-bmp280/master/bmp280.py | |
# install required pyparsing version | |
USER root | |
RUN pip3 install "pyparsing==2.3.1" | |
# Finally build the firmware | |
RUN make --directory /esp/micropython/ports/esp32 |
@etjones, you're welcome. I was meaning to somehow get this merged in the docs or something, but haven't gotten to it yet. Glad it worked
Well, not sure it worked yet... Got through an hour of builds, and it looks like there may have been a change in the pycopy repo that builds the executable as pycopy
rather than micropython
:
From the end of my run:
CC modusocket.c
CC modffi.c
CC ../../lib/mp-readline/readline.c
CC ../../lib/timeutils/timeutils.c
CC ../../lib/oofatfs/ff.c
CC ../../lib/oofatfs/ffunicode.c
LINK pycopy
text data bss dec hex filename
2 0 0 2 2 build/build/frozen.o
4976 3720 0 8696 21f8 build/build/frozen_mpy.o
319619 6280 2184 328083 50193 pycopy
make: Leaving directory '/esp/micropython/ports/unix'
Removing intermediate container ec15544e3e7c
---> e3a6509150ff
Step 26/28 : RUN cd /esp/micropython/ports/unix && ./micropython -m upip install -p ../esp32/modules micropython-uasyncio micropython-uaiohttpclient micropython-urequests micropython-logging
---> Running in b117c8fff6a7
/bin/sh: 1: ./micropython: not found
The command '/bin/sh -c cd /esp/micropython/ports/unix && ./micropython -m upip install -p ../esp32/modules micropython-uasyncio micropython-uaiohttpclient micropython-urequests micropython-logging' returned a non-zero code: 127
So... I'll let you know if I can convince this to work. It may just be a matter of changing the executable in command 26
Good to know, I'll update it if needed
Indeed this fixes it, I have updated the gist and build instructions, they work for me now
Just worked for me, too. Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for putting this together! I've tried and failed to get PyCopy built on my machine, and this is a much better way of doing it.