What changed, and why it matters
This commit only turns on diagnostic logging for automated QEMU (emulated hardware) test runs in CI. It adds a new logger that writes messages to the emulated serial port, changes CI scripts to capture that output, and adjusts a build helper so the '--log' flag is allowed for QEMU builds. There is no indication it fixes or introduces a security vulnerability.
No security action required; treat as routine CI/test infrastructure change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch enables UART0 logging under CONFIG_BOARD_TYPE_QEMU when logging is not disabled (CONFIG_LOG_DEFAULT_LEVEL_NONE). It adds qemu_uart0_logger() in main/logging.c, registers it via esp_log_set_vprintf() in boot_process(), updates CI YAML to pass –log to switch_to.sh for QEMU jobs, captures serial_output.log as a CI artifact, and changes qemu_ci_flash.sh to redirect the serial device to a file instead of a PTY. switch_to.sh is relaxed to permit –log for qemu while still rejecting –log-wifi, –noradio, –debug, and –jtag.
Changed components
main/logging.cmain/main.cmain/qemu/qemu_ci_flash.shtools/switch_to.shgitlab/flash.ymlgitlab/test_fw.ymlInspect captured patch +33 / −6
diff --git a/gitlab/flash.yml b/gitlab/flash.yml
index 1d7a674..587b1f7 100644
--- a/gitlab/flash.yml
+++ b/gitlab/flash.yml
@@ -15,6 +15,11 @@
- mv $(echo $CI_JOB_NAME | sed "s/^${CI_JOB_STAGE}/build_test/") build
- ./main/qemu/make-flash-img.sh
- ./main/qemu/qemu_ci_flash.sh --sample-percent=33
+ artifacts:
+ expire_in: 1 week
+ when: always
+ paths:
+ - serial_output.log
flash_qemu:
extends: .flash_qemu_template
diff --git a/gitlab/test_fw.yml b/gitlab/test_fw.yml
index 017a7a3..61958c7 100644
--- a/gitlab/test_fw.yml
+++ b/gitlab/test_fw.yml
@@ -56,14 +56,14 @@ build_test_jade_v2c_noradio_ci:
build_test_qemu:
extends: .build_test_template
before_script:
- - pushd /opt/esp/idf && . ./export.sh && popd && ./tools/switch_to.sh qemu --dev --ci
+ - pushd /opt/esp/idf && . ./export.sh && popd && ./tools/switch_to.sh qemu --dev --ci --log
build_test_qemu_psram:
extends: .build_test_template
before_script:
- - pushd /opt/esp/idf && . ./export.sh && popd && ./tools/switch_to.sh qemu --dev --ci --psram
+ - pushd /opt/esp/idf && . ./export.sh && popd && ./tools/switch_to.sh qemu --dev --ci --psram --log
build_test_qemu_psram_unamalgamated:
extends: .build_test_template
before_script:
- - pushd /opt/esp/idf && . ./export.sh && popd && ./tools/switch_to.sh qemu --dev --ci --psram --unamalgamated
+ - pushd /opt/esp/idf && . ./export.sh && popd && ./tools/switch_to.sh qemu --dev --ci --psram --unamalgamated --log
diff --git a/main/logging.c b/main/logging.c
index dabad20..fd63763 100644
--- a/main/logging.c
+++ b/main/logging.c
@@ -1,4 +1,5 @@
#ifndef AMALGAMATED_BUILD
+#include "driver/uart.h"
#include "jade_assert.h"
#include "process.h"
#include "utils/cbor_rpc.h"
@@ -68,4 +69,18 @@ int wifi_socket_server_logger(const char* message, va_list fmt)
}
#endif
+#ifdef CONFIG_BOARD_TYPE_QEMU
+// TODO: I would have thought that this would be the default if
+// logging was enabled, perhaps we disabled it somewhere else?
+int qemu_uart0_logger(const char* message, va_list fmt)
+{
+ char buff[BUFFER_SIZE];
+ int written = write_log_line(buff, sizeof(buff), message, fmt);
+
+ uart_write_bytes(UART_NUM_0, buff, written);
+
+ return written;
+}
+#endif
+
#endif // AMALGAMATED_BUILD
diff --git a/main/main.c b/main/main.c
index 4a610d1..a620289 100644
--- a/main/main.c
+++ b/main/main.c
@@ -79,6 +79,9 @@ int serial_logger(const char* message, va_list fmt);
#ifdef CONFIG_LOG_WIFI
int wifi_socket_server_logger(const char* message, va_list fmt);
#endif
+#if defined(CONFIG_BOARD_TYPE_QEMU) && !defined(CONFIG_LOG_DEFAULT_LEVEL_NONE)
+int qemu_uart0_logger(const char* message, va_list fmt);
+#endif
void offer_startup_options(void);
void dashboard_process(void* process_ptr);
@@ -237,6 +240,10 @@ static void boot_process(void)
#endif
#endif
+#if defined(CONFIG_BOARD_TYPE_QEMU) && !defined(CONFIG_LOG_DEFAULT_LEVEL_NONE)
+ esp_log_set_vprintf(qemu_uart0_logger);
+#endif
+
sensitive_init();
temp_stack_init();
diff --git a/main/qemu/qemu_ci_flash.sh b/main/qemu/qemu_ci_flash.sh
index cfde6f9..c75443f 100755
--- a/main/qemu/qemu_ci_flash.sh
+++ b/main/qemu/qemu_ci_flash.sh
@@ -28,7 +28,7 @@ qemu-system-xtensa -nographic \
-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 &
+ -serial file:serial_output.log &
sleep 4
diff --git a/tools/switch_to.sh b/tools/switch_to.sh
index 35c4e7d..bcef9c8 100755
--- a/tools/switch_to.sh
+++ b/tools/switch_to.sh
@@ -101,8 +101,8 @@ fi
if [ "$CONFIG" = "qemu" ]; then
# QEMU
- if [ -n "$NORADIO" ] || [ -n "$LOG" ] || [ -n "$DEBUG" ] || [ -n "$JTAG" ]; then
- usage "--[noradio|log|log-cbor|log-wifi|debug|jtag] must not be given for qemu"
+ if [ -n "$NORADIO" ] || [ "$LOG" = "wifi" ] || [ -n "$DEBUG" ] || [ -n "$JTAG" ]; then
+ usage "--[noradio|log-wifi|debug|jtag] must not be given for qemu"
elif [ -n "$WEBDISPLAY" ] && [ -z "$PSRAM" ]; then
usage "--[webdisplay|webdisplay-larger] require --psram"
fi
Why this scored 14/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.