Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/examples/vorago_va416x0.config
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ WOLFBOOT_RESTORE_CLOCK?=1
#CFLAGS_EXTRA+=-DDEBUG_EXT_FLASH
#CFLAGS_EXTRA+=-DTEST_EXT_FLASH

# Optional: Boot benchmarking (timing of integrity check, signature verify)
# Requires DEBUG_UART=1 for output
#BOOT_BENCHMARK?=1

# Optional: Enable wolfCrypt test and benchmark in test-app
# Uncomment to enable
# Note: Requires ~80-160KB additional flash and ~10-20KB RAM
Expand Down
19 changes: 19 additions & 0 deletions hal/va416x0.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,22 @@ void hal_prepare_boot(void)
/* Disable system config IRQs */
VOR_SYSCONFIG->IRQ_ENB = 0;
}

#if defined(WOLFBOOT_UPDATE_DISK) || defined(BOOT_BENCHMARK)
/* Microsecond timer for boot benchmarking.
* Uses SysTick counter (counts down each ms tick) combined with
* HAL_time_ms (incremented by SysTick_Handler every 1ms).
* SysTick->LOAD = (SystemCoreClock / 1000) - 1 (configured by HAL_Init).
* SysTick->VAL counts down from LOAD to 0.
*/
uint64_t hal_get_timer_us(void)
{
extern volatile uint64_t HAL_time_ms;
uint32_t load = SysTick->LOAD;
uint32_t val = SysTick->VAL;
uint32_t elapsed_ticks = load - val;

return (HAL_time_ms * 1000ULL) +
Comment on lines +596 to +599
((uint64_t)elapsed_ticks * 1000000ULL / SystemCoreClock);
}
#endif
18 changes: 14 additions & 4 deletions src/update_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ void RAMFUNCTION wolfBoot_start(void)
uint8_t updateState;
#endif /* !WOLFBOOT_SELF_UPDATE_MONOLITHIC */
struct wolfBoot_image boot;
BENCHMARK_DECLARE();

#if defined(ARCH_SIM) && defined(WOLFBOOT_TPM) && defined(WOLFBOOT_TPM_SEAL)
wolfBoot_unlock_disk();
Expand Down Expand Up @@ -1481,10 +1482,19 @@ void RAMFUNCTION wolfBoot_start(void)
wolfBoot_get_blob_version(boot.hdr));

#ifndef WOLFBOOT_SKIP_BOOT_VERIFY
if (bootRet < 0
|| (wolfBoot_verify_integrity(&boot) < 0)
|| (wolfBoot_verify_authenticity(&boot) < 0)
) {
if (bootRet >= 0) {
wolfBoot_printf("Checking integrity...");
BENCHMARK_START();
bootRet = wolfBoot_verify_integrity(&boot);
BENCHMARK_END("done");
}
if (bootRet >= 0) {
wolfBoot_printf("Verifying signature...");
BENCHMARK_START();
bootRet = wolfBoot_verify_authenticity(&boot);
BENCHMARK_END("done");
Comment on lines +1489 to +1495
}
if (bootRet < 0) {
wolfBoot_printf("Boot failed: Hdr %d, Hash %d, Sig %d\n",
boot.hdr_ok, boot.sha_ok, boot.signature_ok);
#ifndef WOLFBOOT_SELF_UPDATE_MONOLITHIC
Expand Down
Loading