Browse Source

lantiq: ar7: use okli loader for FRITZ!Box

With Kernel 5.10 the ar7 FRITZ!Box are not booting the initramfs nor the
sysupgrade image any more. Presumably due to the grown kernel.

Use the okli preloader to workaround the bootloader issue. No solution
so far for the initramfs.

Signed-off-by: Mathias Kresin <[email protected]>
Mathias Kresin 4 years ago
parent
commit
9764968bba

+ 4 - 0
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7312.dts

@@ -1,6 +1,7 @@
 #include "ar9.dtsi"
 #include "ar9.dtsi"
 
 
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 
 / {
 / {
 	compatible = "avm,fritz7312", "lantiq,xway", "lantiq,ar9";
 	compatible = "avm,fritz7312", "lantiq,xway", "lantiq,ar9";
@@ -131,7 +132,10 @@
 
 
 			partition@20000 {
 			partition@20000 {
 				label = "firmware";
 				label = "firmware";
+				compatible = "openwrt,uimage", "denx,uimage";
 				reg = <0x20000 0xf60000>;
 				reg = <0x20000 0xf60000>;
+				openwrt,ih-magic = <IH_MAGIC_OKLI>;
+				openwrt,offset = <0x11000>;
 			};
 			};
 
 
 			partition@f80000 {
 			partition@f80000 {

+ 4 - 0
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_avm_fritz7320.dts

@@ -1,6 +1,7 @@
 #include "ar9.dtsi"
 #include "ar9.dtsi"
 
 
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 
 / {
 / {
 	compatible = "avm,fritz7320", "lantiq,xway", "lantiq,ar9";
 	compatible = "avm,fritz7320", "lantiq,xway", "lantiq,ar9";
@@ -140,8 +141,11 @@
 			};
 			};
 
 
 			partition@20000 {
 			partition@20000 {
+				compatible = "openwrt,uimage", "denx,uimage";
 				label = "firmware";
 				label = "firmware";
 				reg = <0x20000 0xf60000>;
 				reg = <0x20000 0xf60000>;
+				openwrt,ih-magic = <IH_MAGIC_OKLI>;
+				openwrt,offset = <0x11000>;
 			};
 			};
 
 
 			partition@f80000 {
 			partition@f80000 {

+ 34 - 1
target/linux/lantiq/image/Makefile

@@ -49,12 +49,35 @@ define Build/fullimage
 	rm [email protected]
 	rm [email protected]
 endef
 endef
 
 
-DEVICE_VARS += SIGNATURE MAGIC CRC32_POLY
+define Build/loader-okli-compile
+	rm -rf [email protected]
+	$(MAKE) -C lzma-loader \
+		PKG_BUILD_DIR="[email protected]" \
+		TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
+		PLATFORM="lantiq" \
+		LZMA_TEXT_START=0x82000000 \
+		LOADADDR=0x80002000 \
+		FLASH_START=0x10000000 \
+		FLASH_OFFS=$(LOADER_FLASH_OFFS) \
+		FLASH_MAX=0x0 \
+		$(1) compile loader.bin
+	mv "[email protected]" "$@"
+	rm -rf [email protected]
+endef
+
+define Build/prepend-loader-okli
+	cat "$(KDIR)/loader-$(word 1,$(1)).bin" "$@" >> "[email protected]"
+	mv "[email protected]" "$@"
+endef
+
+DEVICE_VARS += SIGNATURE MAGIC CRC32_POLY LOADER_FLASH_OFFS
+
 DTS_DIR := $(DTS_DIR)/lantiq
 DTS_DIR := $(DTS_DIR)/lantiq
 
 
 # Shared device definition: applies to every defined device
 # Shared device definition: applies to every defined device
 define Device/Default
 define Device/Default
   PROFILES = Default
   PROFILES = Default
+  COMPILE :=
   KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
   KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
   KERNEL_INITRAMFS_NAME = $$(KERNEL_NAME)-initramfs
   KERNEL_INITRAMFS_NAME = $$(KERNEL_NAME)-initramfs
   KERNEL := kernel-bin | append-dtb | lzma | uImage lzma
   KERNEL := kernel-bin | append-dtb | lzma | uImage lzma
@@ -105,6 +128,16 @@ define Device/AVM
 	append-rootfs | pad-rootfs | check-size | append-metadata
 	append-rootfs | pad-rootfs | check-size | append-metadata
 endef
 endef
 
 
+define Device/AVM_preloader
+  DEVICE_VENDOR := AVM
+  COMPILE := loader-$(1).bin
+  COMPILE/loader-$(1).bin := loader-okli-compile | lzma | eva-image | \
+	pad-to 64k | append-avm-fakeroot | pad-to 4k
+  KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x4f4b4c49 | \
+	prepend-loader-okli $(1)
+  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | eva-image
+endef
+
 ifeq ($(SUBTARGET),ase)
 ifeq ($(SUBTARGET),ase)
 DEFAULT_SOC := amazonse
 DEFAULT_SOC := amazonse
 include amazonse.mk
 include amazonse.mk

+ 4 - 2
target/linux/lantiq/image/ar9.mk

@@ -1,8 +1,9 @@
 define Device/avm_fritz7312
 define Device/avm_fritz7312
-  $(Device/AVM)
+  $(Device/AVM_preloader)
   DEVICE_MODEL := FRITZ!Box 7312
   DEVICE_MODEL := FRITZ!Box 7312
   SOC := ar9
   SOC := ar9
   IMAGE_SIZE := 15744k
   IMAGE_SIZE := 15744k
+  LOADER_FLASH_OFFS := 0x31000
   DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-basic-wolfssl \
   DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-basic-wolfssl \
 	kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
 	kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
 	kmod-ltq-adsl-ar9-fw-b kmod-ltq-atm-ar9 \
 	kmod-ltq-adsl-ar9-fw-b kmod-ltq-atm-ar9 \
@@ -12,12 +13,13 @@ endef
 TARGET_DEVICES += avm_fritz7312
 TARGET_DEVICES += avm_fritz7312
 
 
 define Device/avm_fritz7320
 define Device/avm_fritz7320
-  $(Device/AVM)
+  $(Device/AVM_preloader)
   DEVICE_MODEL := FRITZ!Box 7320
   DEVICE_MODEL := FRITZ!Box 7320
   DEVICE_ALT0_VENDOR := 1&1
   DEVICE_ALT0_VENDOR := 1&1
   DEVICE_ALT0_MODEL := HomeServer
   DEVICE_ALT0_MODEL := HomeServer
   SOC := ar9
   SOC := ar9
   IMAGE_SIZE := 15744k
   IMAGE_SIZE := 15744k
+  LOADER_FLASH_OFFS := 0x31000
   DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-basic-wolfssl \
   DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-basic-wolfssl \
 	kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
 	kmod-ltq-adsl-ar9-mei kmod-ltq-adsl-ar9 \
 	kmod-ltq-adsl-ar9-fw-b kmod-ltq-atm-ar9 \
 	kmod-ltq-adsl-ar9-fw-b kmod-ltq-atm-ar9 \