aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/gemini
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2019-07-17 19:23:32 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2019-08-17 16:57:32 +0200
commitdc451a4b24b2096fe33eb7fa136614597cd601d5 (patch)
tree6e7ce66b895b1850b7784c74b88c42108340a056 /target/linux/gemini
parenta608380e421e601622e524e35f79b5c964781c64 (diff)
downloadupstream-dc451a4b24b2096fe33eb7fa136614597cd601d5.tar.gz
upstream-dc451a4b24b2096fe33eb7fa136614597cd601d5.tar.bz2
upstream-dc451a4b24b2096fe33eb7fa136614597cd601d5.zip
gemini: Enable flash boot on reference design type
The flash layout on the Storlink reference design for Gemini is using 2 MB flash for the kernel, and it also insists on overwriting the partition table with default values on every boot. The same is true for the SQ201. This poses a problem on recent OpenWrt firmware as the base zImage is bigger than 2 MB. At the same time there is a ramdisk partition of 6 MB that we don't really need. The partition table looks like this: Creating 7 MTD partitions on "30000000.flash": 0x000000000000-0x000000016000 : "BOOT" 0x000000120000-0x000000320000 : "Kern" 0x000000320000-0x000000920000 : "Ramdisk" 0x000000920000-0x000000f20000 : "Application" 0x000000f20000-0x000000f40000 : "VCTL" 0x000000f40000-0x000000fe0000 : "CurConf" 0x000000fe0000-0x000001000000 : "FIS directory" On boot the "Kern" partition is copied to RAM @0x01600000 and the "Ramdisk" partition is copied to RAM @0x00800000. Then the kernel is executed. The idea with this patch is to extend the "Kern" partition with the "Ramdisk" partition to get a full 8 MB to use for the kernel. Then we put the OpenWrt JFFS2 rootfs inside the "Application" partition. We create a small assembly loop that we prepend to the "Kern" image that will copy the "Kern" from 0x0160000 and the "Ramdisk" from 0x00800000 and put them in consecutive space at 0x00400000 and execute it from there, using "Application" as rootfs. We generate 3 main files: - zImage - contains the assembly bootstrap loop and the first part of the generated kernel image - rd.gz - contains the second part of the generated kernel image - hddapp.tgz - contains the root filesystem On the SQ201 I flash these manually using the native boot loader PLATO, "Y" alternative for the zImage, "R" for the rd.gz image and "A" for hddapp.tgz. This works fine and I can now boot to prompt on the SQ201 with nothing but flash. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'target/linux/gemini')
-rw-r--r--target/linux/gemini/image/Makefile31
-rw-r--r--target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch2
2 files changed, 24 insertions, 9 deletions
diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile
index e1b6941201..24402f6a9b 100644
--- a/target/linux/gemini/image/Makefile
+++ b/target/linux/gemini/image/Makefile
@@ -7,6 +7,10 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
+define Build/copy-kernel
+ $(MAKE) -C copy-kernel CROSS_COMPILE=$(TARGET_CROSS)
+endef
+
# Cook a "WRGG" image, this board is apparently one in the D-Link
# WRGG family and uses the exact same firmware format as other
# D-Link devices.
@@ -76,18 +80,29 @@ endef
# Create the default image format used by the StorLink reference design
# SL93512r, Raidsonic NAS4220B and Itian Square One SQ201
-# with the squashfs and overlay inside the "rd.gz" file.
-# We pad it out to 6144K which is the size of the initramfs partition.
+# with the squashfs and overlay inside the "application" partition.
+#
+# These devices have a hard-coded partition table that the boot loader
+# constantly reflashes back, so we need to work around it like this:
#
-# The "application" partition is just blank. You can put anything
-# there when using OpenWRT. We just use that to create the
-# "sysupgrade" firmware image.
+# 0x000000120000-0x000000320000 : "Kern" - small copy routine and first
+# part of the kernel goes here
+# 0x000000320000-0x000000920000 : "Ramdisk" - second part of the kernel and
+# some padding goes here
+# 0x000000920000-0x000000f20000 : "Application" - rootfs goes here
define Build/storlink-default-images
mkdir -p $@.tmp
- mv $@ $@.tmp/rd.gz
- dd if=/dev/zero of=$@.tmp/hddapp.tgz bs=6144k count=1
- cp $(IMAGE_KERNEL) $@.tmp/zImage
+ $(call Build/copy-kernel)
+ # "App" partition is the rootfs
+ mv $@ $@.tmp/hddapp.tgz
+ # 256 bytes copy routine
+ dd if=copy-kernel/copy-kernel.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=2096640
+ # Put the rest of the kernel into the "ramdisk"
+ dd if=$(IMAGE_KERNEL) of=$@.tmp/rd.gz bs=1 skip=2096640 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
diff --git a/target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch b/target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch
index 7517d62ed3..578e970c0f 100644
--- a/target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch
+++ b/target/linux/gemini/patches-4.19/0011-ARM-dts-Fix-up-SQ201-flash-access.patch
@@ -20,7 +20,7 @@ Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
chosen {
- bootargs = "console=ttyS0,115200n8 root=/dev/sda1 rw rootwait";
-+ bootargs = "console=ttyS0,115200n8 root=/dev/mtdblock2 rw rootfstype=squashfs,jffs2 rootwait";
++ bootargs = "console=ttyS0,115200n8 root=/dev/mtdblock3 rw rootfstype=squashfs,jffs2 rootwait";
stdout-path = &uart0;
};