Skip to content

QEMU Testing

Mainline QEMU does not support ESP32. Use Espressif’s fork, which ships with ESP-IDF.

  • ESP-IDF v5.x installed and sourced (. $HOME/esp/esp-idf/export.sh)
  • Espressif QEMU at:
    ~/.espressif/tools/qemu-xtensa/esp_develop_9.0.0_20240606/qemu/bin/qemu-system-xtensa
Terminal window
# Use the QEMU sdkconfig defaults
cp sdkconfig.defaults.qemu sdkconfig.defaults
idf.py set-target esp32
idf.py build

The QEMU config disables WiFi/BLE, enables the custom OTA partition table, and defines CONFIG_QEMU_TEST_MODE.

Terminal window
cd build
esptool.py --chip esp32 merge_bin --output flash_image.bin \
--flash_mode dio --flash_freq 40m --flash_size 4MB \
0x1000 bootloader/bootloader.bin \
0x8000 partition_table/partition-table.bin \
0xd000 ota_data_initial.bin \
0x10000 esp32cam_qemu_test.bin
Terminal window
~/.espressif/tools/qemu-xtensa/esp_develop_9.0.0_20240606/qemu/bin/qemu-system-xtensa \
-nographic \
-machine esp32 \
-drive file=build/flash_image.bin,if=mtd,format=raw \
-m 4M

Press Ctrl+A then X to exit QEMU.

On startup in QEMU mode, main.c runs test_loopback_transfer():

  1. Loads the embedded 64×64 JPEG test image (1365 bytes).
  2. Computes CRC16 over the image data.
  3. Fragments the image and sends each fragment via lora_send() — which writes to a FreeRTOS queue instead of UART.
  4. Reads each fragment back from the queue via lora_receive().
  5. Feeds fragments through xfer_rx_process() for reassembly.
  6. After all fragments arrive, verifies the reassembled image matches the original byte-for-byte.

Expected output:

=== Loopback Transfer Test ===
Test image: 1365 bytes, 9 frags, CRC=XXXX
Loopback received header: H:1:9:1365:64:64:XXXX
...
Image fully reassembled via loopback!
Loopback verify: PASS
=== Loopback Test Complete ===
FeatureStatus
CameraEmulated via fake_camera component
LoRa UARTFreeRTOS queue loopback (no real UART)
PSRAMNot emulated by default
WiFi / BluetoothNot emulated
NVSWorks (flash image includes NVS partition)
OTA partitionsPresent in partition table