Skip to content

Commit ad1fb3d

Browse files
nordicjmnvlsianpu
authored andcommitted
boot_serial: Allow using a buffer larger than 512 bytes
There are 3 levels of buffers and only the first one seems to be configurable, this fixes that issue. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
1 parent 0b6d343 commit ad1fb3d

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

boot/boot_serial/src/boot_serial.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@
7878

7979
BOOT_LOG_MODULE_DECLARE(mcuboot);
8080

81-
#define BOOT_SERIAL_INPUT_MAX 512
81+
#ifndef MCUBOOT_SERIAL_MAX_RECEIVE_SIZE
82+
#define MCUBOOT_SERIAL_MAX_RECEIVE_SIZE 512
83+
#endif
84+
8285
#define BOOT_SERIAL_OUT_MAX (128 * BOOT_IMAGE_NUMBER)
8386

8487
#ifdef __ZEPHYR__
@@ -107,8 +110,8 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);
107110
#define IMAGES_ITER(x)
108111
#endif
109112

110-
static char in_buf[BOOT_SERIAL_INPUT_MAX + 1];
111-
static char dec_buf[BOOT_SERIAL_INPUT_MAX + 1];
113+
static char in_buf[MCUBOOT_SERIAL_MAX_RECEIVE_SIZE + 1];
114+
static char dec_buf[MCUBOOT_SERIAL_MAX_RECEIVE_SIZE + 1];
112115
const struct boot_uart_funcs *boot_uf;
113116
static struct nmgr_hdr *bs_hdr;
114117
static bool bs_entry;

boot/zephyr/Kconfig.serial_recovery

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,16 @@ config MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD
5252
selection is done.
5353

5454
config BOOT_MAX_LINE_INPUT_LEN
55-
int "Maximum command line length"
55+
int "Maximum input line length"
5656
default 512
5757
help
58-
Maximum length of commands transported over the serial port.
58+
Maximum length of input serial port buffer.
59+
60+
config BOOT_SERIAL_MAX_RECEIVE_SIZE
61+
int "Maximum command line length"
62+
default 1024
63+
help
64+
Maximum length of received commands via the serial port.
5965

6066
config BOOT_SERIAL_DETECT_PORT
6167
string "GPIO device to trigger serial recovery mode (DEPRECATED)"

boot/zephyr/include/mcuboot_config/mcuboot_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@
241241
#define MCUBOOT_MAX_IMG_SECTORS 128
242242
#endif
243243

244+
#ifdef CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE
245+
#define MCUBOOT_SERIAL_MAX_RECEIVE_SIZE CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE
246+
#endif
247+
244248
/* Support 32-byte aligned flash sizes */
245249
#if DT_HAS_CHOSEN(zephyr_flash)
246250
#if DT_PROP_OR(DT_CHOSEN(zephyr_flash), write_block_size, 0) > 8

0 commit comments

Comments
 (0)