-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for simulator self-update test #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
e45371d to
aee4042
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for testing bootloader self-update functionality in the simulator environment. The self-update feature allows wolfBoot to update itself in RAM, which requires special handling in the simulator since flash memory is memory-mapped at runtime rather than at linker-time addresses.
Key changes:
- Added simulator-specific self-update test that verifies the bootloader can update itself by swapping a dummy payload to the bootloader region
- Implemented conditional logic in the self-update code to use runtime flash offsets instead of linker symbols when running in the simulator
- Added arch_reboot() implementation for the simulator to properly exit after self-update
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/test.mk | Adds test-sim-self-update target that creates a dummy bootloader update, assembles flash partitions, runs the simulator, and verifies the update was applied correctly |
| src/update_flash.c | Adds ARCH_SIM conditional compilation to use ARCH_FLASH_OFFSET instead of _start_text linker symbol for flash writes in both EXT_FLASH and internal flash code paths |
| hal/sim.c | Implements arch_reboot() function that calls exit(0) to terminate the simulator after self-update |
| config/examples/sim-self-update.config | Provides configuration for simulator self-update testing with appropriate partition sizes and addresses |
| .github/workflows/test-sim-self-update.yml | Adds CI workflow to automatically run the self-update test on ubuntu-latest with sources.list workaround for reliability |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @echo "=== Simulator Self-Update Test ===" | ||
| $(Q)make wolfboot.bin RAM_CODE=1 WOLFBOOT_VERSION=1 | ||
| @# Create dummy payload (0xAA pattern) and sign as wolfBoot update v2 | ||
| $(Q)dd if=/dev/zero bs=$$(stat -c%s wolfboot.bin) count=1 2>/dev/null | tr '\000' '\252' > dummy_update.bin |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stat command with -c option is GNU coreutils specific and is not portable to macOS/BSD systems where the equivalent would be stat -f%z. This could cause the test to fail on macOS. Consider using a portable alternative or adding conditional logic for different platforms, similar to how other parts of the codebase handle platform differences.
| @# Run simulator - self-update runs before app boot, writes dummy to offset 0, then reboots | ||
| $(Q)./wolfboot.elf get_version || true | ||
| @# Verify dummy payload was written to bootloader region, indicating the self update swapped images as expected | ||
| $(Q)cmp -n $$(stat -c%s dummy_update.bin) dummy_update.bin internal_flash.dd && echo "=== Self-update test PASSED ===" |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stat command with -c option is GNU coreutils specific and is not portable to macOS/BSD systems where the equivalent would be stat -f%z. This could cause the test to fail on macOS. Consider using a portable alternative or adding conditional logic for different platforms.
No description provided.