summaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2023-08-05 09:02:20 +0200
committerLinus Walleij <linus.walleij@linaro.org>2024-05-01 21:32:23 +0200
commit219018185e52a49b6a676a3591fe28406bb1a062 (patch)
tree1d35014298a4c804163bd540340904783a07c141 /target/linux
parentf789454df1146aa426d6cc28fc61b005ecfb82c3 (diff)
downloadopenwrt-219018185e52a49b6a676a3591fe28406bb1a062.tar.gz
openwrt-219018185e52a49b6a676a3591fe28406bb1a062.tar.bz2
openwrt-219018185e52a49b6a676a3591fe28406bb1a062.zip
bmips: Build U-Boot into the XG6846 target
It appears that the CFE boot loader found in the XG6846 cannot load kernels over a certain size, and the old relocate hack is not working. What to do? We can build a small U-Boot into the image, make CFE boot that, place the kernel immediately after U-Boot, and use U-Boot to boot the system instead. The compiled u-boot.bin becomes around ~300KB and with LZMA compression it will swiftly fit into 128KB, so we use two 64KB erase blocks right after the CFE to store an imagetag:ed U-Boot. Reviewed-by: Paul Donald <newtwen+github@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/bmips/dts/bcm6328-inteno-xg6846.dts3
-rw-r--r--target/linux/bmips/image/Makefile31
-rw-r--r--target/linux/bmips/image/bcm6328.mk2
3 files changed, 34 insertions, 2 deletions
diff --git a/target/linux/bmips/dts/bcm6328-inteno-xg6846.dts b/target/linux/bmips/dts/bcm6328-inteno-xg6846.dts
index ee9d19839c..72f85a53ca 100644
--- a/target/linux/bmips/dts/bcm6328-inteno-xg6846.dts
+++ b/target/linux/bmips/dts/bcm6328-inteno-xg6846.dts
@@ -117,9 +117,10 @@
};
partition@10000 {
- compatible = "brcm,bcm963xx-imagetag";
+ compatible = "openwrt,uimage", "denx,uimage";
reg = <0x010000 0xfe0000>;
label = "firmware";
+ openwrt,offset = <0x30000>;
};
partition@ff0000 {
diff --git a/target/linux/bmips/image/Makefile b/target/linux/bmips/image/Makefile
index 9311e2df09..b79974931d 100644
--- a/target/linux/bmips/image/Makefile
+++ b/target/linux/bmips/image/Makefile
@@ -4,6 +4,7 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
KERNEL_LOADADDR := 0x80010000 # RAM start + 64K
+UBOOT_ENTRY := 0x81c00000
LOADER_ENTRY := 0x81000000 # RAM start + 16M, for relocate
LZMA_TEXT_START := 0x82000000 # RAM start + 32M
@@ -94,6 +95,21 @@ define Build/cfe-bin
$(CFE_EXTRAS) $(1)
endef
+# Build a CFE image with just U-Boot
+define Build/cfe-bin-uboot
+ cp $(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-u-boot.bin $@
+ $(call Build/lzma)
+ mv $@ $@.uboot.lzma
+ echo "dummy" > $@.dummyfs
+ $(STAGING_DIR_HOST)/bin/imagetag -i $@.uboot.lzma -f $@.dummyfs \
+ --output $@ --boardid $(CFE_BOARD_ID) --chipid $(CHIP_ID) \
+ --entry $(UBOOT_ENTRY) --load-addr $(UBOOT_ENTRY) \
+ --info1 "$(call ModelNameLimit16,$(DEVICE_NAME))" \
+ $(CFE_EXTRAS) $(1)
+ rm $@.uboot.lzma
+ rm $@.dummyfs
+endef
+
define Build/cfe-jffs2
$(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
--big-endian \
@@ -284,6 +300,21 @@ define Device/bcm63xx-cfe-legacy
KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma-cfe
endef
+# CFE images with U-Boot in front of the kernel, these will execute
+# U-Boot instead of the kernel and U-Boot will then proceed to load
+# the kernel. The reason to do this is that CFE is sometimes unable to
+# load big kernels even with the lzma loader tricks.
+define Device/bcm63xx-cfe-uboot
+ $(Device/bcm63xx-cfe)
+ KERNEL := kernel-bin | append-dtb | lzma | uImage lzma
+ IMAGE/cfe.bin := cfe-bin-uboot | pad-to $$$$$$$$(($$(BLOCKSIZE))) | \
+ append-kernel | pad-to $$$$$$$$(($$(BLOCKSIZE))) | \
+ append-rootfs $$$$(if $$$$(FLASH_MB),--pad $$$$(shell expr $$$$(FLASH_MB) / 2))
+ IMAGE/sysupgrade.bin := cfe-bin-uboot | pad-to $$$$$$$$(($$(BLOCKSIZE))) | \
+ append-kernel | pad-to $$$$$$$$(($$(BLOCKSIZE))) | \
+ append-rootfs | append-metadata
+endef
+
# CFE expects a single JFFS2 partition with cferam and kernel. However,
# it's possible to fool CFE into properly loading both cferam and kernel
# from two different JFFS2 partitions by adding dummy files (see
diff --git a/target/linux/bmips/image/bcm6328.mk b/target/linux/bmips/image/bcm6328.mk
index 0e249fa96e..b85b6ac7a8 100644
--- a/target/linux/bmips/image/bcm6328.mk
+++ b/target/linux/bmips/image/bcm6328.mk
@@ -52,7 +52,7 @@ endef
TARGET_DEVICES += innacomm_w3400v6
define Device/inteno_xg6846
- $(Device/bcm63xx-cfe-legacy)
+ $(Device/bcm63xx-cfe-uboot)
DEVICE_VENDOR := Inteno
DEVICE_MODEL := XG6846
CHIP_ID := 6328