-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tools for setup-free CircuitPython builds #9349
base: main
Are you sure you want to change the base?
Changes from 6 commits
92b9df0
382ade1
539d02f
0dba0e4
d9bef70
2ce8449
965707e
bb190a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
FROM ubuntu:24.04 as build | ||
|
||
RUN apt-get update && apt-get install -y build-essential software-properties-common git git-lfs gettext cmake mtools wget curl which | ||
|
||
ARG ARM_TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/ | ||
ARG ARM_TOOLCHAIN_FILE=arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.gz | ||
ARG DOWNLOAD_DIR=/root/bin | ||
|
||
RUN mkdir ${DOWNLOAD_DIR} && cd ${DOWNLOAD_DIR} && curl -LO ${ARM_TOOLCHAIN_URL}/${ARM_TOOLCHAIN_FILE} | ||
|
||
RUN cd ${DOWNLOAD_DIR} && pwd && tar -xf ${ARM_TOOLCHAIN_FILE} | ||
|
||
ARG ARM_TOOLCHAIN_DIR=arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi | ||
|
||
ENV PATH="${PATH}:${DOWNLOAD_DIR}/${ARM_TOOLCHAIN_DIR}/bin" | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -y | sh | ||
|
||
RUN apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build | ||
|
||
RUN apt-get install -y ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 python-is-python3 | ||
|
||
ENV IDF_TOOLS_PATH=/root/.espressif | ||
ENV IDF_PATH=/root/esp/esp-idf | ||
|
||
RUN mkdir -p /root/esp && cd /root/esp && git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git && ls | ||
|
||
RUN cd /root/esp/esp-idf && ./install.sh all | ||
|
||
RUN curl -LO https://raw.githubusercontent.com/adafruit/circuitpython/main/requirements-dev.txt | ||
|
||
RUN curl -LO https://raw.githubusercontent.com/adafruit/circuitpython/main/requirements-doc.txt | ||
|
||
RUN . /root/esp/esp-idf/export.sh && pip3 install --upgrade -r requirements-dev.txt && \ | ||
pip3 install --upgrade -r requirements-doc.txt | ||
|
||
COPY build.sh /root | ||
|
||
RUN chmod +x /root/build.sh | ||
|
||
ENTRYPOINT ["/bin/bash"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Building CircuitPython with Docker | ||
|
||
On a Linux machine with `docker` installed, an executable for any supported CircuitPython board can be built without setup by invoking the command `sudo tools/docker-build/build <port> <board-name> <option>` from the CircuitPython root directory. For example, if the CircuitPython repo is located at `~/circuitpython` the commands | ||
|
||
```bash | ||
cd ~/circuitpython | ||
sudo tools/docker-build/build espressif adafruit_feather_esp32s2_reverse_tft | ||
sudo tools/docker-build/build raspberrypi waveshare_rp2040_zero | ||
sudo tools/docker-build/build atmel-samd grandcentral_m4_express DEBUG=1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it typical that docker usage runs things as root? It seems like the whole build will be run as root in the docker container. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this is one of the things that could probably be improved. The container doesn't have to be run with |
||
``` | ||
|
||
will build executables for a Feather ESP32S2 board, a Waveshare RP2040 board and an Adafruit Grand Central M4 Express board, and the Grand Central build will include debugging information. | ||
|
||
## Building a new Docker image | ||
|
||
The `build` script uses tools built into a container image pulled from a public Docker Hub repository. If you like, you can build your own image from the `Dockerfile` in this directory with the command | ||
|
||
```bash | ||
docker build -t <name> . | ||
``` | ||
|
||
Where <name> is the name that will be applied to the image. If you then change the value of `$LOCAL_IMAGE` in the `build` script to match <name>, `build` will use the new image for building CircuitPython. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
REMOTE_IMAGE="timchinowsky/build_circuitpython" | ||
LOCAL_IMAGE="timchinowsky/build_circuitpython" | ||
|
||
make fetch-all-submodules | ||
docker pull $REMOTE_IMAGE | ||
docker run -it -v .:/root/circuitpython $LOCAL_IMAGE /root/build.sh $1 $2 $3 | ||
chown -R `(stat -c '%u' Makefile)`:`(stat -c '%g' Makefile)` * | ||
chown -R `(stat -c '%u' Makefile)`:`(stat -c '%g' Makefile)` .git | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes ownership of the files created by the container back to the owner of the repo (as cribbed from the metadata of |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
DIR=$(pwd) | ||
|
||
git config --global --add safe.directory /root/circuitpython | ||
git config --global --add safe.directory /root/circuitpython/ports/espressif/esp-idf | ||
|
||
cd /root/circuitpython | ||
|
||
make fetch-tags | ||
|
||
. /root/esp/esp-idf/export.sh | ||
|
||
cd /root/circuitpython/ports/$1 | ||
|
||
# cd $DIR | ||
|
||
make BOARD=$2 $3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets the requirements files from the tip of main, but I think you want to get them from the repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Dockerfile
is only used to build the image. I'm including it so that folks can see what it is doing (basically the same steps you would need to do on the command line to install the tools) and be empowered to create their own images.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the repo that CP is being built from? Can't do that because the image is given access to that repo at runtime, but the requirements need to be available at image build time so that the python built into the image can be configured. If you wanted to do it the other way, you'd need to have python pull in the requirements every time it is asked to build CP.