From 691aa70e1693542eee795df4bed2b46f6af26e63 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 24 Jan 2026 18:13:24 +0100 Subject: [PATCH] gemini: create a copy-kernel for 3072k kernels The Raidsonic devices do not use a 2048k kernel "Kern" partition like the Storlink reference designs. Instead it uses a 3072k partition to fit a slightly larger kernel. Sadly the current OpenWrt Gemini kernel is still bigger than 3072k so we need to make use of the Ramdisk partition as well. Create a special "copy-kernel" version that can deal with the Raidsonic 3072k kernels. Tested on the Raidsonic IB-4220-B booting kernel v6.12.66. Fix a copy/paste error in the image generation makefile while we are at it. Link: https://github.com/openwrt/openwrt/pull/21686 Signed-off-by: Linus Walleij --- target/linux/gemini/image/Makefile | 17 ++++--- .../linux/gemini/image/copy-kernel/Makefile | 5 ++- .../{copy-kernel.S => copy-kernel-2048k.S} | 0 .../image/copy-kernel/copy-kernel-3072k.S | 45 +++++++++++++++++++ 4 files changed, 56 insertions(+), 11 deletions(-) rename target/linux/gemini/image/copy-kernel/{copy-kernel.S => copy-kernel-2048k.S} (100%) create mode 100644 target/linux/gemini/image/copy-kernel/copy-kernel-3072k.S diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index ba32d1c64f..7e208ed981 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -94,14 +94,13 @@ define CreateStorlinkTarfile # "Application" partition is the rootfs mv $@ $@.tmp/hddapp.tgz - # 256 bytes copy routine - # TODO fix for IB-4220-B - dd if=$(KDIR)/copy-kernel.bin of=$@.tmp/zImage + # 512 bytes copy routine + dd if=$(KDIR)/copy-kernel-$(2).bin of=$@.tmp/zImage $(call Image/pad-to,$@.tmp/zImage,512) # Copy first part of the kernel into zImage - dd if=$(IMAGE_KERNEL) of=$@.tmp/zImage bs=1 seek=512 count=$(2) + dd if=$(IMAGE_KERNEL) of=$@.tmp/zImage bs=1 seek=512 count=$(3) # Put the rest of the kernel into the "ramdisk" - dd if=$(IMAGE_KERNEL) of=$@.tmp/rd.gz bs=1 skip=$(2) count=6144k conv=sync + dd if=$(IMAGE_KERNEL) of=$@.tmp/rd.gz bs=1 skip=$(3) count=6144k conv=sync cp ./ImageInfo-$(1) $@.tmp/ImageInfo sed -i -e "s/DATESTR/`date +%Y%m%d $(if $(SOURCE_DATE_EPOCH),--date "@$(SOURCE_DATE_EPOCH)")`/g" $@.tmp/ImageInfo @@ -115,12 +114,12 @@ endef # 2048k "Kern" partition define Build/storlink-default-image - $(call CreateStorlinkTarfile,$(1),2096640) + $(call CreateStorlinkTarfile,$(1),2048k,2096640) endef -# 3032k "Kern" partition +# 3072k "Kern" partition define Build/raidsonic-ib-4220-b-image - $(call CreateStorlinkTarfile,$(1),3145216) + $(call CreateStorlinkTarfile,$(1),3072k,3145216) endef # WBD-111 and WBD-222: @@ -228,7 +227,7 @@ define Device/raidsonic_ib-4220-b # Application 6144k | = 15360k IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 6144k | \ raidsonic-ib-4220-b-image $(1) - IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 6144k | \ + IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | pad-to 6144k | \ raidsonic-ib-4220-b-image $(1) | append-metadata endef TARGET_DEVICES += raidsonic_ib-4220-b diff --git a/target/linux/gemini/image/copy-kernel/Makefile b/target/linux/gemini/image/copy-kernel/Makefile index 9ba283bb01..befac6912a 100644 --- a/target/linux/gemini/image/copy-kernel/Makefile +++ b/target/linux/gemini/image/copy-kernel/Makefile @@ -16,7 +16,7 @@ BIN_FLAGS := -O binary -S SRC_DIR := $(CURDIR)/ OUT_DIR := $(if $(O),$(if $(patsubst %/,,$(O)),$(O)/,$(O)),$(SRC_DIR)) -all: $(OUT_DIR)copy-kernel.bin +all: $(OUT_DIR)copy-kernel-2048k.bin $(OUT_DIR)copy-kernel-3072k.bin # Don't build dependencies, this may die if $(CC) isn't gcc dep: @@ -35,4 +35,5 @@ $(OUT_DIR)%.bin: $(OUT_DIR)%.o mrproper: clean clean: - rm -f $(OUT_DIR)copy-kernel.bin $(OUT_DIR)copy-kernel.o + rm -f $(OUT_DIR)copy-kernel-2048k.bin $(OUT_DIR)copy-kernel-2048k.o + rm -f $(OUT_DIR)copy-kernel-3072k.bin $(OUT_DIR)copy-kernel-3072k.o diff --git a/target/linux/gemini/image/copy-kernel/copy-kernel.S b/target/linux/gemini/image/copy-kernel/copy-kernel-2048k.S similarity index 100% rename from target/linux/gemini/image/copy-kernel/copy-kernel.S rename to target/linux/gemini/image/copy-kernel/copy-kernel-2048k.S diff --git a/target/linux/gemini/image/copy-kernel/copy-kernel-3072k.S b/target/linux/gemini/image/copy-kernel/copy-kernel-3072k.S new file mode 100644 index 0000000000..e6b53f2bd2 --- /dev/null +++ b/target/linux/gemini/image/copy-kernel/copy-kernel-3072k.S @@ -0,0 +1,45 @@ + // Arm assembly to copy the Gemini kernel on Raidsonic + // designs and derived devices with the same flash layout and + // boot loader. + // + // This will execute at 0x01600000 + // + // Copies the kernel from two fragments (originally zImage + // and initramdisk) to 0x00400000 making space for a kernel + // image of up to 8 MB except for these 512 bytes used for + // this bootstrap. + // + // 0x01600200 .. 0x018fffff -> 0x00400000 .. 0x006ffdff + // 0x00800000 .. 0x00dfffff -> 0x006ffe00 .. 0x00cffdff + + // Memory used for this bootstrap + .equ BOOT_HEADROOM, 0x200 + + .global _start // Stand-alone assembly code +_start: + mov r1, #0x01600000 + mov r2, #0x00400000 + mov r3, #0x00300000 + add r1, r1, #BOOT_HEADROOM + sub r3, r3, #BOOT_HEADROOM +copyloop1: + ldr r0, [r1] + str r0, [r2] + add r1, r1, #4 + add r2, r2, #4 + sub r3, r3, #4 + cmp r3, #0 + bne copyloop1 + mov r1, #0x00800000 + mov r3, #0x00600000 +copyloop2: + ldr r0, [r1] + str r0, [r2] + add r1, r1, #4 + add r2, r2, #4 + sub r3, r3, #4 + cmp r3, #0 + bne copyloop2 + mov r0, #0x00400000 + // Let's go + mov pc, r0