Skip to content

Commit

Permalink
Added more configuration options for stm32c0
Browse files Browse the repository at this point in the history
  • Loading branch information
danielinux committed Apr 11, 2024
1 parent c332cb9 commit 655ba46
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 6 deletions.
51 changes: 51 additions & 0 deletions config/examples/stm32c0-lms-8-10-1.config
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions config/examples/stm32c0-rsa2048.config
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions config/examples/stm32c0.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
ARCH?=ARM
TARGET?=stm32c0
#Supports ED25519/SHA384
# No longer supported: RSA2048/SHA256
SIGN?=ED25519
HASH?=SHA384
DEBUG?=0
Expand Down
43 changes: 39 additions & 4 deletions docs/Targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`.
Expand Down

0 comments on commit 655ba46

Please sign in to comment.