Skip to content

Commit 00bf88b

Browse files
committed
Added upper limit for NO_PARTITIONS builds
1 parent a7b1002 commit 00bf88b

File tree

7 files changed

+18
-0
lines changed

7 files changed

+18
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ include/target.h: $(TARGET_H_TEMPLATE) FORCE
604604
sed -e "s/@WOLFBOOT_DTS_UPDATE_ADDRESS@/$(WOLFBOOT_DTS_UPDATE_ADDRESS)/g" | \
605605
sed -e "s/@WOLFBOOT_LOAD_ADDRESS@/$(WOLFBOOT_LOAD_ADDRESS)/g" | \
606606
sed -e "s/@WOLFBOOT_LOAD_DTS_ADDRESS@/$(WOLFBOOT_LOAD_DTS_ADDRESS)/g" | \
607+
sed -e "s/@WOLFBOOT_RAMBOOT_MAX_SIZE@/$(WOLFBOOT_RAMBOOT_MAX_SIZE)/g" | \
607608
sed -e "s/@WOLFBOOT_PARTITION_SELF_HEADER_ADDRESS@/$(WOLFBOOT_PARTITION_SELF_HEADER_ADDRESS)/g" \
608609
> $@
609610

config/examples/polarfire_mpfs250.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ WOLFBOOT_LOAD_ADDRESS?=0x8E000000
6262
# Partition layout for PolarFire SoC MPFS250T
6363
# Using update_disk loader we just need to specify the partition number or A/B
6464
WOLFBOOT_NO_PARTITIONS=1
65+
WOLFBOOT_RAMBOOT_MAX_SIZE=0x80000000
6566
CFLAGS_EXTRA+=-DBOOT_PART_A=1
6667
CFLAGS_EXTRA+=-DBOOT_PART_B=2
6768
# Speed up disk partition read (512KB chunks - max DMA size)

config/examples/raspi3-encrypted.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PKA?=0
1010
WOLFTPM?=0
1111

1212
WOLFBOOT_NO_PARTITIONS=1
13+
WOLFBOOT_RAMBOOT_MAX_SIZE=0x20000000
1314
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x140000
1415
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x1140000
1516
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xFFFFFFFF

config/examples/raspi3.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ NO_XIP?=1
1313
NO_QNX?=1
1414
WOLFBOOT_SECTOR_SIZE=0x400
1515
WOLFBOOT_NO_PARTITIONS=1
16+
WOLFBOOT_RAMBOOT_MAX_SIZE=0x20000000
1617
WOLFBOOT_LOAD_ADDRESS?=0x3080000
1718
WOLFBOOT_LOAD_DTS_ADDRESS?=0x400000

config/examples/versal_vmk180_sdcard.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ CROSS_COMPILE=aarch64-none-elf-
6666
# These are 0-based indices into the parsed partition array:
6767
# part[0]=boot, part[1]=OFP_A, part[2]=OFP_B, part[3]=rootfs
6868
WOLFBOOT_NO_PARTITIONS=1
69+
WOLFBOOT_RAMBOOT_MAX_SIZE=0x80000000
6970
CFLAGS_EXTRA+=-DBOOT_PART_A=1
7071
CFLAGS_EXTRA+=-DBOOT_PART_B=2
7172

include/target.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@
116116
/* Load address in RAM for staged OS (update_ram only) */
117117
#define WOLFBOOT_LOAD_ADDRESS @WOLFBOOT_LOAD_ADDRESS@
118118
#endif
119+
120+
/* Optional RAM-boot image size cap for targets without partitions */
121+
#define WOLFBOOT_RAMBOOT_MAX_SIZE @WOLFBOOT_RAMBOOT_MAX_SIZE@
119122
#define WOLFBOOT_LOAD_DTS_ADDRESS @WOLFBOOT_LOAD_DTS_ADDRESS@
120123

121124

src/update_ram.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,20 @@ int wolfBoot_ramboot(struct wolfBoot_image *img, uint8_t *src, uint8_t *dst)
8282

8383
/* determine size of partition */
8484
img_size = wolfBoot_image_size((uint8_t*)dst);
85+
#if defined(WOLFBOOT_NO_PARTITIONS)
86+
# ifndef WOLFBOOT_RAMBOOT_MAX_SIZE
87+
# error "WOLFBOOT_RAMBOOT_MAX_SIZE required when WOLFBOOT_NO_PARTITIONS=1"
88+
# endif
89+
if (img_size > WOLFBOOT_RAMBOOT_MAX_SIZE) {
90+
wolfBoot_printf("Invalid image size %u at %p\n", img_size, src);
91+
return -1;
92+
}
93+
#elif defined(WOLFBOOT_PARTITION_SIZE)
8594
if (img_size > (WOLFBOOT_PARTITION_SIZE - IMAGE_HEADER_SIZE)) {
8695
wolfBoot_printf("Invalid image size %u at %p\n", img_size, src);
8796
return -1;
8897
}
98+
#endif
8999

90100
/* Read the entire image into RAM */
91101
wolfBoot_printf("Loading image %d bytes from %p to %p...",

0 commit comments

Comments
 (0)