Skip to content

Commit 2583b37

Browse files
committed
ci(qemu): Add QEMU emulator to CI
1 parent e93c6b8 commit 2583b37

File tree

9 files changed

+33
-17
lines changed

9 files changed

+33
-17
lines changed

.github/scripts/sketch_utils.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
7878

7979
# Default FQBN options if none were passed in the command line.
8080

81-
esp32_opts="PSRAM=enabled,PartitionScheme=huge_app"
81+
esp32_opts="FlashMode=dio,PSRAM=enabled,PartitionScheme=huge_app"
8282
esp32s2_opts="PSRAM=enabled,PartitionScheme=huge_app"
8383
esp32s3_opts="PSRAM=opi,USBMode=default,PartitionScheme=huge_app"
84-
esp32c3_opts="PartitionScheme=huge_app"
84+
esp32c3_opts="FlashMode=dio,PartitionScheme=huge_app"
8585
esp32c6_opts="PartitionScheme=huge_app"
8686
esp32h2_opts="PartitionScheme=huge_app"
8787

@@ -139,7 +139,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
139139
echo "Skipping $sketchname for target $target"
140140
exit 0
141141
fi
142-
142+
143143
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
144144
if [ -n "$ARDUINO_BUILD_DIR" ]; then
145145
build_dir="$ARDUINO_BUILD_DIR"
@@ -177,7 +177,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
177177
--build-path "$build_dir" \
178178
$xtra_opts "${sketchdir}" \
179179
> $output_file
180-
180+
181181
exit_status=$?
182182
if [ $exit_status -ne 0 ]; then
183183
echo ""ERROR: Compilation failed with error code $exit_status""
@@ -198,11 +198,11 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
198198
# Extract the desired substring using sed
199199
lib_sketch_name=$(echo "$directory_path" | sed "s|$constant_part||")
200200
#append json file where key is fqbn, sketch name, sizes -> extracted values
201-
echo "{\"name\": \"$lib_sketch_name\",
201+
echo "{\"name\": \"$lib_sketch_name\",
202202
\"sizes\": [{
203-
\"flash_bytes\": $flash_bytes,
204-
\"flash_percentage\": $flash_percentage,
205-
\"ram_bytes\": $ram_bytes,
203+
\"flash_bytes\": $flash_bytes,
204+
\"flash_percentage\": $flash_percentage,
205+
\"ram_bytes\": $ram_bytes,
206206
\"ram_percentage\": $ram_percentage
207207
}]
208208
}," >> "$sizes_file"
@@ -386,7 +386,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
386386
if [ $log_compilation ]; then
387387
#echo board,target and start of sketches to sizes_file json
388388
echo "{ \"board\": \"$fqbn\",
389-
\"target\": \"$target\",
389+
\"target\": \"$target\",
390390
\"sketches\": [" >> "$sizes_file"
391391
fi
392392

