Skip to content

Commit 83f7aa9

Browse files
committed
Make swap RAM buffer size configurable
1 parent 4a1b41c commit 83f7aa9

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

boot/bootutil/include/bootutil/bootutil_public.h

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ extern "C" {
8282
#define BOOT_MAGIC_ALIGN_SIZE BOOT_MAGIC_SZ
8383
#endif
8484

85+
#ifdef MCUBOOT_SWAP_BUF_SIZE
86+
#define BOOT_SWAP_BUF_SIZE MCUBOOT_SWAP_BUF_SIZE
87+
#elif BOOT_MAX_ALIGN > 1024
88+
#define BOOT_SWAP_BUF_SIZE BOOT_MAX_ALIGN
89+
#else
90+
#define BOOT_SWAP_BUF_SIZE 1024
91+
#endif
92+
8593
#define BOOT_MAGIC_GOOD 1
8694
#define BOOT_MAGIC_BAD 2
8795
#define BOOT_MAGIC_UNSET 3

boot/bootutil/src/loader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ boot_copy_region(struct boot_loader_state *state,
924924
uint8_t image_index;
925925
#endif
926926

927-
TARGET_STATIC uint8_t buf[1024] __attribute__((aligned(4)));
927+
TARGET_STATIC uint8_t buf[BOOT_SWAP_BUF_SIZE] __attribute__((aligned(4)));
928928

929929
#if !defined(MCUBOOT_ENC_IMAGES)
930930
(void)state;

boot/mbed/mbed_lib.json

+6
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@
214214
"macro_name": "MCUBOOT_INCLUDE_KEYS",
215215
"accepted_values": [true, null],
216216
"value": null
217+
},
218+
"swap-buf-size": {
219+
"help": "Specify swap ram buffer size.",
220+
"macro_name": "MCUBOOT_SWAP_BUF_SIZE",
221+
"accepted_values": [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],
222+
"value": null
217223
}
218224
}
219225
}

0 commit comments

Comments
 (0)