Skip to content

Commit 1813463

Browse files
committed
Fix non-trustzone configs
1 parent 177358e commit 1813463

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

config/examples/stm32h5.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ DUALBANK_SWAP?=0
2121
WOLFBOOT_PARTITION_SIZE?=0xA0000
2222
WOLFBOOT_SECTOR_SIZE?=0x2000
2323
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08060000
24-
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x0C100000
25-
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x0C1A0000
24+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x08100000
25+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x081A0000
2626
FLAGS_HOME=0
2727
DISABLE_BACKUP=0
2828
IMAGE_HEADER_SIZE?=1024

test-app/app_stm32h5.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,12 @@ static int cmd_update_xmodem(const char *args)
282282

283283
printf("Erasing update partition...");
284284
fflush(stdout);
285+
#ifdef WOLFCRYPT_SECURE_MODE
285286
wolfBoot_nsc_erase_update(dst_offset, WOLFBOOT_PARTITION_SIZE);
287+
#else
288+
hal_flash_unlock();
289+
hal_flash_erase(WOLFBOOT_PARTITION_UPDATE_ADDRESS + dst_offset, WOLFBOOT_PARTITION_SIZE);
290+
#endif
286291
printf("Done.\r\n");
287292

288293
printf("Waiting for XMODEM transfer...\r\n");
@@ -346,7 +351,11 @@ static int cmd_update_xmodem(const char *args)
346351
if (crc == calc_crc) {
347352
/* CRC is valid */
348353
memcpy(xpkt_payload, xpkt + 3, XMODEM_PAYLOAD_SIZE);
354+
#ifdef WOLFCRYPT_SECURE_MODE
349355
ret = wolfBoot_nsc_write_update(dst_offset, xpkt_payload, XMODEM_PAYLOAD_SIZE);
356+
#else
357+
ret = hal_flash_write(WOLFBOOT_PARTITION_UPDATE_ADDRESS + dst_offset, xpkt_payload, XMODEM_PAYLOAD_SIZE);
358+
#endif
350359
if (ret != 0) {
351360
xcancel();
352361
printf("Error writing to flash\r\n");
@@ -381,17 +390,29 @@ static int cmd_update_xmodem(const char *args)
381390
}
382391
else {
383392
printf("Transfer succeeded\r\n");
393+
#ifdef WOLFCRYPT_SECURE_MODE
384394
update_ver = wolfBoot_nsc_update_firmware_version();
395+
#else
396+
update_ver = wolfBoot_update_firmware_version();
397+
#endif
385398
if (update_ver != 0) {
386399
printf("New firmware version: 0x%lx\r\n", update_ver);
387400
printf("Triggering update...\r\n");
401+
#ifdef WOLFCRYPT_SECURE_MODE
388402
wolfBoot_nsc_update_trigger();
403+
#else
404+
wolfBoot_update_trigger();
405+
#endif
389406
printf("Update written successfully. Reboot to apply.\r\n");
390407
} else {
391408
printf("No valid image in update partition\r\n");
392409
}
393410
}
394411

412+
#ifndef WOLFCRYPT_SECURE_MODE
413+
hal_flash_lock();
414+
#endif
415+
395416
return ret;
396417
}
397418

@@ -441,11 +462,19 @@ static int cmd_info(const char *args)
441462
uint16_t hdrSz;
442463
uint8_t boot_part_state = IMG_STATE_NEW, update_part_state = IMG_STATE_NEW;
443464

465+
#ifdef WOLFCRYPT_SECURE_MODE
444466
cur_fw_version = wolfBoot_nsc_current_firmware_version();
445467
update_fw_version = wolfBoot_nsc_update_firmware_version();
446468

447469
wolfBoot_nsc_get_partition_state(PART_BOOT, &boot_part_state);
448470
wolfBoot_nsc_get_partition_state(PART_UPDATE, &update_part_state);
471+
#else
472+
cur_fw_version = wolfBoot_current_firmware_version();
473+
update_fw_version = wolfBoot_update_firmware_version();
474+
475+
wolfBoot_get_partition_state(PART_BOOT, &boot_part_state);
476+
wolfBoot_get_partition_state(PART_UPDATE, &update_part_state);
477+
#endif
449478

450479
printf("\r\n");
451480
printf("System information\r\n");
@@ -496,7 +525,11 @@ static int cmd_info(const char *args)
496525

497526
static int cmd_success(const char *args)
498527
{
528+
#ifdef WOLFCRYPT_SECURE_MODE
499529
wolfBoot_nsc_success();
530+
#else
531+
wolfBoot_success();
532+
#endif
500533
printf("update success confirmed.\r\n");
501534
return 0;
502535
}
@@ -761,7 +794,11 @@ void main(void)
761794
/* Enable SysTick */
762795
systick_enable();
763796

797+
#ifdef WOLFCRYPT_SECURE_MODE
764798
app_version = wolfBoot_nsc_current_firmware_version();
799+
#else
800+
app_version = wolfBoot_current_firmware_version();
801+
#endif
765802

766803
nvic_irq_setprio(NVIC_USART3_IRQN, 0);
767804
nvic_irq_enable(NVIC_USART3_IRQN);

0 commit comments

Comments
 (0)