[openwrt/openwrt] realtek: rt-loader: make search_image() generic

LEDE Commits lede-commits at lists.infradead.org
Fri Jan 2 09:03:52 PST 2026


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/2e74ef5be135fb8af51535ffbb7b1312f6b91375

commit 2e74ef5be135fb8af51535ffbb7b1312f6b91375
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Tue Dec 30 16:54:56 2025 +0100

    realtek: rt-loader: make search_image() generic
    
    Until now search_image() is used for searching a uImage on
    flash (or the memory mapped equivalent). In a future commit
    this will be reused to search for a piggy-backed uimage.
    Make this function generic by
    
    - replacing "flash" with "image" in variables
    - Search bytewise and do not rely on 4 byte alignment
    - remove 2 obsolete variables
    - move console output to caller
    
    Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Link: https://github.com/openwrt/openwrt/pull/21332
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 target/linux/realtek/image/rt-loader/src/main.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/target/linux/realtek/image/rt-loader/src/main.c b/target/linux/realtek/image/rt-loader/src/main.c
index 697ee6723a..f78d91ded8 100644
--- a/target/linux/realtek/image/rt-loader/src/main.c
+++ b/target/linux/realtek/image/rt-loader/src/main.c
@@ -128,19 +128,15 @@ void *decompress(void *out, void *in, int len)
 	return out;
 }
 
-void search_image(void **flash_addr, int *flash_size, void **load_addr)
+void search_image(void **image_addr, int *image_size, void **load_addr)
 {
-	unsigned char *addr = *flash_addr;
-	unsigned int image_size = 0;
-	unsigned int *maxaddr;
+	unsigned char *addr = *image_addr;
 
-	printf("Searching for uImage starting at 0x%08x ...\n", addr);
-
-	*flash_addr = NULL;
-	for (int i = 0; i < 256 * 1024; i += 4, addr += 4) {
+	*image_addr = NULL;
+	for (int i = 0; i < 256 * 1024; i += 1, addr += 1) {
 		if (is_uimage(addr)) {
-			*flash_addr = addr;
-			*flash_size = *(int *)(addr + 12);
+			*image_addr = addr;
+			*image_size = *(int *)(addr + 12);
 			*load_addr = *(void **)(addr + 16);
 			_kernel_comp_type = addr[31];
 			break;
@@ -152,6 +148,8 @@ void load_kernel(void *flash_start)
 {
 	void *flash_addr = flash_start;
 
+	printf("Searching for uImage starting at 0x%08x ...\n", flash_addr);
+
 	search_image(&flash_addr, &_kernel_data_size, &_kernel_load_addr);
 	_kernel_data_addr = _my_load_addr - _kernel_data_size - 1024;
 




More information about the lede-commits mailing list