Skip to content

Commit 86138b4

Browse files
committed
PolarFire PQC (ML-DSA) testing
1 parent 472cab6 commit 86138b4

File tree

9 files changed

+184
-51
lines changed

9 files changed

+184
-51
lines changed

config/examples/polarfire_mpfs250.config

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
ARCH?=RISCV64
22
TARGET?=mpfs250
3+
4+
# ECC P384 + SHA384
35
SIGN?=ECC384
46
HASH?=SHA384
57
IMAGE_HEADER_SIZE=512
8+
WOLFBOOT_SECTOR_SIZE?=0x1000
9+
10+
# ML-DSA 87 + SHA256
11+
#SIGN=ML_DSA
12+
#HASH=SHA256
13+
#ML_DSA_LEVEL=5
14+
#IMAGE_SIGNATURE_SIZE=4627
15+
#IMAGE_HEADER_SIZE=12288
16+
#WOLFBOOT_SECTOR_SIZE?=0x4000
17+
618
WOLFBOOT_VERSION?=1
719
ARMORED?=0
820
DEBUG?=0
@@ -27,7 +39,6 @@ ELF?=1
2739

2840
# Use RISC-V assembly version of ECDSA and SHA
2941
NO_ASM?=0
30-
NO_ARM_ASM?=0
3142
# Optional: Use smaller SHA512
3243
#CFLAGS_EXTRA+=-DUSE_SLOW_SHA512
3344

@@ -38,9 +49,6 @@ DISK_EMMC?=0
3849
# DDR Address for wolfBoot to start from
3950
WOLFBOOT_ORIGIN?=0x80000000
4051

41-
# Flash sector size (4KB typical)
42-
WOLFBOOT_SECTOR_SIZE?=0x1000
43-
4452
# Load Partition to RAM Address
4553
WOLFBOOT_LOAD_ADDRESS?=0x8E000000
4654

docs/Targets.md

