-
Notifications
You must be signed in to change notification settings - Fork 233
Build instructions ESP8266 (Docker)
Maxim Kulkin edited this page Jul 1, 2022
·
8 revisions
Here is build setup that I use. Note that you need Docker, python2.7 and python pip
tool installed.
- Create an empty directory and change into it.
- Create a file
esp-sdk-dockerfile
with following content:
FROM ubuntu:20.04 as builder
RUN groupadd -g 1000 docker && useradd docker -u 1000 -g 1000 -s /bin/bash -d /build
RUN mkdir /build && chown docker:docker /build
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt-get install -y \
make unrar-free autoconf automake libtool gcc g++ gperf \
flex bison texinfo gawk ncurses-dev libexpat-dev python3-dev python3 python3-serial \
sed git unzip bash help2man wget bzip2 libtool-bin
# Manually download some dependent packages as builtin URLs are not working
RUN su docker -c " \
wget -P /build https://libisl.sourceforge.io/isl-0.14.tar.bz2 ; \
wget -P /build https://github.com/libexpat/libexpat/releases/download/R_2_1_0/expat-2.1.0.tar.gz ; \
"
# Checkout main source code
RUN su docker -c " \
git clone --recursive https://github.com/pfalcon/esp-open-sdk.git /build/esp-open-sdk ; \
"
COPY crosstool-NG-configure.patch /build
# Patch source code to make it work on newer Linux version
RUN su docker -c " \
cd /build/esp-open-sdk ; \
patch -p1 < /build/crosstool-NG-configure.patch ; \
echo CT_LOCAL_TARBALLS_DIR=/build >> crosstool-config-overrides ; \
echo CT_DEBUG_gdb=n >> crosstool-config-overrides ; \
cd esptool ; \
git checkout v1.3 ; \
"
# Build code
RUN su docker -c "cd /build/esp-open-sdk && make STANDALONE=n"
FROM ubuntu:20.04
RUN DEBIAN_FRONTEND=noninteractive apt update && \
DEBIAN_FRONTEND=noninteractive apt install -y make python3 python3-serial
COPY --from=builder /build/esp-open-sdk/xtensa-lx106-elf /opt/xtensa-lx106-elf
ENV PATH /opt/xtensa-lx106-elf/bin:$PATH
- Create a file
crosstool-NG-configure.patch
with following content:
diff --git a/crosstool-NG/configure.ac b/crosstool-NG/configure.ac
index 5d512fe8..bf9c30f3 100644
--- a/crosstool-NG/configure.ac
+++ b/crosstool-NG/configure.ac
@@ -190,7 +190,7 @@ AC_CACHE_VAL([ac_cv_path__BASH],
AC_CACHE_CHECK([for bash >= 3.1], [ac_cv_path__BASH],
[AC_PATH_PROGS_FEATURE_CHECK([_BASH], [bash],
[[_BASH_ver=$($ac_path__BASH --version 2>&1 \
- |$EGREP '^GNU bash, version (3\.[1-9]|4)')
+ |$EGREP '^GNU bash, version (3\.[1-9]|[4-9])')
test -n "$_BASH_ver" && ac_cv_path__BASH=$ac_path__BASH ac_path__BASH_found=:]],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([could not find bash >= 3.1])])])
- Create a file
esp-rtos-dockerfile
with following content:
FROM ubuntu:20.04 as builder
RUN apt-get update && apt-get install -y git
RUN git clone --recursive https://github.com/Superhouse/esp-open-rtos.git /opt/esp-open-rtos
FROM esp-sdk:latest
RUN apt-get update && apt-get install -y python3 python-is-python3
COPY --from=builder /opt/esp-open-rtos /opt/esp-open-rtos
ENV SDK_PATH /opt/esp-open-rtos
- Build
esp-sdk
Docker container:
docker build . -f esp-sdk-dockerfile -t esp-sdk
- Build
esp-rtos
Docker container:
docker build . -f esp-rtos-dockerfile -t esp-rtos
- Clone
esp-open-rtos
repository:
git clone --recursive https://github.com/SuperHouse/esp-open-rtos.git
- Install esptool.py:
pip install esptool
- Clone
esp-homekit-demo
repository:
git clone --recursive https://github.com/maximkulkin/esp-homekit-demo.git
- Setup enviroment variables:
export SDK_PATH="$(pwd)/esp-open-rtos"
export ESPPORT=/dev/tty.SLAB_USBtoUART
To find out what is the name of your USB device to put to ESPPORT environment variable, first do ls /dev/tty.*
before you connect your ESP8266 to USB, then do same command after you have connected it to USB and notice which new device has appeared.
- Copy wifi.h.sample -> wifi.h and edit it with correct WiFi SSID and password.
- Configure settings
- To build an example", first change into
esp-homekit-demo
directory (into it's root directory:
cd esp-homekit-demo
Then build example you want (e.g. sonoff_basic
) by running
docker run -it --rm -v "$(pwd)":/project -w /project esp-rtos make -C examples/sonoff_basic all
Then flash it (and optionally immediately run monitor)
make -C examples/sonoff_basic flash monitor
NOTE: personally I do a lot of stuff in Docker containers, so I have following helper function in my ~/.bashrc:
docker-run() {
docker run -it --rm -v "$(pwd)":/project -w /project "$@"
}
Then, to run a container I just do
docker-run esp-rtos make -C examples/sonoff_basic all