Skip to content

Commit

Permalink
boot_serial: increase the unaligned buffer range
Browse files Browse the repository at this point in the history
- Increases the unaligned buffer range and default value
  to support the flash program size up to
  512 (maximum supported by Zephyr platforms now).
- Fixes the serial recovery for LPC55x and MCXNx.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
  • Loading branch information
butok committed Oct 14, 2024
1 parent b9d69dd commit dd3121f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions boot/boot_serial/src/boot_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ bs_upload(char *buf, int len)
const uint8_t *img_chunk = NULL; /* Pointer to buffer with received image chunk */
size_t img_chunk_len = 0; /* Length of received image chunk */
size_t img_chunk_off = SIZE_MAX; /* Offset of image chunk within image */
uint8_t rem_bytes; /* Reminder bytes after aligning chunk write to
size_t rem_bytes; /* Reminder bytes after aligning chunk write to
* to flash alignment */
uint32_t img_num_tmp = UINT_MAX; /* Temp variable for image number */
static uint32_t img_num = 0;
Expand Down Expand Up @@ -947,7 +947,7 @@ bs_upload(char *buf, int len)
if (flash_area_align(fap) > 1 &&
(((size_t)img_chunk) & (flash_area_align(fap) - 1)) != 0) {
/* Buffer address incompatible with write address, use buffer to write */
uint8_t write_size = MCUBOOT_SERIAL_UNALIGNED_BUFFER_SIZE;
size_t write_size = MCUBOOT_SERIAL_UNALIGNED_BUFFER_SIZE;
uint8_t wbs_aligned[MCUBOOT_SERIAL_UNALIGNED_BUFFER_SIZE];

while (img_chunk_len >= flash_area_align(fap)) {
Expand Down
4 changes: 2 additions & 2 deletions boot/zephyr/Kconfig.serial_recovery
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ config MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD

config BOOT_SERIAL_UNALIGNED_BUFFER_SIZE
int "Stack buffer for unaligned memory writes"
default 64
range 0 128
default 512
range 0 1024
help
Specifies the stack usage for a buffer which is used for unaligned
memory access when data is written to a device with memory alignment
Expand Down

0 comments on commit dd3121f

Please sign in to comment.