qemu: fix outdated scripts/documenation
What changed, and why it matters
This commit only updates QEMU emulator helper scripts and documentation. It renames a script from make-flash-img.sh to make_flash_img.sh, adds command-line options, updates README instructions, and removes an unused reboot script. There is no change to the actual Jade firmware or wallet security code.
No security action required. Treat as routine developer-experience/maintenance update.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a maintenance patch for QEMU-based development/testing workflows. It renames make-flash-img.sh to make_flash_img.sh, parameterizes output paths, adds argument parsing to qemu_run.sh and run_emulator.sh, updates Dockerfile.qemu and GitLab CI references, refreshes README.md to reference blockstream/jade_builder and switch_to.sh, and deletes qemu_reboot.sh. No firmware source, cryptography, protocol handling, or hardware-abstraction code is modified.
Changed components
main/qemu/make-flash-img.shmain/qemu/make_flash_img.shmain/qemu/qemu_run.shmain/qemu/run_emulator.shmain/qemu/qemu_reboot.shmain/qemu/README.mdDockerfile.qemugitlab/flash.ymlInspect captured patch +109 / −55
diff --git a/Dockerfile.qemu b/Dockerfile.qemu
index 798f018..e162f98 100644
--- a/Dockerfile.qemu
+++ b/Dockerfile.qemu
@@ -8,5 +8,5 @@ WORKDIR /jade
COPY . .
RUN ./tools/switch_to.sh qemu ${QEMU_CONFIG_ARGS}
RUN cd /opt/esp/idf && . ./export.sh && cd /jade && idf.py all && ./tools/fwprep.py build/jade.bin build
-RUN ./main/qemu/make-flash-img.sh
+RUN ./main/qemu/make_flash_img.sh
CMD [ "/jade/main/qemu/qemu_run.sh", "$QEMU_GDB" ]
diff --git a/gitlab/flash.yml b/gitlab/flash.yml
index 587b1f7..6b66e3a 100644
--- a/gitlab/flash.yml
+++ b/gitlab/flash.yml
@@ -13,7 +13,7 @@
GIT_SUBMODULE_STRATEGY: none
script:
- mv $(echo $CI_JOB_NAME | sed "s/^${CI_JOB_STAGE}/build_test/") build
- - ./main/qemu/make-flash-img.sh
+ - ./main/qemu/make_flash_img.sh
- ./main/qemu/qemu_ci_flash.sh --sample-percent=33
artifacts:
expire_in: 1 week
diff --git a/main/qemu/README.md b/main/qemu/README.md
index 2d8f95c..1d56333 100644
--- a/main/qemu/README.md
+++ b/main/qemu/README.md
@@ -2,28 +2,28 @@ Run the following:
```docker build . -t local_jade```
-The above creates the docker image with all the required dependencies. You can also look into fetching instead blockstream/verde with
-```docker pull blockstream/verde```
+The above creates the docker image with all the required dependencies. You can also look into fetching instead blockstream/jade_builder with (or see https://hub.docker.com/r/blockstream/jade_builder/tags for recent images)
+```docker pull blockstream/jade_builder@sha256:148353098cf71916de389e1f9534550a841cd6efbd1d8f2c4a6ef496d3291dbe```
You can then tag this as local_jade with
-```docker tag blockstream/verde local_jade```
+```docker tag blockstream/jade_builder@sha256:148353098cf71916de389e1f9534550a841cd6efbd1d8f2c4a6ef496d3291dbe local_jade```
At this point we are ready to build and run Jade in qemu with the following:
-```cp configs/sdkconfig_qemu_psram_webdisplay.defaults sdkconfig.defaults```
+```./tools/switch_to.sh qemu --dev --psram --webdisplay```
```idf.py build```
After this the build files are ready and you can modify at any time any of the files and reissue the previous and then the following command:
-```docker run --rm -v $PWD:/jade -p 127.0.0.1:30121:30121/tcp -p 127.0.0.1:30122:30122/tcp local_jade /bin/bash -c "cd /jade && ./main/qemu/make-flash-img.sh && ./main/qemu/qemu_run.sh"```
+```docker run --rm -v $PWD:/jade -p 127.0.0.1:30121:30121/tcp -p 127.0.0.1:30122:30122/tcp local_jade /bin/bash -c "cd /jade && ./main/qemu/make_flash_img.sh && ./main/qemu/qemu_run.sh"```
This will start the docker image, open the port 30121 to talk to Jade via tcp and 30122 to show the display on a webpage.
-If you do not have idf.py configured/installed you can also try with:
+If you do not have idf.py configured/installed you can also try the ```run_emulator.sh``` script which will automate the process of building the jade firmware in docker also:
-```docker run --rm -v $PWD:/jade -p 127.0.0.1:30121:30121/tcp -p 127.0.0.1:30122:30122/tcp local_jade /bin/bash -c "cd /jade && rm -fr sdkconfig sdkconfig.defaults build && cp configs/sdkconfig_qemu_psram_webdisplay.defaults sdkconfig.defaults && rm -fr build sdkconfig && . /root/esp/esp-idf/export.sh && idf.py build && ./main/qemu/make-flash-img.sh && ./main/qemu/qemu_run.sh"```
+```./main/qemu/run_emulator.sh```
Potential additions:
diff --git a/main/qemu/make-flash-img.sh b/main/qemu/make-flash-img.sh
deleted file mode 100755
index e4aaad0..0000000
--- a/main/qemu/make-flash-img.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env bash
-set -eo pipefail
-
-FLASH_IMAGE_FILE=/flash_image.bin
-
-pushd /opt/esp/idf && . ./export.sh && popd
-
-esptool.py --chip esp32 merge_bin --fill-flash-size 4MB -o ${FLASH_IMAGE_FILE} \
---flash_mode dio --flash_freq 40m --flash_size 4MB \
-0x9000 build/partition_table/partition-table.bin \
-0xe000 build/ota_data_initial.bin \
-0x1000 build/bootloader/bootloader.bin \
-0x10000 build/jade.bin
-
-cp main/qemu/qemu_efuse.bin /qemu_efuse.bin
-chmod 777 /qemu_efuse.bin ${FLASH_IMAGE_FILE}
diff --git a/main/qemu/make_flash_img.sh b/main/qemu/make_flash_img.sh
new file mode 100755
index 0000000..5fc84f2
--- /dev/null
+++ b/main/qemu/make_flash_img.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+set -eo pipefail
+
+if [ -n "$1" ]; then
+ FLASH_IMAGE_FILE="$1"
+else
+ FLASH_IMAGE_FILE="/flash_image.bin"
+fi
+
+if [ -n "$2" ]; then
+ EFUSE_FILE="$2"
+else
+ EFUSE_FILE="/qemu_efuse.bin"
+fi
+
+if [ -z "${IDF_PATH}" ]; then
+ pushd /opt/esp/idf && . ./export.sh && popd
+fi
+
+esptool.py --chip esp32 merge_bin --fill-flash-size 4MB -o ${FLASH_IMAGE_FILE} \
+--flash_mode dio --flash_freq 40m --flash_size 4MB \
+0x9000 build/partition_table/partition-table.bin \
+0xe000 build/ota_data_initial.bin \
+0x1000 build/bootloader/bootloader.bin \
+0x10000 build/jade.bin
+
+cp main/qemu/qemu_efuse.bin ${EFUSE_FILE}
+chmod 777 ${EFUSE_FILE} ${FLASH_IMAGE_FILE}
diff --git a/main/qemu/qemu_reboot.sh b/main/qemu/qemu_reboot.sh
deleted file mode 100755
index 4608272..0000000
--- a/main/qemu/qemu_reboot.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-set -eo pipefail
-
-pushd /opt/esp/idf && . ./export.sh && popd
-
-pkill -f qemu-system-xtensa || true
-
-qemu-system-xtensa -nographic \
- -machine esp32 \
- -m 4M \
- -drive file=/flash_image.bin,if=mtd,format=raw \
- -nic user,model=open_eth,id=lo0,hostfwd=tcp:0.0.0.0:30121-:30121 \
- -drive file=/qemu_efuse.bin,if=none,format=raw,id=efuse \
- -global driver=nvram.esp32.efuse,property=drive,value=efuse \
- -serial pty &
diff --git a/main/qemu/qemu_run.sh b/main/qemu/qemu_run.sh
index 915d4e1..7aabe55 100755
--- a/main/qemu/qemu_run.sh
+++ b/main/qemu/qemu_run.sh
@@ -1,12 +1,47 @@
#!/usr/bin/env bash
-#
+
+set -eo pipefail
+
if [ -z "${IDF_PATH}" ]; then
pushd /opt/esp/idf && . ./export.sh && popd
fi
+GDB=""
+FLASH_IMAGE="/flash_image.bin"
+EFUSE_IMAGE="/qemu_efuse.bin"
+
+function usage {
+ if [ -n "$1" ]; then
+ echo "error: $1" >&2
+ fi
+ echo "Usage: ${0} [OPTIONS]"
+ echo "OPTIONS:"
+ echo " --gdb Launch QEMU suspended and attach xtensa-esp32-elf-gdb"
+ echo " --flash-image <path> Flash image to use (default: /flash_image.bin)"
+ echo " --efuse-image <path> eFuse image to use (default: /qemu_efuse.bin)"
+ echo " -h | --help Show this help message"
+ if [ -n "$1" ]; then
+ exit 1
+ fi
+ exit 0
+}
+
+while true; do
+ case "$1" in
+ --gdb) GDB=1; shift ;;
+ --flash-image) FLASH_IMAGE="$2"; shift 2 ;;
+ --efuse-image) EFUSE_IMAGE="$2"; shift 2 ;;
+ -h | --help) usage ;;
+ "") break ;;
+ *) usage "unknown option $1" ;;
+ esac
+done
+
pkill -f qemu-system-xtensa || true
-if [ "$1" = "--gdb" ]; then
+EXTRA_ARGS=""
+BG=""
+if [ -n "$GDB" ]; then
EXTRA_ARGS="-s -S"
BG="&"
fi
@@ -14,14 +49,14 @@ fi
qemu-system-xtensa $EXTRA_ARGS -nographic \
-machine esp32 \
-m 4M \
- -drive file=/flash_image.bin,if=mtd,format=raw \
+ -drive file=${FLASH_IMAGE},if=mtd,format=raw \
-nic user,model=open_eth,id=lo0,hostfwd=tcp:0.0.0.0:30122-:30122,hostfwd=tcp:0.0.0.0:30121-:30121 \
- -drive file=/qemu_efuse.bin,if=none,format=raw,id=efuse \
+ -drive file=${EFUSE_IMAGE},if=none,format=raw,id=efuse \
-global driver=nvram.esp32.efuse,property=drive,value=efuse \
-serial pty $BG
#-serial mon:stdio
-if [ "$1" = "--gdb" ]; then
+if [ -n "$GDB" ]; then
xtensa-esp32-elf-gdb /jade/build/jade.elf \
-ex "target remote :1234" \
-ex "monitor system_reset" \
diff --git a/main/qemu/run_emulator.sh b/main/qemu/run_emulator.sh
index a86dd09..b70f463 100755
--- a/main/qemu/run_emulator.sh
+++ b/main/qemu/run_emulator.sh
@@ -1,16 +1,37 @@
#!/usr/bin/env bash
set -e
-if [ "$#" -gt 1 ] || ([ "$#" -eq 1 ] && [ "$1" != "--larger-display" ]); then
- echo "Error: Invalid parameters."
- exit 1
-fi
+function usage {
+ if [ -n "$1" ]; then
+ echo "error: $1" >&2
+ fi
+ echo "Usage: ${0} [OPTIONS]"
+ echo "OPTIONS:"
+ echo " --larger-display Use a larger QEMU web display"
+ echo " -h | --help Show this help message"
+ if [ -n "$1" ]; then
+ exit 1
+ fi
+ exit 0
+}
+
+LARGER_DISPLAY=""
+
+while true; do
+ case "$1" in
+ --larger-display) LARGER_DISPLAY=1; shift ;;
+ -h | --help) usage ;;
+ "") break ;;
+ *) usage "unknown option $1" ;;
+ esac
+done
jade_docker_image=$(grep '^image:' .gitlab-ci.yml | awk '{print $2}')
-config_file="sdkconfig_qemu_psram_webdisplay.defaults"
-if [ "$1" == "--larger-display" ]; then
- config_file="sdkconfig_qemu_psram_webdisplay_larger.defaults"
+config_file="sdkconfig_qemu.defaults"
+QEMU_CONFIG_ARGS="--dev --psram --webdisplay"
+if [ -n "$LARGER_DISPLAY" ]; then
+ QEMU_CONFIG_ARGS="$QEMU_CONFIG_ARGS --webdisplay-larger"
fi
# the script makes a copy of the entire repo, cleans the build/config and
@@ -26,8 +47,10 @@ cmd="cp -r /jade /jade_cpy && cd /jade_cpy"
cmd+=" && cp configs/${config_file} sdkconfig.defaults"
# comment this out to make subsequent builds faster
#cmd+=" && rm -fr build sdkconfig"
-cmd+=" && pushd /opt/esp/idf && . ./export.sh && popd && idf.py build"
-cmd+=" && ./main/qemu/make-flash-img.sh && ./main/qemu/qemu_run.sh"
+cmd+=" && pushd /opt/esp/idf && . ./export.sh && popd"
+cmd+=" && ./tools/switch_to.sh qemu ${QEMU_CONFIG_ARGS}"
+cmd+=" && idf.py build"
+cmd+=" && ./main/qemu/make_flash_img.sh && ./main/qemu/qemu_run.sh"
docker run --rm -v $PWD:/jade \
-p 127.0.0.1:30121:30121/tcp -p 127.0.0.1:30122:30122/tcp \
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.