From 619ea01a014edc2720b81a768561ea6d20298c0b Mon Sep 17 00:00:00 2001 From: Michal Lenc Date: Thu, 17 Jul 2025 17:12:27 +0200 Subject: [PATCH 1/2] boot/nxboot/loader/flash.c: open partition with O_DIRECT flag There is no need to use buffers in a bootloader. We expect a sequential access, therefore we just need to erase the erase page before writing to it for the first time, which is something FTL layer already takes care of. Signed-off-by: Michal Lenc --- boot/nxboot/loader/flash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/nxboot/loader/flash.c b/boot/nxboot/loader/flash.c index fdbab4bb99d..9142b25d9f0 100644 --- a/boot/nxboot/loader/flash.c +++ b/boot/nxboot/loader/flash.c @@ -64,7 +64,7 @@ int flash_partition_open(const char *path) { int fd; - fd = open(path, O_RDWR); + fd = open(path, O_RDWR | O_DIRECT); if (fd < 0) { syslog(LOG_ERR, "Could not open %s partition: %s\n", From 95e4b0cce3210ef6bb411da9bf4913bfabba6ac9 Mon Sep 17 00:00:00 2001 From: Michal Lenc Date: Thu, 17 Jul 2025 17:14:15 +0200 Subject: [PATCH 2/2] boot/nxboot/loader/boot.c: copy partition with blocksize large writes The previous logic MAX(info_from.blocksize, info_where.blocksize) was incorrect. The most effective access with by writing the entire size of the block, therefore just decide the size based on the target page size. Signed-off-by: Michal Lenc --- boot/nxboot/loader/boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/nxboot/loader/boot.c b/boot/nxboot/loader/boot.c index 9364ba16f94..42f83a66e2e 100644 --- a/boot/nxboot/loader/boot.c +++ b/boot/nxboot/loader/boot.c @@ -164,7 +164,7 @@ static int copy_partition(int from, int where, struct nxboot_state *state, #ifdef CONFIG_NXBOOT_PRINTF_PROGRESS_PERCENT total_size = remain * 100; #endif - blocksize = MAX(info_from.blocksize, info_where.blocksize); + blocksize = info_where.blocksize; buf = malloc(blocksize); if (!buf)