.github/scripts/tests_run.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,23 @@ function run_test() {
3939
fi
4040

4141
if [ $platform == "qemu" ]; then
42-
extra_args="--embedded-services qemu --qemu-image-path $build_dir/$sketchname.ino.bin"
42+
PATH=$HOME/qemu/bin:$PATH
43+
extra_args="--embedded-services qemu --qemu-image-path $build_dir/$sketchname.ino.merged.bin"
4344

4445
if [ $target == "esp32" ] || [ $target == "esp32s3" ]; then
45-
extra_args+=" --qemu-prog-path $QEMU_PATH/qemu-system-xtensa --qemu-cli-args '-nographic -machine $target'"
46+
extra_args+=" --qemu-prog-path qemu-system-xtensa --qemu-cli-args=\"-machine $target -nographic\""
47+
elif [ $target == "esp32c3" ]; then
48+
extra_args+=" --qemu-prog-path qemu-system-riscv32 --qemu-cli-args=\"-machine $target -icount 3 -nographic\""
4649
else
47-
extra_args+=" --qemu-prog-path $QEMU_PATH/qemu-system-riscv32 --qemu-cli-args '-nographic -machine $target'"
50+
echo "Unsupported QEMU target: $target"
51+
exit 1
4852
fi
4953
else
5054
extra_args="--embedded-services esp,arduino"
5155
fi
5256

5357
echo "pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args"
54-
pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args
58+
bash -c "pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args"
5559
result=$?
5660
if [ $result -ne 0 ]; then
5761
return $result

.github/workflows/hil.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ jobs:
9595
~/.cache/pip
9696
key: ${{ steps.get-qemu-version.outputs.release }}-${{ hashFiles('.github/workflows/hil.yml') }}
9797

98-
- name: Install python dependencies
98+
- name: Install dependencies
9999
run: |
100100
pip install -U pip
101101
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi
102+
sudo apt update && sudo apt install libpixman-1-0 libnuma1 libglib2.0-0 libslirp0 libsdl2-2.0-0
102103
103104
- name: Download QEMU
104105
if: steps.cache-linux.outputs.cache-hit != 'true'

platform.txt

+11
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ recipe.hooks.objcopy.postobjcopy.1.pattern.windows=cmd /c if exist "{build.path}
169169
recipe.hooks.objcopy.postobjcopy.2.pattern=/usr/bin/env bash -c "[ ! -d "{build.path}"/libraries/ESP_SR ] || [ ! -f "{compiler.sdk.path}"/esp_sr/srmodels.bin ] || cp -f "{compiler.sdk.path}"/esp_sr/srmodels.bin "{build.path}"/srmodels.bin"
170170
recipe.hooks.objcopy.postobjcopy.2.pattern.windows=cmd /c if exist "{build.path}\libraries\ESP_SR" if exist "{compiler.sdk.path}\esp_sr\srmodels.bin" COPY /y "{compiler.sdk.path}\esp_sr\srmodels.bin" "{build.path}\srmodels.bin"
171171

172+
## Create flash_args file
173+
flash_args.path={build.path}/flash_args
174+
recipe.hooks.objcopy.postobjcopy.3.pattern_args=(echo '--fill-flash-size {build.flash_size} --flash_mode keep --flash_freq keep --flash_size keep'; echo '{build.bootloader_addr} {build.path}/{build.project_name}.bootloader.bin'; echo '0x8000 {build.path}/{build.project_name}.partitions.bin'; echo '0xe000 {runtime.platform.path}/tools/partitions/boot_app0.bin'; echo '0x10000 {build.path}/{build.project_name}.bin') > {flash_args.path}
175+
recipe.hooks.objcopy.postobjcopy.3.pattern=/usr/bin/env bash -c "{recipe.hooks.objcopy.postobjcopy.3.pattern_args}"
176+
recipe.hooks.objcopy.postobjcopy.3.pattern.windows=cmd /c "{recipe.hooks.objcopy.postobjcopy.3.pattern_args}"
177+
178+
# Create QEMU image
179+
recipe.hooks.objcopy.postobjcopy.4.pattern_args=--chip {build.mcu} merge_bin -o {build.path}/{build.project_name}.merged.bin @{flash_args.path}
180+
recipe.hooks.objcopy.postobjcopy.4.pattern="{tools.esptool_py.path}/{tools.esptool_py.cmd}" {recipe.hooks.objcopy.postobjcopy.4.pattern_args}
181+
recipe.hooks.objcopy.postobjcopy.4.pattern.linux=python3 "{tools.esptool_py.path}/{tools.esptool_py.cmd}" {recipe.hooks.objcopy.postobjcopy.4.pattern_args}
182+
172183
## Save bin
173184
recipe.output.tmp_file={build.project_name}.bin
174185
recipe.output.save_file={build.project_name}.{build.variant}.bin

tests/democfg/.skip.qemu

Whitespace-only changes.

tests/nvs/.skip.qemu

Whitespace-only changes.

tests/periman/.skip.qemu

Whitespace-only changes.

tests/requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cryptography>=2.1.4
22
--only-binary cryptography
33
pytest-cov
4-
pytest-embedded-serial-esp>=1.3.4
5-
pytest-embedded-arduino>=1.3.4
6-
pytest-embedded-qemu>=1.3.4
4+
pytest-embedded-serial-esp>=1.10.1
5+
pytest-embedded-arduino>=1.10.1
6+
pytest-embedded-qemu>=1.10.1

tests/uart/.skip.qemu

Whitespace-only changes.

0 commit comments

Comments
 (0)