Skip to content

Commit 5843121

Browse files
nordicjmmbolivar-nordic
authored andcommitted
[nrf fromlist] 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. Upstream PR: mcu-tools/mcuboot#1536 Signed-off-by: Jamie McCrae <[email protected]> (cherry picked from commit db3da7f)
1 parent da841f5 commit 5843121

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
@@ -59,10 +59,16 @@ config BOOT_SERIAL_UNALIGNED_BUFFER_SIZE
5959
requirements. Set to 0 to disable.
6060

6161
config BOOT_MAX_LINE_INPUT_LEN
62-
int "Maximum command line length"
62+
int "Maximum input line length"
6363
default 512
6464
help
65-
Maximum length of commands transported over the serial port.
65+
Maximum length of input serial port buffer.
66+
67+
config BOOT_SERIAL_MAX_RECEIVE_SIZE
68+
int "Maximum command line length"
69+
default 1024
70+
help
71+
Maximum length of received commands via the serial port.
6672

6773
config BOOT_SERIAL_DETECT_PORT
6874
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
@@ -244,6 +244,10 @@
244244
#define MCUBOOT_SERIAL_UNALIGNED_BUFFER_SIZE CONFIG_BOOT_SERIAL_UNALIGNED_BUFFER_SIZE
245245
#endif
246246

247+
#ifdef CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE
248+
#define MCUBOOT_SERIAL_MAX_RECEIVE_SIZE CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE
249+
#endif
250+
247251
/* Support 32-byte aligned flash sizes */
248252
#if DT_HAS_CHOSEN(zephyr_flash)
249253
#if DT_PROP_OR(DT_CHOSEN(zephyr_flash), write_block_size, 0) > 8

0 commit comments

Comments
 (0)