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 <linusw@kernel.org>
This commit is contained in:
Linus Walleij 2026-01-24 18:13:24 +01:00
parent 428bcee2f8
commit 691aa70e16
4 changed files with 56 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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