Skip to content

Commit 9cf9472

Browse files
dgarskedanielinux
authored andcommitted
* Fix for building on MacOS (new keystore section issues).
* Fix for library.o workaround. * Added new `WOLFBOOT_DEBUG_MALLOC` option to help diagnosing malloc failures.
1 parent 2143cdc commit 9cf9472

File tree

13 files changed

+138
-71
lines changed

13 files changed

+138
-71
lines changed

.github/workflows/test-configs.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,42 @@ jobs:
9595
config-file: ./config/examples/raspi3.config
9696
make-args: wolfboot.bin CROSS_COMPILE=aarch64-linux-gnu-
9797

98-
sim_test:
98+
sim_tfm_smallstack_test:
9999
uses: ./.github/workflows/test-build.yml
100100
with:
101101
arch: host
102102
config-file: ./config/examples/sim.config
103+
make-args: WOLFBOOT_SMALL_STACK=1
104+
105+
sim_tfm_bigstack_test:
106+
uses: ./.github/workflows/test-build.yml
107+
with:
108+
arch: host
109+
config-file: ./config/examples/sim.config
110+
make-args: WOLFBOOT_SMALL_STACK=0 WOLFBOOT_HUGE_STACK=1
111+
112+
sim_spmathall_smallstack_test:
113+
uses: ./.github/workflows/test-build.yml
114+
with:
115+
arch: host
116+
config-file: ./config/examples/sim.config
117+
make-args: SPMATHALL=1 WOLFBOOT_SMALL_STACK=1
118+
119+
sim_spmathall_bigsack_test:
120+
uses: ./.github/workflows/test-build.yml
121+
with:
122+
arch: host
123+
config-file: ./config/examples/sim.config
124+
make-args: SPMATHALL=1 WOLFBOOT_SMALL_STACK=0 WOLFBOOT_HUGE_STACK=1
125+
126+
sim_spmath_bigstack_test:
127+
uses: ./.github/workflows/test-build.yml
128+
with:
129+
arch: host
130+
config-file: ./config/examples/sim.config
131+
make-args: SPMATH=1 WOLFBOOT_SMALL_STACK=0 WOLFBOOT_HUGE_STACK=1
132+
133+
# TODO: SP math with small stack has issues
103134

104135
stm32f4_small_blocks_uart_update_test:
105136
uses: ./.github/workflows/test-build.yml

.github/workflows/test-keytools.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ jobs:
2323
2424
- name: Select config
2525
run: |
26-
cp config/examples/sim-ecc.config .config && make include/target.h
26+
cp config/examples/sim.config .config && make include/target.h
2727
2828
- name: Build tools
2929
run: |
3030
make -C tools/keytools && make -C tools/bin-assemble
3131
3232
- name: Build wolfboot
3333
run: |
34-
make ${{inputs.make-args}}
34+
make SIGN=ECC256 HASH=SHA256
3535
3636
- name: Generate external key
3737
run: |
@@ -73,7 +73,7 @@ jobs:
7373
7474
- name: Build wolfboot
7575
run: |
76-
make ${{inputs.make-args}}
76+
make SIGN=ED25519 HASH=SHA256
7777
7878
- name: Generate external key
7979
run: |
@@ -107,15 +107,15 @@ jobs:
107107
108108
- name: Select config
109109
run: |
110-
cp config/examples/sim-rsa.config .config && make include/target.h
110+
cp config/examples/sim.config .config && make include/target.h
111111
112112
- name: Build tools
113113
run: |
114114
make -C tools/keytools && make -C tools/bin-assemble
115115
116116
- name: Build wolfboot
117117
run: |
118-
make ${{inputs.make-args}}
118+
make SIGN=RSA2048 HASH=SHA256
119119
120120
- name: Generate external key
121121
run: |

CMakeLists.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ if(SIGN STREQUAL "NONE")
285285
set(WOLFBOOT_SIGNING_PRIVATE_KEY
286286
""
287287
CACHE INTERNAL "")
288-
set(STACK_USAGE 1216)
288+
if(HASH STREQUAL "SHA384")
289+
set(STACK_USAGE 3760)
290+
else()
291+
set(STACK_USAGE 1216)
292+
endif()
289293
list(APPEND SIGN_OPTIONS WOLFBOOT_NO_SIGN)
290294
else()
291295
set(WOLFBOOT_SIGNING_PRIVATE_KEY ${CMAKE_CURRENT_BINARY_DIR}/wolfboot_signing_private_key.der)
@@ -312,9 +316,9 @@ if(SIGN STREQUAL "ECC256")
312316
if(WOLFBOOT_SMALL_STACK)
313317
set(STACK_USAGE 4096)
314318
elseif(NOT SPMATH)
315-
set(STACK_USAGE 5008)
319+
set(STACK_USAGE 5264)
316320
else()
317-
set(STACK_USAGE 3952)
321+
set(STACK_USAGE 7632)
318322
endif()
319323

320324
if(${IMAGE_HEADER_SIZE} LESS 256)
@@ -333,7 +337,7 @@ if(SIGN STREQUAL "ECC384")
333337
elseif(NOT SPMATH)
334338
set(STACK_USAGE 11248)
335339
else()
336-
set(STACK_USAGE 5880)
340+
set(STACK_USAGE 11216)
337341
endif()
338342

339343
if(${IMAGE_HEADER_SIZE} LESS 512)
@@ -367,7 +371,7 @@ if(SIGN STREQUAL "ED25519")
367371
list(APPEND SIGN_OPTIONS WOLFBOOT_SIGN_ED25519)
368372

369373
if(NOT DEFINED STACK_USAGE)
370-
set(STACK_USAGE 1180)
374+
set(STACK_USAGE 5000)
371375
endif()
372376

373377
if(${IMAGE_HEADER_SIZE} LESS 256)
@@ -412,7 +416,7 @@ if(SIGN STREQUAL "RSA2048")
412416
elseif(NOT SPMATH)
413417
set(STACK_USAGE 35952)
414418
else()
415-
set(STACK_USAGE 12288)
419+
set(STACK_USAGE 17568)
416420
endif()
417421

418422
if(${IMAGE_HEADER_SIZE} LESS 512)
@@ -430,7 +434,7 @@ if(SIGN STREQUAL "RSA4096")
430434
if(NOT SPMATH)
431435
set(STACK_USAGE 5888)
432436
else()
433-
set(STACK_USAGE 4096)
437+
set(STACK_USAGE 5768)
434438
endif()
435439
elseif(NOT SPMATH)
436440
set(STACK_USAGE 69232)

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ stage1/loader_stage1.bin: FORCE
117117
@echo "\t[BIN] $@"
118118
$(Q)$(MAKE) -C $(dir $@) $(notdir $@)
119119

120-
test-lib: $(OBJS)
121-
$(Q)$(CC) $(CFLAGS) -o $@ $^
120+
test-lib: include/target.h $(OBJS)
121+
$(Q)$(CC) $(CFLAGS) -o $@ $(OBJS)
122122

123123
wolfboot.efi: wolfboot.elf
124124
@echo "\t[BIN] $@"

arch.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ ifeq ($(TARGET),sim)
716716
LD_END_GROUP=
717717
BOOT_IMG=test-app/image.elf
718718
CFLAGS+=-DARCH_SIM
719+
ifeq ($(SPMATH),1)
720+
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o
721+
CFLAGS+=-DWOLFSSL_SP_DIV_WORD_HALF
722+
endif
719723
endif
720724

721725
CFLAGS+=-DARCH_FLASH_OFFSET=$(ARCH_FLASH_OFFSET)
@@ -731,9 +735,12 @@ ifeq ($(DUALBANK_SWAP),1)
731735
UPDATE_OBJS:=src/update_flash_hwswap.o
732736
endif
733737

738+
# Set default update object (if not library)
739+
ifneq ($(TARGET),library)
734740
ifeq ($(UPDATE_OBJS),)
735741
UPDATE_OBJS:=./src/update_flash.o
736742
endif
743+
endif
737744

738745
## wolfBoot origin
739746
ifeq ($(WOLFBOOT_ORIGIN),)

config/examples/library.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
ARCH=
22
NO_LOADER=1
33
USE_GCC_HEADLESS=0
4-
# ends up double including this to work around defaulting to update_flash
5-
UPDATE_OBJS:=hal/library.o
64
TARGET=library
75
WOLFBOOT_SMALL_STACK=1
86
SIGN?=ED25519

config/examples/sim-ecc.config

Lines changed: 0 additions & 18 deletions
This file was deleted.

config/examples/sim-rsa.config

Lines changed: 0 additions & 19 deletions
This file was deleted.

config/examples/sim.config

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ ARCH=sim
22
TARGET=sim
33
SIGN?=ED25519
44
HASH?=SHA256
5-
WOLFBOOT_SMALL_STACK=1
5+
WOLFBOOT_SMALL_STACK?=1
66
SPI_FLASH=0
77
DEBUG=1
8+
SPMATH?=0
89

910
# sizes should be multiple of system page size
1011
WOLFBOOT_PARTITION_SIZE=0x40000
1112
WOLFBOOT_SECTOR_SIZE=0x1000
12-
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
13+
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80000
1314
# if on external flash, it should be multiple of system page size
14-
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x60000
15-
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xA0000
15+
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x100000
16+
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x180000
1617

1718
# required for keytools
1819
WOLFBOOT_FIXED_PARTITIONS=1
20+
21+
# For debugging XMALLOC/XFREE
22+
#CFLAGS_EXTRA+=-DWOLFBOOT_DEBUG_MALLOC

include/user_settings.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
# include "test-app/wcs/user_settings.h"
3131
#else
3232

33-
3433
#include <target.h>
3534

3635
/* System */
3736
#define WOLFSSL_GENERAL_ALIGNMENT 4
3837
#define SINGLE_THREADED
38+
#define WOLFSSL_USER_MUTEX /* avoid wc_port.c wc_InitAndAllocMutex */
3939
#define WOLFCRYPT_ONLY
4040
#define SIZEOF_LONG_LONG 8
4141

@@ -166,14 +166,14 @@ extern int tolower(int c);
166166
defined(WOLFBOOT_SIGN_RSA4096) || \
167167
defined(WOLFCRYPT_SECURE_MODE)
168168

169-
170-
# define WC_RSA_BLINDING
169+
# define WC_RSA_BLINDING
171170
# define WC_RSA_DIRECT
172171
# define RSA_LOW_MEM
173172
# define WC_ASN_HASH_SHA256
174173
# if !defined(WOLFBOOT_TPM) && !defined(WOLFCRYPT_SECURE_MODE)
175174
# define WOLFSSL_RSA_VERIFY_INLINE
176175
# define WOLFSSL_RSA_VERIFY_ONLY
176+
# define WOLFSSL_RSA_PUBLIC_ONLY
177177
# define WC_NO_RSA_OAEP
178178
# endif
179179
# if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH_ALL)
@@ -374,6 +374,9 @@ extern int tolower(int c);
374374
#define WOLFSSL_NO_SOCK
375375
#define WOLFSSL_IGNORE_FILE_WARN
376376
#define NO_ERROR_STRINGS
377+
#define NO_PKCS12
378+
#define NO_PKCS8
379+
#define NO_CHECK_PRIVATE_KEY
377380

378381
#define BENCH_EMBEDDED
379382
#define NO_CRYPT_TEST
@@ -397,13 +400,13 @@ extern int tolower(int c);
397400
# define WOLFSSL_SP_NO_MALLOC
398401
# define WOLFSSL_SP_NO_DYN_STACK
399402
# endif
400-
# if !defined(ARCH_SIM) && !defined(SECURE_PKCS11)
403+
# if !defined(SECURE_PKCS11)
401404
# define WOLFSSL_NO_MALLOC
402405
# endif
403406
#else
404407
# if defined(WOLFBOOT_HUGE_STACK)
405408
# error "Cannot use SMALL_STACK=1 with HUGE_STACK=1"
406-
#endif
409+
# endif
407410
# define WOLFSSL_SMALL_STACK
408411
#endif
409412

0 commit comments

Comments
 (0)