@@ -306,54 +306,11 @@ if [[ -n ${build_jade} ]]; then
306306 git submodule update --recursive --init
307307 fi
308308
309- # Deduce the relevant versions of esp-idf and qemu to use
309+ # Deduce the relevant version of esp-idf to use
310310 ESP_IDF_BRANCH=$( grep " ARG ESP_IDF_BRANCH=" Dockerfile | cut -d\= -f2)
311311 ESP_IDF_COMMIT=$( grep " ARG ESP_IDF_COMMIT=" Dockerfile | cut -d\= -f2)
312- ESP_QEMU_BRANCH=$( grep " ARG ESP_QEMU_BRANCH=" Dockerfile | cut -d\= -f2)
313- ESP_QEMU_COMMIT=$( grep " ARG ESP_QEMU_COMMIT=" Dockerfile | cut -d\= -f2)
314312 cd ..
315313
316- # Build the qemu emulator if required
317-
318- # If the directory exists, see if it is at the expected commit
319- # If not, remove the entire directory (it will be re-cloned below)
320- if [ -d " qemu" ]; then
321- cd qemu
322- LOCAL=$( git rev-parse @)
323- if [ $LOCAL = $ESP_QEMU_COMMIT ]; then
324- echo " esp-qemu up-to-date"
325- cd ..
326- else
327- cd ..
328- rm -fr qemu
329- fi
330- fi
331-
332- # Clone the upstream if the directory does not exist
333- # Then build the emulator
334- if [ ! -d " qemu" ]; then
335- git clone --quiet --depth 1 --branch ${ESP_QEMU_BRANCH} --single-branch --shallow-submodules https://github.com/espressif/qemu.git ./qemu
336- cd qemu
337-
338- git checkout ${ESP_QEMU_COMMIT}
339- ./configure \
340- --target-list=xtensa-softmmu \
341- --enable-gcrypt \
342- --disable-sanitizers \
343- --disable-strip \
344- --disable-user \
345- --disable-capstone \
346- --disable-vnc \
347- --disable-sdl \
348- --disable-gtk \
349- --enable-slirp \
350- --extra-cflags=-Wno-array-parameter
351- ninja -C build
352- cd ..
353- fi
354-
355- # Build the esp-idf toolchain if required
356-
357314 # We will install the esp-idf tools in a given location (otherwise defaults to user home dir)
358315 export IDF_TOOLS_PATH=" $( pwd) /esp-idf-tools"
359316
@@ -395,6 +352,13 @@ if [[ -n ${build_jade} ]]; then
395352 # Export the tools
396353 . ./esp-idf/export.sh
397354
355+ # Install the emulator
356+ idf_tools.py install qemu-xtensa
357+ QEMU_EXE=$( find ${IDF_TOOLS_PATH} -type f -name qemu-system-xtensa)
358+ QEMU_BIOS_DIR=$( dirname " ${QEMU_EXE} " ) /../share/qemu
359+ echo " Installed qemu emulator: ${QEMU_EXE} "
360+ echo " Installed qemu bios files: ${QEMU_BIOS_DIR} "
361+
398362 # Build Blockstream Jade firmware configured for the emulator
399363 cd jade
400364 rm -fr sdkconfig
@@ -413,8 +377,8 @@ if [[ -n ${build_jade} ]]; then
413377 # Extract the minimal artifacts required to run the emulator
414378 rm -fr simulator
415379 mkdir simulator
416- cp qemu/build/qemu-system-xtensa simulator/
417- cp -R qemu /pc-bios simulator/
380+ cp ${QEMU_EXE} simulator/
381+ cp -R ${QEMU_BIOS_DIR} simulator /pc-bios
418382 cp jade/main/qemu/flash_image.bin simulator/
419383 cp jade/main/qemu/qemu_efuse.bin simulator/
420384
0 commit comments