Lines changed: 155 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,29 @@ int wolfBoot_get_encrypt_key(uint8_t *key, uint8_t *nonce);
10481048
int wolfBoot_erase_encrypt_key(void); /* called automatically by wolfBoot_success() */
10491049
```
10501050
1051-
To use your own implementation for getting the encryption key use `CUSTOM_ENCRYPT_KEY` and `OBJS_EXTRA=src/my_custom_encrypt_key.o`. Then provide your own implementation of `int wolfBoot_get_encrypt_key(uint8_t *key, uint8_t *nonce);`
1051+
To use your own implementation for getting the encryption key use `CUSTOM_ENCRYPT_KEY` and `OBJS_EXTRA=src/my_custom_encrypt_key.o`.
1052+
Then provide your own implementation of `int RAMFUNCTION wolfBoot_get_encrypt_key(uint8_t *key, uint8_t *nonce);`
1053+
1054+
Example:
1055+
1056+
```c
1057+
int RAMFUNCTION wolfBoot_get_encrypt_key(uint8_t *key, uint8_t *nonce)
1058+
{
1059+
int i;
1060+
/* Test key: "0123456789abcdef0123456789abcdef" (32 bytes for AES-256) */
1061+
const char test_key[] = "0123456789abcdef0123456789abcdef";
1062+
/* Test nonce: "0123456789abcdef" (16 bytes) */
1063+
const char test_nonce[] = "0123456789abcdef";
1064+
1065+
for (i = 0; i < ENCRYPT_KEY_SIZE && i < (int)sizeof(test_key); i++) {
1066+
key[i] = (uint8_t)test_key[i];
1067+
}
1068+
for (i = 0; i < ENCRYPT_NONCE_SIZE && i < (int)sizeof(test_nonce); i++) {
1069+
nonce[i] = (uint8_t)test_nonce[i];
1070+
}
1071+
return 0;
1072+
}
1073+
```
10521074

10531075
To sign and encrypt an image, create a key file with the concatenated key and nonce, then use the sign tool:
10541076

@@ -1063,10 +1085,74 @@ printf "0123456789abcdef0123456789abcdef0123456789abcdef" > /tmp/enc_key.der
10631085

10641086
The result is `fitImage_v1_signed_and_encrypted.bin`, which gets placed into your OFP_A or OFP_B partitions.
10651087

1088+
```sh
1089+
sudo dd if=fitImage_v1_signed_and_encrypted.bin of=/dev/sdc2 bs=512 status=progress && sudo cmp fitImage_v1_signed_and_encrypted.bin /dev/sdc2
1090+
sudo dd if=fitImage_v1_signed_and_encrypted.bin of=/dev/sdc3 bs=512 status=progress && sudo cmp fitImage_v1_signed_and_encrypted.bin /dev/sdc3
1091+
```
1092+
10661093
During boot, wolfBoot decrypts the image headers from disk to select the best candidate, loads and decrypts the full image to RAM, then verifies integrity and authenticity before booting. On successful boot, `wolfBoot_success()` clears the key from RAM.
10671094

10681095
See the [Encrypted Partitions](encrypted_partitions.md) documentation for additional details.
10691096

1097+
### PolarFire SoC with PQC (ML-DSA)
1098+
1099+
#### Configuration
1100+
1101+
Update your `.config` file with the following ML-DSA settings:
1102+
1103+
```makefile
1104+
# ML-DSA 87 (Category 5)
1105+
SIGN=ML_DSA
1106+
HASH=SHA256
1107+
ML_DSA_LEVEL=5
1108+
IMAGE_SIGNATURE_SIZE=4627
1109+
IMAGE_HEADER_SIZE=12288
1110+
WOLFBOOT_SECTOR_SIZE?=0x4000
1111+
```
1112+
1113+
**Important:**
1114+
- The `sign` tool requires `IMAGE_HEADER_SIZE` to be set as an environment variable, even if it's already configured in `.config`. This is because the sign tool reads the environment variable separately to determine the header size for padding. Without this, the sign tool may use a smaller default header size, causing a mismatch with wolfBoot's expected header size.
1115+
- The `WOLFBOOT_SECTOR_SIZE` must be larger than the `IMAGE_HEADER_SIZE`/
1116+
1117+
#### Signing and Encryption
1118+
1119+
```sh
1120+
# Sign and Encrypt with PQ ML-DSA 5 (87)
1121+
# NOTE: IMAGE_HEADER_SIZE must match the value in .config
1122+
IMAGE_HEADER_SIZE=12288 ML_DSA_LEVEL=5 ./tools/keytools/sign --ml_dsa --sha256 --aes256 --encrypt /tmp/enc_key.der \
1123+
fitImage wolfboot_signing_private_key.der 1
1124+
```
1125+
1126+
**ML-DSA Parameter Reference:**
1127+
1128+
| ML_DSA_LEVEL | Security Category | Signature Size | Private Key | Public Key | Recommended IMAGE_HEADER_SIZE |
1129+
|--------------|-------------------|----------------|-------------|------------|------------------------------ |
1130+
| 2 | Category 2 | 2420 | 2560 | 1312 | 8192 |
1131+
| 3 | Category 3 | 3309 | 4032 | 1952 | 8192 |
1132+
| 5 | Category 5 | 4627 | 4896 | 2592 | 12288 |
1133+
1134+
For other ML-DSA levels, adjust `ML_DSA_LEVEL`, `IMAGE_SIGNATURE_SIZE`, and `IMAGE_HEADER_SIZE` accordingly in both `.config` and the signing command.
1135+
1136+
### PolarFire Performance Comparison
1137+
1138+
#### Binary Size Comparison
1139+
1140+
The following table compares wolfBoot binary sizes for different signature algorithms on PolarFire SoC (MPFS250):
1141+
1142+
| Algorithm | Hash | Text | Data | BSS | Total | Binary Size |
1143+
|-----------|--------|---------|------|---------|---------|-------------|
1144+
| ECC384 | SHA384 | 67.1 KB | 8 B | 3.0 KB | 70.2 KB | 68 KB |
1145+
| ML-DSA 87 | SHA256 | 63.9 KB | 0 B | 14.5 KB | 78.4 KB | 64 KB |
1146+
1147+
#### Boot Time Comparison
1148+
1149+
Boot time measurements on PolarFire SoC (RISC-V 64-bit U54 @ 625 MHz) for a 19MB encrypted FIT image:
1150+
1151+
| Algorithm | Hash | Load Time | Decrypt Time | Integrity Check | Signature Verify | Total Boot Time |
1152+
|-------------|---------|-----------|--------------|-----------------|------------------|-----------------|
1153+
| ECC384 | SHA384 | ~800 ms | ~2900 ms | ~1500 ms | ~70 ms | ~5.3 seconds |
1154+
| ML-DSA 87 | SHA256 | ~835 ms | ~2900 ms | ~2100 ms | ~22 ms | ~5.9 seconds |
1155+
10701156
### PolarFire Soc Debugging
10711157

10721158
Start GDB server:
@@ -1154,48 +1240,80 @@ FDT: MAC1 = 00:04:A3:5B:22:89
11541240
RISC-V 64-bit U54 (RV64GC1) 625 MHz
11551241

11561242
```
1243+
./configure --enable-riscv-asm --enable-dilithium --enable-mlkem --enable-sp=yes
1244+
make
1245+
./wolfcrypt/benchmark/benchmark
11571246
------------------------------------------------------------------------------
11581247
wolfSSL version 5.8.4
11591248
------------------------------------------------------------------------------
11601249
Math: Multi-Precision: Wolf(SP) word-size=64 bits=3072 sp_int.c
1250+
Single Precision: ecc 256 rsa/dh 2048 3072 sp_c64.c
11611251
Assembly Speedups: RISCVASM ALIGN
11621252
wolfCrypt Benchmark (block bytes 1048576, min 1.0 sec each)
1163-
RNG 5 MiB took 1.232 seconds, 4.058 MiB/s
1164-
AES-128-CBC-enc 10 MiB took 1.182 seconds, 8.457 MiB/s
1165-
AES-128-CBC-dec 10 MiB took 1.166 seconds, 8.573 MiB/s
1166-
AES-192-CBC-enc 10 MiB took 1.378 seconds, 7.257 MiB/s
1167-
AES-192-CBC-dec 10 MiB took 1.362 seconds, 7.344 MiB/s
1168-
AES-256-CBC-enc 10 MiB took 1.569 seconds, 6.373 MiB/s
1169-
AES-256-CBC-dec 10 MiB took 1.556 seconds, 6.426 MiB/s
1170-
AES-128-GCM-enc 10 MiB took 1.956 seconds, 5.113 MiB/s
1171-
AES-128-GCM-dec 10 MiB took 1.955 seconds, 5.115 MiB/s
1172-
AES-192-GCM-enc 5 MiB took 1.075 seconds, 4.650 MiB/s
1173-
AES-192-GCM-dec 5 MiB took 1.074 seconds, 4.654 MiB/s
1174-
AES-256-GCM-enc 5 MiB took 1.172 seconds, 4.268 MiB/s
1175-
AES-256-GCM-dec 5 MiB took 1.170 seconds, 4.275 MiB/s
1176-
GMAC Table 4-bit 15 MiB took 1.133 seconds, 13.245 MiB/s
1177-
CHACHA 20 MiB took 1.107 seconds, 18.064 MiB/s
1178-
CHA-POLY 15 MiB took 1.060 seconds, 14.152 MiB/s
1179-
POLY1305 75 MiB took 1.044 seconds, 71.812 MiB/s
1180-
SHA 20 MiB took 1.139 seconds, 17.561 MiB/s
1181-
SHA-256 10 MiB took 1.069 seconds, 9.350 MiB/s
1182-
SHA-384 15 MiB took 1.072 seconds, 13.994 MiB/s
1183-
SHA-512 15 MiB took 1.072 seconds, 13.990 MiB/s
1184-
SHA-512/224 15 MiB took 1.068 seconds, 14.041 MiB/s
1185-
SHA-512/256 15 MiB took 1.066 seconds, 14.070 MiB/s
1186-
HMAC-SHA 20 MiB took 1.140 seconds, 17.542 MiB/s
1187-
HMAC-SHA256 10 MiB took 1.068 seconds, 9.366 MiB/s
1188-
HMAC-SHA384 15 MiB took 1.066 seconds, 14.076 MiB/s
1189-
HMAC-SHA512 15 MiB took 1.066 seconds, 14.077 MiB/s
1190-
PBKDF2 1 KiB took 1.024 seconds, 1.129 KiB/s
1191-
RSA 2048 public 800 ops took 1.142 sec, avg 1.427 ms, 700.575 ops/sec
1192-
RSA 2048 private 100 ops took 8.450 sec, avg 84.504 ms, 11.834 ops/sec
1193-
DH 2048 key gen 60 ops took 1.010 sec, avg 16.841 ms, 59.379 ops/sec
1194-
DH 2048 agree 100 ops took 3.421 sec, avg 34.211 ms, 29.231 ops/sec
1195-
ECC [ SECP256R1] 256 key gen 100 ops took 1.304 sec, avg 13.039 ms, 76.691 ops/sec
1196-
ECDHE [ SECP256R1] 256 agree 100 ops took 1.299 sec, avg 12.992 ms, 76.970 ops/sec
1197-
ECDSA [ SECP256R1] 256 sign 100 ops took 1.338 sec, avg 13.383 ms, 74.723 ops/sec
1198-
ECDSA [ SECP256R1] 256 verify 200 ops took 1.846 sec, avg 9.231 ms, 108.333 ops/sec
1253+
RNG 5 MiB took 1.225 seconds, 4.081 MiB/s
1254+
AES-128-CBC-enc 10 MiB took 1.179 seconds, 8.478 MiB/s
1255+
AES-128-CBC-dec 10 MiB took 1.164 seconds, 8.589 MiB/s
1256+
AES-192-CBC-enc 10 MiB took 1.373 seconds, 7.281 MiB/s
1257+
AES-192-CBC-dec 10 MiB took 1.360 seconds, 7.354 MiB/s
1258+
AES-256-CBC-enc 10 MiB took 1.565 seconds, 6.389 MiB/s
1259+
AES-256-CBC-dec 10 MiB took 1.550 seconds, 6.451 MiB/s
1260+
AES-128-GCM-enc 10 MiB took 1.940 seconds, 5.156 MiB/s
1261+
AES-128-GCM-dec 10 MiB took 1.938 seconds, 5.159 MiB/s
1262+
AES-192-GCM-enc 5 MiB took 1.068 seconds, 4.680 MiB/s
1263+
AES-192-GCM-dec 5 MiB took 1.066 seconds, 4.689 MiB/s
1264+
AES-256-GCM-enc 5 MiB took 1.163 seconds, 4.298 MiB/s
1265+
AES-256-GCM-dec 5 MiB took 1.163 seconds, 4.301 MiB/s
1266+
GMAC Table 4-bit 15 MiB took 1.106 seconds, 13.566 MiB/s
1267+
CHACHA 20 MiB took 1.107 seconds, 18.068 MiB/s
1268+
CHA-POLY 15 MiB took 1.058 seconds, 14.178 MiB/s
1269+
POLY1305 75 MiB took 1.036 seconds, 72.387 MiB/s
1270+
SHA 20 MiB took 1.141 seconds, 17.535 MiB/s
1271+
SHA-256 10 MiB took 1.071 seconds, 9.336 MiB/s
1272+
SHA-384 15 MiB took 1.066 seconds, 14.068 MiB/s
1273+
SHA-512 15 MiB took 1.066 seconds, 14.070 MiB/s
1274+
SHA-512/224 15 MiB took 1.067 seconds, 14.060 MiB/s
1275+
SHA-512/256 15 MiB took 1.070 seconds, 14.023 MiB/s
1276+
SHA3-224 15 MiB took 1.328 seconds, 11.292 MiB/s
1277+
SHA3-256 15 MiB took 1.398 seconds, 10.731 MiB/s
1278+
SHA3-384 10 MiB took 1.206 seconds, 8.291 MiB/s
1279+
SHA3-512 10 MiB took 1.729 seconds, 5.785 MiB/s
1280+
SHAKE128 15 MiB took 1.142 seconds, 13.135 MiB/s
1281+
SHAKE256 15 MiB took 1.402 seconds, 10.699 MiB/s
1282+
HMAC-SHA 20 MiB took 1.145 seconds, 17.470 MiB/s
1283+
HMAC-SHA256 10 MiB took 1.074 seconds, 9.310 MiB/s
1284+
HMAC-SHA384 15 MiB took 1.076 seconds, 13.944 MiB/s
1285+
HMAC-SHA512 15 MiB took 1.069 seconds, 14.036 MiB/s
1286+
PBKDF2 1 KiB took 1.023 seconds, 1.130 KiB/s
1287+
RSA 2048 public 1000 ops took 1.087 sec, avg 1.087 ms, 920.244 ops/sec
1288+
RSA 2048 private 100 ops took 5.410 sec, avg 54.100 ms, 18.484 ops/sec
1289+
DH 2048 key gen 48 ops took 1.004 sec, avg 20.920 ms, 47.801 ops/sec
1290+
DH 2048 agree 100 ops took 2.087 sec, avg 20.873 ms, 47.909 ops/sec
1291+
ECC [ SECP256R1] 256 key gen 800 ops took 1.100 sec, avg 1.375 ms, 727.248 ops/sec
1292+
ECDHE [ SECP256R1] 256 agree 300 ops took 1.041 sec, avg 3.470 ms, 288.152 ops/sec
1293+
ECDSA [ SECP256R1] 256 sign 600 ops took 1.144 sec, avg 1.907 ms, 524.370 ops/sec
1294+
ECDSA [ SECP256R1] 256 verify 300 ops took 1.173 sec, avg 3.909 ms, 255.844 ops/sec
1295+
ECC [ SECP384R1] 384 key gen 100 ops took 3.887 sec, avg 38.867 ms, 25.729 ops/sec
1296+
ECDHE [ SECP384R1] 384 agree 100 ops took 3.883 sec, avg 38.827 ms, 25.755 ops/sec
1297+
ECDSA [ SECP384R1] 384 sign 100 ops took 3.948 sec, avg 39.485 ms, 25.326 ops/sec
1298+
ECDSA [ SECP384R1] 384 verify 100 ops took 2.619 sec, avg 26.190 ms, 38.183 ops/sec
1299+
ML-KEM 512 128 key gen 2000 ops took 1.021 sec, avg 0.511 ms, 1958.111 ops/sec
1300+
ML-KEM 512 128 encap 1700 ops took 1.006 sec, avg 0.592 ms, 1690.275 ops/sec
1301+
ML-KEM 512 128 decap 1300 ops took 1.075 sec, avg 0.827 ms, 1209.214 ops/sec
1302+
ML-KEM 768 192 key gen 1200 ops took 1.035 sec, avg 0.863 ms, 1158.970 ops/sec
1303+
ML-KEM 768 192 encap 1100 ops took 1.092 sec, avg 0.993 ms, 1006.925 ops/sec
1304+
ML-KEM 768 192 decap 800 ops took 1.055 sec, avg 1.319 ms, 758.026 ops/sec
1305+
ML-KEM 1024 256 key gen 800 ops took 1.124 sec, avg 1.405 ms, 711.862 ops/sec
1306+
ML-KEM 1024 256 encap 700 ops took 1.090 sec, avg 1.557 ms, 642.343 ops/sec
1307+
ML-KEM 1024 256 decap 600 ops took 1.181 sec, avg 1.968 ms, 508.073 ops/sec
1308+
ML-DSA 44 key gen 600 ops took 1.107 sec, avg 1.844 ms, 542.217 ops/sec
1309+
ML-DSA 44 sign 200 ops took 1.144 sec, avg 5.719 ms, 174.842 ops/sec
1310+
ML-DSA 44 verify 600 ops took 1.146 sec, avg 1.910 ms, 523.569 ops/sec
1311+
ML-DSA 65 key gen 400 ops took 1.267 sec, avg 3.167 ms, 315.744 ops/sec
1312+
ML-DSA 65 sign 200 ops took 1.687 sec, avg 8.436 ms, 118.543 ops/sec
1313+
ML-DSA 65 verify 400 ops took 1.272 sec, avg 3.180 ms, 314.428 ops/sec
1314+
ML-DSA 87 key gen 200 ops took 1.066 sec, avg 5.331 ms, 187.588 ops/sec
1315+
ML-DSA 87 sign 100 ops took 1.162 sec, avg 11.617 ms, 86.084 ops/sec
1316+
ML-DSA 87 verify 200 ops took 1.077 sec, avg 5.385 ms, 185.704 ops/sec
11991317
Benchmark complete
12001318
```
12011319

include/user_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ extern int tolower(int c);
296296
# define WOLFSSL_SHA3
297297
# define WOLFSSL_SHAKE256
298298
# define WOLFSSL_SHAKE128
299+
# define WOLFSSL_SP_NO_DYN_STACK
299300
#endif /* WOLFBOOT_SIGN_ML_DSA || WOLFBOOT_SIGN_SECONDARY_ML_DSA */
300301

301302
#ifdef WOLFBOOT_HASH_SHA3_384

lib/wolfssl

Submodule wolfssl updated 418 files

options.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ ifeq ($(SIGN),ML_DSA)
409409
KEYGEN_OPTIONS+=--ml_dsa
410410
SIGN_OPTIONS+=--ml_dsa
411411
WOLFCRYPT_OBJS+= $(ML_DSA_OBJS)
412+
WOLFCRYPT_OBJS+=$(MATH_OBJS)
412413
CFLAGS+=-D"WOLFBOOT_SIGN_ML_DSA" $(ML_DSA_EXTRA)
413414
ifneq ($(HASH),SHA3)
414415
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sha3.o
@@ -417,7 +418,7 @@ ifeq ($(SIGN),ML_DSA)
417418
ifeq ($(WOLFBOOT_SMALL_STACK),1)
418419
$(error WOLFBOOT_SMALL_STACK with ML-DSA not supported yet)
419420
else
420-
STACK_USAGE=19544
421+
STACK_USAGE=25000
421422
endif
422423
endif
423424

src/image.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ static void wolfBoot_verify_signature_ml_dsa(uint8_t key_slot,
696696
int sig_len = 0;
697697
int verify_res = 0;
698698

699-
wolfBoot_printf("info: ML-DSA wolfBoot_verify_signature\n");
699+
wolfBoot_printf("info: ML-DSA %d verify_signature: pubkey %d, sig %d\n",
700+
ML_DSA_LEVEL, KEYSTORE_PUBKEY_SIZE, ML_DSA_IMAGE_SIGNATURE_SIZE);
700701

701702
#if !defined WOLFBOOT_ENABLE_WOLFHSM_CLIENT || \
702703
(defined WOLFBOOT_ENABLE_WOLFHSM_CLIENT && \
@@ -784,7 +785,7 @@ static void wolfBoot_verify_signature_ml_dsa(uint8_t key_slot,
784785
ret = wc_MlDsaKey_GetSigLen(&ml_dsa, &sig_len);
785786

786787
if (ret != 0 || sig_len <= 0) {
787-
wolfBoot_printf("error: wc_MlDsaKey_GetPubLen returned %d\n", ret);
788+
wolfBoot_printf("error: wc_MlDsaKey_GetSigLen returned %d\n", ret);
788789
ret = -1;
789790
}
790791
else if (sig_len != ML_DSA_IMAGE_SIGNATURE_SIZE) {
@@ -798,7 +799,7 @@ static void wolfBoot_verify_signature_ml_dsa(uint8_t key_slot,
798799
wolfBoot_printf("info: using ML-DSA security level: %d\n",
799800
ML_DSA_LEVEL);
800801

801-
/* Finally verify signagure. */
802+
/* Finally verify signature. */
802803
ret = wc_MlDsaKey_Verify(&ml_dsa, sig, ML_DSA_IMAGE_SIGNATURE_SIZE,
803804
img->sha_hash, WOLFBOOT_SHA_DIGEST_SIZE,
804805
&verify_res);

src/libwolfboot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
#include <stddef.h> /* for size_t */
6464

65-
#if defined(EXT_ENCRYPTED) && (defined(__WOLFBOOT) || defined(UNIT_TEST))
65+
#if defined(EXT_ENCRYPTED) && (defined(__WOLFBOOT) || defined(UNIT_TEST) || defined(MMU))
6666
#include "encrypt.h"
6767
static int encrypt_initialized = 0;
6868

@@ -1376,7 +1376,7 @@ int wolfBoot_fallback_is_possible(void)
13761376
static uint8_t ENCRYPT_KEY[ENCRYPT_KEY_SIZE + ENCRYPT_NONCE_SIZE];
13771377
#endif
13781378

1379-
#if defined(EXT_ENCRYPTED) && (defined(__WOLFBOOT) || defined(UNIT_TEST))
1379+
#if defined(EXT_ENCRYPTED) && (defined(__WOLFBOOT) || defined(UNIT_TEST) || defined(MMU))
13801380
int RAMFUNCTION wolfBoot_enable_fallback_iv(int enable)
13811381
{
13821382
int prev = 0;
@@ -1408,7 +1408,7 @@ void RAMFUNCTION wolfBoot_crypto_set_iv(const uint8_t *nonce, uint32_t iv_counte
14081408
/* Fallback IV offset is single-use; clear it once applied. */
14091409
encrypt_iv_offset = 0;
14101410
}
1411-
#endif /* EXT_ENCRYPTED && (__WOLFBOOT || UNIT_TEST) */
1411+
#endif /* EXT_ENCRYPTED && (__WOLFBOOT || UNIT_TEST || MMU) */
14121412

14131413
static int RAMFUNCTION hal_set_key(const uint8_t *k, const uint8_t *nonce)
14141414
{

src/sdhci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,8 +1328,10 @@ int sdhci_init(void)
13281328
reg &= ~SDHCI_HRS06_EMM_MASK;
13291329
#ifdef DISK_EMMC
13301330
reg |= SDHCI_HRS06_MODE_LEGACY; /* eMMC Legacy mode */
1331+
wolfBoot_printf("SDHCI: eMMC mode\n");
13311332
#else
13321333
reg |= SDHCI_HRS06_MODE_SD; /* SD card mode */
1334+
wolfBoot_printf("SDHCI: SDCard mode\n");
13331335
#endif
13341336
SDHCI_REG_SET(SDHCI_HRS06, reg);
13351337

test-app/RISCV64-mpfs250.ld

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ SECTIONS
6767
} >LSRAM AT> IRAM
6868

6969
/* Uninitialized data section */
70+
/* Mark as NOLOAD so it's not included in binary (zero-initialized at runtime) */
7071
. = ALIGN(8);
71-
.bss :
72+
.bss (NOLOAD) :
7273
{
7374
/* This is used by the startup in order to initialize the .bss section */
7475
_start_bss = .; /* define a global symbol at bss start */
@@ -83,7 +84,8 @@ SECTIONS
8384
} >LSRAM
8485

8586
/* User_heap_stack section, used to check that there is enough RAM left */
86-
._user_heap_stack :
87+
/* Mark as NOLOAD so it's not included in binary (zero-initialized at runtime) */
88+
._user_heap_stack (NOLOAD) :
8789
{
8890
. = ALIGN(8);
8991
PROVIDE ( end = . );

0 commit comments

Comments
 (0)