Skip to content

Conversation

@bigbrett
Copy link
Owner

@bigbrett bigbrett commented Jan 5, 2026

No description provided.

Copy link

Copilot AI left a 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
Copy link

Copilot AI Jan 5, 2026

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.

Copilot uses AI. Check for mistakes.
@# 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 ==="
Copy link

Copilot AI Jan 5, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants