]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: rt-loader: make search_image() generic
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Tue, 30 Dec 2025 15:54:56 +0000 (16:54 +0100)
committerRobert Marko <robimarko@gmail.com>
Fri, 2 Jan 2026 17:03:45 +0000 (18:03 +0100)
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@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21332
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/image/rt-loader/src/main.c

index 697ee6723a0242cc44a4fb657a2cb20cd0f1d4f1..f78d91ded84c8240bc434c0922024926c7a41471 100644 (file)
@@ -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;