base dockerfile directly on ubuntu and add esp8266 toolchain

This commit is contained in:
Robin Appelman 2020-10-24 16:10:26 +02:00
parent 35de27629f
commit ca642db108
3 changed files with 40 additions and 15 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
/target
/Cargo.lock

View File

@ -1,9 +1,27 @@
FROM espressif/idf:release-v4.1
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
ARG toolchain=nightly-2020-10-09
ARG xtensalink="https://github.com/espressif/crosstool-NG/releases/download/esp-2020r3/xtensa-esp32-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz"
ARG xtensa_esp32_link="https://github.com/espressif/crosstool-NG/releases/download/esp-2020r3/xtensa-esp32-elf-gcc8_4_0-esp-2020r3-linux-amd64.tar.gz"
ARG xtensa_lx106_link="https://dl.espressif.com/dl/xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz"
RUN apt-get update -y && apt-get install -y build-essential cmake clang-6.0
RUN apt-get update && apt-get install -y \
apt-utils \
ca-certificates \
curl \
flex \
git \
unzip \
wget \
xz-utils \
zip \
python \
ninja-build \
build-essential \
cmake \
clang-6.0 \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
# Init rust-xtensa
RUN git clone --depth 1 https://github.com/MabezDev/rust-xtensa /rust-xtensa
@ -11,24 +29,29 @@ RUN cd rust-xtensa && \
./configure --experimental-targets=Xtensa && \
./x.py build --stage 2
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup toolchain install ${toolchain} --allow-downgrade --profile minimal
ENV CUSTOM_RUSTC=/rust-xtensa
ENV RUST_BACKTRACE=1
ENV XARGO_RUST_SRC=$CUSTOM_RUSTC/library
ENV RUSTC=$CUSTOM_RUSTC/build/x86_64-unknown-linux-gnu/stage2/bin/rustc
ENV RUSTDOC=$CUSTOM_RUSTC/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc
# Init xtensa-esp32-elf-gcc8
RUN wget ${xtensalink} -O /tmp/xtensa-esp32-elf-gcc8.tar.gz && \
RUN wget -q ${xtensa_esp32_link} -O /tmp/xtensa-esp32-elf-gcc8.tar.gz && \
mkdir -p /esp && \
tar -xzf "/tmp/xtensa-esp32-elf-gcc8.tar.gz" -C /esp && \
rm "/tmp/xtensa-esp32-elf-gcc8.tar.gz"
ENV PATH="$PATH:/esp/xtensa-esp32-elf/bin"
RUN wget -q ${xtensa_lx106_link} -O /tmp/xtensa-lx106-elf.tar.gz && \
mkdir -p /esp && \
tar -xzf "/tmp/xtensa-lx106-elf.tar.gz" -C /esp && \
rm "/tmp/xtensa-lx106-elf.tar.gz"
ENV PATH="$PATH:/esp/xtensa-lx106-elf/bin"
# Init espflash
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup toolchain install ${toolchain} --allow-downgrade --profile minimal
RUN cargo install cargo-espflash
RUN cargo install cargo-espflash cargo-xbuild xargo
WORKDIR /espflash

View File

@ -13,13 +13,13 @@ If you have an ELF file that flashes correctly with `esptool.py` but not with th
## Quickstart - Docker
The docker image `esp-rs/espflash` contains all necessary toolchains and tooling including espflash to build and flash.
To clone, build and flash the [xtensa-rust-quickstart](https://github.com/MabezDev/xtensa-rust-quickstart) esp32 example run the following:
The docker image `esprs/espflash` contains all necessary toolchains and tooling including espflash to build and flash.
To clone, build and flash the [esp32-hal](https://github.com/esp-rs/esp32-hal) examples run the following:
```cmd
git clone --depth 1 https://github.com/MabezDev/xtensa-rust-quickstart.git
cd xtensa-rust-quickstart
docker run -v "$(pwd):/espflash" --device=/dev/ttyUSB0 -ti esp-rs/espflash --release --tool=cargo --chip=esp32 --example=esp32 --features="xtensa-lx-rt/lx6 xtensa-lx/lx6 esp32-hal" /dev/ttyUSB0
git clone https://github.com/esp-rs/esp32-hal
cd esp32-hal
docker run -v "$(pwd):/espflash" --device=/dev/ttyUSB0 -ti esprs/espflash --release --tool=cargo --example=blinky /dev/ttyUSB0
```
### Custom Docker Build
@ -27,5 +27,5 @@ docker run -v "$(pwd):/espflash" --device=/dev/ttyUSB0 -ti esp-rs/espflash --rel
```cmd
git clone --depth 1 https://github.com/esp-rs/espflash.git
cd espflash
docker build -t esp-rs/espflash .
docker build -t esprs/espflash .
```