mirror of https://github.com/wolfSSL/wolfBoot.git
sim self update: test external flash
parent
d661c2afb3
commit
e31755be4b
|
|
@ -61,7 +61,13 @@ jobs:
|
|||
echo "--- apt-mirrors.txt ---"
|
||||
cat /etc/apt/apt-mirrors.txt || true
|
||||
|
||||
- name: Run self-update test
|
||||
- name: Run self-update test (internal flash)
|
||||
run: |
|
||||
cp config/examples/sim-self-update.config .config
|
||||
make test-sim-self-update
|
||||
|
||||
- name: Run self-update test (external flash)
|
||||
run: |
|
||||
make clean
|
||||
cp config/examples/sim-self-update-ext.config .config
|
||||
make test-sim-self-update-ext
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
ARCH=sim
|
||||
TARGET=sim
|
||||
SIGN?=ED25519
|
||||
HASH?=SHA256
|
||||
WOLFBOOT_SMALL_STACK?=0
|
||||
SPI_FLASH=0
|
||||
EXT_FLASH=1
|
||||
DEBUG=1
|
||||
RAM_CODE=1
|
||||
WOLFBOOT_VERSION=1
|
||||
|
||||
# sizes should be multiple of system page size
|
||||
WOLFBOOT_PARTITION_SIZE=0x40000
|
||||
WOLFBOOT_SECTOR_SIZE=0x1000
|
||||
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
|
||||
# Update and swap on external flash (address 0x00000)
|
||||
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00000
|
||||
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x40000
|
||||
|
||||
# required for keytools
|
||||
WOLFBOOT_FIXED_PARTITIONS=1
|
||||
|
|
@ -266,6 +266,32 @@ test-sim-self-update: wolfboot.bin FORCE
|
|||
@# Verify dummy payload was written to bootloader region, indicating the self update swapped images as expected
|
||||
$(Q)cmp -n $$(wc -c < dummy_update.bin | awk '{print $$1}') dummy_update.bin internal_flash.dd && echo "=== Self-update test PASSED ==="
|
||||
|
||||
# Test bootloader self-update mechanism with external flash
|
||||
test-sim-self-update-ext: wolfboot.bin FORCE
|
||||
@echo "=== Simulator Self-Update Test (External Flash) ==="
|
||||
@# Create dummy payload (0xAA pattern) and sign as wolfBoot update v2
|
||||
$(Q)dd if=/dev/zero bs=$$(wc -c < wolfboot.bin | awk '{print $$1}') count=1 2>/dev/null | tr '\000' '\252' > dummy_update.bin
|
||||
$(Q)$(SIGN_ENV) $(SIGN_TOOL) $(SIGN_OPTIONS) --wolfboot-update dummy_update.bin $(PRIVATE_KEY) 2
|
||||
@# Create update partition with signed update and "pBOOT" trailer
|
||||
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null | tr '\000' '\377' > update_part.dd
|
||||
$(Q)dd if=dummy_update_v2_signed.bin of=update_part.dd bs=1 conv=notrunc
|
||||
$(Q)printf "pBOOT" | dd of=update_part.dd bs=1 seek=$$(($(WOLFBOOT_PARTITION_SIZE) - 5)) conv=notrunc
|
||||
@# Create erased boot and swap partitions
|
||||
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_PARTITION_SIZE))) count=1 2>/dev/null | tr '\000' '\377' > boot_part.dd
|
||||
$(Q)dd if=/dev/zero bs=$$(($(WOLFBOOT_SECTOR_SIZE))) count=1 2>/dev/null | tr '\000' '\377' > erased_sec.dd
|
||||
@# Assemble internal flash: wolfboot.bin at 0, empty boot partition
|
||||
$(Q)$(BINASSEMBLE) internal_flash.dd \
|
||||
0 wolfboot.bin \
|
||||
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) boot_part.dd
|
||||
@# Assemble external flash: update partition, swap sector
|
||||
$(Q)$(BINASSEMBLE) external_flash.dd \
|
||||
0 update_part.dd \
|
||||
$(WOLFBOOT_PARTITION_SIZE) erased_sec.dd
|
||||
@# Run simulator - self-update reads from external, writes to internal at offset 0
|
||||
$(Q)./wolfboot.elf get_version || true
|
||||
@# Verify dummy payload was written to bootloader region
|
||||
$(Q)cmp -n $$(wc -c < dummy_update.bin | awk '{print $$1}') dummy_update.bin internal_flash.dd && echo "=== Self-update test (External Flash) PASSED ==="
|
||||
|
||||
test-self-update: FORCE
|
||||
@mv $(PRIVATE_KEY) private_key.old
|
||||
@make clean factory.bin RAM_CODE=1 WOLFBOOT_VERSION=1 SIGN=$(SIGN)
|
||||
|
|
|
|||
Loading…
Reference in New Issue