realtek: add rt-loader (runtime loader)
authorMarkus Stockhausen <[email protected]>
Sun, 8 Jun 2025 16:11:37 +0000 (12:11 -0400)
committerRobert Marko <[email protected]>
Sat, 28 Jun 2025 14:14:55 +0000 (16:14 +0200)
commitccbff8bbdd1aaca3ad76fc129b8d53effb161183
treeffd68274f445b0af3ebe483e2713d438e8a1473e
parentba2ae60a00e8c109a4a73c6d98bff89f1a7bbd89
realtek: add rt-loader (runtime loader)

The bootloader of many Realtek switches only supports gzipped kernel images.
With limited flash space that might get critical in future versions. For better
compression allow support for compressed images. For this a new loader was
developed. Several ideas have been taken over from the existing lzma loader
but this has been enhanced to make integration simpler. What is new:

- Loader is position independent. No need to define load addresses
- Loader identifies device memory on its own
- Loader uses "official" upstream kernel lzma uncompress
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/decompress_unlzma.c
- Loader uses "official" UNMODIFIED nanoprintg that is used by several
  bare metal projects. https://github.com/charlesnicholson/nanoprintf

Compiled the loader ist just under 12KiB and during boot it will show:

rt-loader
Found RTL8380M (chip id 6275C) with 256MB
Relocate 2924240 bytes from 0x80100000 to 0x8fce0000
Extract kernel with 2900144 bytes from 0x8fce521c to 0x80100000...
Extracted kernel size is 9814907 bytes
Booting kernel from 0x80100000 ...

[    0.000000] Linux version 6.12.33 ...
[    0.000000] RTL838X model is 83806800
...

Signed-off-by: Markus Stockhausen <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/18397
Signed-off-by: Robert Marko <[email protected]>
target/linux/realtek/image/rt-loader/Makefile [new file with mode: 0644]
target/linux/realtek/image/rt-loader/include/board.h [new file with mode: 0644]
target/linux/realtek/image/rt-loader/include/globals.h [new file with mode: 0644]
target/linux/realtek/image/rt-loader/include/memory.h [new file with mode: 0644]
target/linux/realtek/image/rt-loader/include/nanoprintf.h [new file with mode: 0644]
target/linux/realtek/image/rt-loader/linker/linker.ld [new file with mode: 0644]
target/linux/realtek/image/rt-loader/src/board.c [new file with mode: 0644]
target/linux/realtek/image/rt-loader/src/main.c [new file with mode: 0644]
target/linux/realtek/image/rt-loader/src/memory.c [new file with mode: 0644]
target/linux/realtek/image/rt-loader/src/startup.S [new file with mode: 0644]
target/linux/realtek/image/rt-loader/src/unlzma.c [new file with mode: 0644]