From 655ba461acf7a86f5bd089b54902bb2bf1a91532 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Thu, 11 Apr 2024 11:13:05 +0200 Subject: [PATCH] Added more configuration options for stm32c0 --- config/examples/stm32c0-lms-8-10-1.config | 51 +++++++++++++++++++++++ config/examples/stm32c0-rsa2048.config | 46 ++++++++++++++++++++ config/examples/stm32c0.config | 2 - docs/Targets.md | 43 +++++++++++++++++-- 4 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 config/examples/stm32c0-lms-8-10-1.config create mode 100644 config/examples/stm32c0-rsa2048.config diff --git a/config/examples/stm32c0-lms-8-10-1.config b/config/examples/stm32c0-lms-8-10-1.config new file mode 100644 index 000000000..758831c97 --- /dev/null +++ b/config/examples/stm32c0-lms-8-10-1.config @@ -0,0 +1,51 @@ +ARCH?=ARM +TARGET?=stm32c0 +SIGN?=LMS +LMS_LEVELS=1 +LMS_HEIGHT=10 +LMS_WINTERNITZ=8 +IMAGE_SIGNATURE_SIZE=1456 +IMAGE_HEADER_SIZE=2048 +HASH?=SHA256 +DEBUG?=0 +VTOR?=1 +CORTEX_M0?=1 +NO_ASM?=0 +NO_MPU?=1 +EXT_FLASH?=0 +SPI_FLASH?=0 +ALLOW_DOWNGRADE?=0 +NVM_FLASH_WRITEONCE?=1 +WOLFBOOT_VERSION?=0 +V?=0 +SPMATH?=1 +DUALBANK_SWAP?=0 + +# Enable this to support wolfBoot self-update +RAM_CODE?=0 + +# Use slightly smaller SHA2-256 +CFLAGS_EXTRA+=-DUSE_SLOW_SHA256 + +# Enable this feature for secure memory support +# Makes the flash sectors for the bootloader unaccessible from the application +# Requires using the STM32CubeProgrammer to set FLASH_SECR -> SEC_SIZE pages +#CFLAGS_EXTRA+=-DFLASH_SECURABLE_MEMORY_SUPPORT + + +#Partition: Boot: 8KB, App, 10KB +WOLFBOOT_PARTITION_SIZE?=0x2800 +WOLFBOOT_SECTOR_SIZE?=0x800 +#Max WOLFBOOT size is 8KB +WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08002000 +WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x085000 +WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x08007800 + +#Example debugging partition for larger wolfBoot +#Partition: Boot: 22KB, App, 4K +#DEBUG?=1 +#WOLFBOOT_PARTITION_SIZE?=0x1000 +#WOLFBOOT_SECTOR_SIZE?=0x800 +#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08005800 +#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x08006800 +#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x08007800 diff --git a/config/examples/stm32c0-rsa2048.config b/config/examples/stm32c0-rsa2048.config new file mode 100644 index 000000000..979b33db9 --- /dev/null +++ b/config/examples/stm32c0-rsa2048.config @@ -0,0 +1,46 @@ +ARCH?=ARM +TARGET?=stm32c0 +SIGN?=RSA2048 +HASH?=SHA256 +DEBUG?=0 +VTOR?=1 +CORTEX_M0?=1 +NO_ASM?=0 +NO_MPU?=1 +EXT_FLASH?=0 +SPI_FLASH?=0 +ALLOW_DOWNGRADE?=0 +NVM_FLASH_WRITEONCE?=1 +WOLFBOOT_VERSION?=0 +V?=0 +SPMATH?=1 +DUALBANK_SWAP?=0 + +# Enable this to support wolfBoot self-update +RAM_CODE?=0 + +# Use slightly smaller SHA2-256 +CFLAGS_EXTRA+=-DUSE_SLOW_SHA256 + +# Enable this feature for secure memory support +# Makes the flash sectors for the bootloader unaccessible from the application +# Requires using the STM32CubeProgrammer to set FLASH_SECR -> SEC_SIZE pages +#CFLAGS_EXTRA+=-DFLASH_SECURABLE_MEMORY_SUPPORT + + +#Partition: Boot: 12KB, App, 8KB +WOLFBOOT_PARTITION_SIZE?=0x2000 +WOLFBOOT_SECTOR_SIZE?=0x800 +#Max WOLFBOOT size is 10KB +WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08003000 +WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x08005000 +WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x08007800 + +#Example debugging partition for larger wolfBoot +#Partition: Boot: 22KB, App, 4K +#DEBUG?=1 +#WOLFBOOT_PARTITION_SIZE?=0x1000 +#WOLFBOOT_SECTOR_SIZE?=0x800 +#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08005800 +#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x08006800 +#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x08007800 diff --git a/config/examples/stm32c0.config b/config/examples/stm32c0.config index 0a09dd905..cb2cbf123 100644 --- a/config/examples/stm32c0.config +++ b/config/examples/stm32c0.config @@ -1,7 +1,5 @@ ARCH?=ARM TARGET?=stm32c0 -#Supports ED25519/SHA384 -# No longer supported: RSA2048/SHA256 SIGN?=ED25519 HASH?=SHA384 DEBUG?=0 diff --git a/docs/Targets.md b/docs/Targets.md index 0185f87ea..9fbf8f45b 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -443,10 +443,13 @@ mon reset init Supports STM32C0x0/STM32C0x1. Instructions are for the STM Nucleo-C031C6 dev board. Tested build configurations: -* With RSA2048 and SHA2-256 the code size is 9724 and it boots in under 1 second. +* With RSA2048 and SHA2-256 the code size is 10988 and it boots in under 1 second. * With ED25519 and SHA2-384 the code size is 10024 and takes about 10 seconds for the LED to turn on. +* With LMS-8-10-1 and SHA2-256 the code size is 8164 -Example 32KB partitioning on STM32-G070: +### Example 32KB partitioning on STM32-G070 + +with ED25519: - Sector size: 2KB - Wolfboot partition size: 10KB @@ -461,11 +464,43 @@ Example 32KB partitioning on STM32-G070: #define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x08007800 /* at 30KB */ ``` +with LMS: + +- Sector size: 2KB +- Wolfboot partition size: 8KB +- Application partition size: 10 KB +- Swap size 2KB + +```C +#define WOLFBOOT_SECTOR_SIZE 0x800 /* 2 KB */ +#define WOLFBOOT_PARTITION_BOOT_ADDRESS 0x08002000 /* at 8KB */ +#define WOLFBOOT_PARTITION_SIZE 0x2800 /* 10 KB */ +#define WOLFBOOT_PARTITION_UPDATE_ADDRESS 0x08005000 /* at 20KB */ +#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x08007800 /* at 30KB */ +``` + +with RSA2048: + +- Sector size: 2KB +- Wolfboot partition size: 12KB +- Application partition size: 8 KB +- Swap size 2KB + +```C +#define WOLFBOOT_SECTOR_SIZE 0x800 /* 2 KB */ +#define WOLFBOOT_PARTITION_BOOT_ADDRESS 0x08003000 /* at 12KB */ +#define WOLFBOOT_PARTITION_SIZE 0x2000 /* 8 KB */ +#define WOLFBOOT_PARTITION_UPDATE_ADDRESS 0x08005000 /* at 20KB */ +#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x08007800 /* at 30KB */ +``` + ### Building STM32C0 -Reference configuration (see [/config/examples/stm32c0.config](/config/examples/stm32c0.config)). +Reference configuration files (see [config/examples/stm32c0.config](/config/examples/stm32c0.config), +[config/examples/stm32c0-rsa2048.config](/config/examples/stm32c0-rsa2048.config) and +[config/examples/stm32c0-lms-8-10-1.config](/config/examples/stm32c0-lms-8-10-1.config)). -You can copy this to wolfBoot root as `.config`: `cp ./config/examples/stm32c0.config .config`. +You can copy one of these to wolfBoot root as `.config`: `cp ./config/examples/stm32c0.config .config`. To build you can use `make`. The TARGET for this is `stm32c0`: `make TARGET=stm32c0`.