Skip to content

Commit 4e5e742

Browse files
Lawrence NahumJamie C. Driver
authored andcommitted
build: use qemu from espressif rather than custom built
Also use bookworm-slim, minimize docker layers
1 parent 5dba69c commit 4e5e742

File tree

9 files changed

+31
-44
lines changed

9 files changed

+31
-44
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ stages:
77
- test
88
- deploy
99

10-
image: blockstream/verde@sha256:391a4337c174f2eb47dc9f31d7e25d19a5f101bbc07fa8a296866c1ee52b8473
10+
image: blockstream/verde@sha256:9171360dae48d3fba7c0f36ab5eb45e2529d178a603e89197cb08fb123ca619e
1111

1212
test_bip85_rsa_key_gen:
1313
tags:

Dockerfile

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
1-
FROM debian:bookworm@sha256:321341744acb788e251ebd374aecc1a42d60ce65da7bd4ee9207ff6be6686a62 AS base
2-
RUN dpkg --add-architecture i386 && apt-get update -qq && apt-get upgrade --no-install-recommends --no-install-suggests -yqq && apt-get install --no-install-recommends --no-install-suggests -yqq git wget libncurses-dev flex bison gperf libffi-dev libssl-dev dfu-util cmake ninja-build build-essential ca-certificates ccache curl make pkg-config python3 python3-dev python3-pip python3-setuptools python3-serial python3-click python3-cryptography python3-future python3-pyparsing python3-pyelftools python3-pkg-resources python3-wheel python3-venv python3-sphinx unzip bluez-tools bluez libusb-1.0-0 clang lld clang-format libglib2.0-dev libpixman-1-dev libgcrypt20-dev virtualenv libslirp-dev gcc-multilib libc6-dev-i386 libsdl2-dev:i386 libcurl4-openssl-dev:i386 && apt-get -yqq autoremove && apt-get -yqq clean && rm -rf /var/lib/apt/lists/* /var/cache/* /tmp/*
3-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
4-
RUN python3 -m pip install --break-system-packages --user pycodestyle
5-
6-
FROM base AS esp-idf
1+
FROM debian:bookworm-slim@sha256:12c396bd585df7ec21d5679bb6a83d4878bc4415ce926c9e5ea6426d23c60bdc
72

83
# These ARGs are easily parseable (eg by HWI)
94
ARG ESP_IDF_BRANCH=v5.4
105
ARG ESP_IDF_COMMIT=67c1de1eebe095d554d281952fde63c16ee2dca0
11-
RUN mkdir ~/esp && cd ~/esp && git clone --quiet --depth=1 --branch ${ESP_IDF_BRANCH} --single-branch --recursive --shallow-submodules https://github.com/espressif/esp-idf.git
12-
RUN cd ~/esp/esp-idf && git checkout ${ESP_IDF_COMMIT} && ./install.sh esp32 esp32s3
13-
14-
FROM base AS esp-qemu
15-
16-
# These ARGs are easily parseable (eg by HWI)
17-
ARG ESP_QEMU_BRANCH=esp-develop-9.0.0-20240606
18-
ARG ESP_QEMU_COMMIT=abb5ce24386972e048b401f9eca10e90b8427a20
19-
RUN git clone --quiet --depth 1 --branch ${ESP_QEMU_BRANCH} --single-branch --shallow-submodules https://github.com/espressif/qemu.git \
20-
&& cd qemu && git checkout ${ESP_QEMU_COMMIT}
216

22-
RUN cd qemu && ./configure --target-list=xtensa-softmmu --prefix=/opt \
23-
--enable-gcrypt \
24-
--disable-sanitizers \
25-
--disable-strip --disable-user \
26-
--disable-capstone --disable-vnc \
27-
--disable-sdl --disable-gtk --enable-slirp \
28-
&& ninja -C build install && rm -fr /qemu
29-
30-
FROM esp-idf
31-
COPY --from=esp-qemu /opt /opt
32-
COPY requirements.txt /
337
SHELL ["/bin/bash", "-c"]
34-
RUN virtualenv -p python3 /venv && source /venv/bin/activate && pip install --require-hashes -r /requirements.txt
8+
COPY requirements.txt /
9+
10+
RUN dpkg --add-architecture i386 && apt-get update -qq && apt-get upgrade --no-install-recommends --no-install-suggests -yqq && apt-get install --no-install-recommends --no-install-suggests -yqq git wget libncurses-dev flex bison gperf libffi-dev libssl-dev dfu-util cmake ninja-build build-essential ca-certificates ccache curl make pkg-config python3 python3-dev python3-pip python3-setuptools python3-serial python3-click python3-cryptography python3-future python3-pyparsing python3-pyelftools python3-pkg-resources python3-wheel python3-venv python3-sphinx unzip bluez-tools bluez libusb-1.0-0 clang lld clang-format libglib2.0 libpixman-1-0 libsdl2-2.0-0 libgcrypt20-dev virtualenv libslirp0 gcc-multilib libc6-dev-i386 libsdl2-dev:i386 libcurl4-openssl-dev:i386 libmbedtls-dev:i386 && apt-get -yqq autoremove && apt-get -yqq clean && rm -rf /var/lib/apt/lists/* /var/cache/* /tmp/* /usr/share/doc /usr/share/man /usr/share/info /usr/share/locale /usr/share/common-licenses && update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && python3 -m pip install --break-system-packages --user pycodestyle && mkdir ~/esp && cd ~/esp && git clone --quiet --depth=1 --branch ${ESP_IDF_BRANCH} --single-branch --recursive --shallow-submodules https://github.com/espressif/esp-idf.git && cd ~/esp/esp-idf && git checkout ${ESP_IDF_COMMIT} && ./install.sh esp32 esp32s3 && python ~/esp/esp-idf/tools/idf_tools.py install qemu-xtensa && virtualenv -p python3 /venv && source /venv/bin/activate && pip install --require-hashes -r /requirements.txt

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM blockstream/verde@sha256:391a4337c174f2eb47dc9f31d7e25d19a5f101bbc07fa8a296866c1ee52b8473
1+
FROM blockstream/verde@sha256:9171360dae48d3fba7c0f36ab5eb45e2529d178a603e89197cb08fb123ca619e
22

33
RUN echo "source /root/esp/esp-idf/export.sh" >> /etc/bash.bashrc
44

Dockerfile.qemu

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM blockstream/verde@sha256:391a4337c174f2eb47dc9f31d7e25d19a5f101bbc07fa8a296866c1ee52b8473 as builder
1+
FROM blockstream/verde@sha256:9171360dae48d3fba7c0f36ab5eb45e2529d178a603e89197cb08fb123ca619e as builder
22

33
ARG SDK_CONFIG=configs/sdkconfig_qemu_psram.defaults
44

@@ -12,15 +12,13 @@ RUN ./tools/fwprep.py build/jade.bin build
1212
ENV PATH=$PATH:/jade/main/qemu
1313
RUN make-flash-img.sh
1414

15-
FROM debian:bookworm@sha256:321341744acb788e251ebd374aecc1a42d60ce65da7bd4ee9207ff6be6686a62
15+
FROM debian:bookworm-slim@sha256:12c396bd585df7ec21d5679bb6a83d4878bc4415ce926c9e5ea6426d23c60bdc
1616

1717
RUN apt-get update -yqq && apt-get install -yqq libpixman-1-dev libglib2.0-dev libslirp-dev libncurses-dev
1818

1919
COPY --from=builder /flash_image.bin /flash_image.bin
2020
COPY --from=builder /qemu_efuse.bin /qemu_efuse.bin
2121

22-
COPY --from=builder /opt/bin/qemu-system-xtensa /opt/bin/qemu-system-xtensa
23-
COPY --from=builder /opt/share/qemu /opt/share/qemu
2422
COPY --from=builder /jade/main/qemu/ /jade/main/qemu/
2523

2624
ENV PATH=$PATH:/jade/main/qemu

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ mkdir ~/esp
4242
cd ~/esp
4343
git clone -b v5.4 --recursive https://github.com/espressif/esp-idf.git
4444
cd ~/esp/esp-idf && git checkout 67c1de1eebe095d554d281952fde63c16ee2dca0 && ./install.sh --enable-gdbgui esp32 esp32s3
45+
python ~/esp/esp-idf/tools/idf_tools.py install qemu-xtensa
4546
```
4647

4748
Set up the environmental variables:

main/qemu/qemu_ci_flash.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
set -eo pipefail
33

4+
. $HOME/esp/esp-idf/export.sh
5+
46
# this is the minimum to run qemu
57
# build/qemu-system-xtensa -nographic \
68
# -machine esp32 \
@@ -17,18 +19,17 @@ set -eo pipefail
1719
# -serial pty)
1820
# -serial mon:stdio)
1921

20-
2122
# if you want to put qemu in a state where it can be used with idf.py flash or esptool.py
2223
# -global driver=esp32.gpio,property=strap_mode,value=0x0f \
23-
24-
/opt/bin/qemu-system-xtensa -nographic \
24+
qemu-system-xtensa -nographic \
2525
-machine esp32 \
2626
-m 4M \
2727
-drive file=/flash_image.bin,if=mtd,format=raw \
2828
-nic user,model=open_eth,id=lo0,hostfwd=tcp:0.0.0.0:30121-:30121 \
2929
-drive file=/qemu_efuse.bin,if=none,format=raw,id=efuse \
3030
-global driver=nvram.esp32.efuse,property=drive,value=efuse \
3131
-serial pty &
32+
3233
sleep 4
3334

3435
source /venv/bin/activate

main/qemu/qemu_gdb.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
22

3-
pkill -f qemu-system-xtensa
3+
set -eo pipefail
44

5-
/opt/bin/qemu-system-xtensa -s -S -nographic \
5+
. $HOME/esp/esp-idf/export.sh
6+
7+
pkill -f qemu-system-xtensa | true
8+
9+
qemu-system-xtensa -s -S -nographic \
610
-machine esp32 \
711
-m 4M \
812
-drive file=/flash_image.bin,if=mtd,format=raw \
@@ -19,4 +23,3 @@ xtensa-esp32-elf-gdb /jade/build/jade.elf \
1923
-ex "tb app_main" -ex "c" \
2024
-ex "b main.c:120"\
2125
-ex 'info b' -ex 'set print pretty on'
22-

main/qemu/qemu_reboot.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
22

3-
pkill -f qemu-system-xtensa
3+
set -eo pipefail
44

5-
/opt/bin/qemu-system-xtensa -nographic \
5+
. $HOME/esp/esp-idf/export.sh
6+
7+
pkill -f qemu-system-xtensa || true
8+
9+
qemu-system-xtensa -nographic \
610
-machine esp32 \
711
-m 4M \
812
-drive file=/flash_image.bin,if=mtd,format=raw \

main/qemu/qemu_run.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
2+
#
3+
set -eo pipefail
24

3-
pkill -f qemu-system-xtensa
5+
. $HOME/esp/esp-idf/export.sh
46

5-
/opt/bin/qemu-system-xtensa -nographic \
7+
pkill -f qemu-system-xtensa | true
8+
9+
qemu-system-xtensa -nographic \
610
-machine esp32 \
711
-m 4M \
812
-drive file=/flash_image.bin,if=mtd,format=raw \

0 commit comments

Comments
 (0)