Skip to content

Conversation

@bigbrett
Copy link
Contributor

@bigbrett bigbrett commented Jan 8, 2026

Adds support for basic sanity-check testing of the self-update mechanism in the simulator. The test verifies that a new self-update payload is copied to the expected flash location.

This change includes a small simulator-only modification to update_flash.c to work around _start_text not being a real symbol, and introduces a new test target along with a corresponding GitHub Actions workflow.

The new test target:

  1. Creates a dummy bootloader payload consisting of 0xAA bytes, matching the size of a real bootloader.
  2. Signs the payload as a v2 bootloader update using the --wolfboot-update flag.
  3. Pre-populates the UPDATE partition with the signed image and a pBOOT trailer indicating IMG_STATE_UPDATING.
  4. Assembles a flash image containing a real v1 bootloader at offset 0 and the pending update in the UPDATE partition.
  5. Boots wolfBoot, which detects the image state and triggers a self-update.
  6. wolfBoot performs the self-update.
  7. arch_reboot() exits the process.
  8. The test verifies that the dummy payload was copied to the expected location

Note that we can't really test true "reboot into simulated wolfBoot" without some hackery spawning another process, but figured this would be a good sanity check

Copy link
Contributor

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 simulator-based testing for wolfBoot's self-update mechanism, allowing automated verification that the bootloader can update itself correctly. The implementation includes test targets for both internal and external flash configurations, along with a corresponding GitHub Actions workflow.

Key changes:

  • Introduces two new test targets (test-sim-self-update and test-sim-self-update-ext) that verify self-update by comparing a dummy payload after the update
  • Adds simulator-specific code paths in update_flash.c to use ARCH_FLASH_OFFSET instead of the _start_text linker symbol
  • Implements arch_reboot() for the simulator that exits the process

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/test.mk Adds two new test targets for self-update testing with internal and external flash configurations
src/update_flash.c Adds ARCH_SIM conditional logic to use ARCH_FLASH_OFFSET instead of _start_text symbol for simulator compatibility
hal/sim.c Implements arch_reboot() function that exits the simulator process
config/examples/sim-self-update.config Configuration file for internal flash self-update test
config/examples/sim-self-update-ext.config Configuration file for external flash self-update test
.github/workflows/test-sim-self-update.yml GitHub Actions workflow to run both self-update tests in CI

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dgarske dgarske merged commit 8577188 into wolfSSL:master Jan 9, 2026
309 checks passed
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.

3 participants