mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-29 10:08:59 +00:00
5c142aad7b
After the kernel has switched version to 5.10, JA76PF2 and RouterStations lost the capability to sysupgrade the OpenWrt version. The cause is the lack of porting the patches responsible for partial flash erase block writing and these boards FIS directory and RedBoot config partitions share the same erase block. Because of that the FIS directory can't be updated to accommodate kernel/rootfs partition size changes. This could be remedied by bootloader update, but it is very intrusive and could potentially lead to non-trivial recovery procedure, if something went wrong. The less difficult option is to use OpenWrt kernel loader, which will let us use static partition sizes and employ mtd splitter to dynamically adjust kernel and rootfs partition sizes. On sysupgrade from ath79 19.07 or 21.02 image, which still let to modify FIS directory, the loader will be written to kernel partition, while the kernel+rootfs to rootfs partition. The caveats are: * image format changes, no possible upgrade from ar71xx target images * downgrade to any older OpenWrt version will require TFTP recovery or usage of bootloader command line interface To downgrade to 19.07 or 21.02, or to upgrade if one is already on OpenWrt with kernel 5.10, for RouterStations use TFTP recovery procedure. For JA76PF2 use instructions from this commit message: commit0cc87b3bac
("ath79: image: disable sysupgrade images for routerstations and ja76pf2"), replacing kernel image with loader (loader.bin suffix) and rootfs image with firmware (firmware.bin suffix). Fixes:b10d604459
("kernel: add linux 5.10 support") Fixes:15aa53d7ee
("ath79: switch to Kernel 5.10") Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com> (mkubntimage was moved to generic-ubnt.mk) Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
104 lines
2.6 KiB
Makefile
104 lines
2.6 KiB
Makefile
include $(TOPDIR)/rules.mk
|
|
include $(INCLUDE_DIR)/image.mk
|
|
|
|
KERNEL_LOADADDR = 0x80060000
|
|
|
|
DEVICE_VARS += LOADER_FLASH_OFFS LOADER_TYPE
|
|
DEVICE_VARS += LOADER_FLASH_MAX LOADER_KERNEL_MAGIC
|
|
DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID
|
|
DEVICE_VARS += RAS_BOARD RAS_ROOTFS_SIZE RAS_VERSION
|
|
|
|
define Build/loader-common
|
|
rm -rf $@.src
|
|
$(MAKE) -C lzma-loader \
|
|
PKG_BUILD_DIR="$@.src" \
|
|
TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
|
|
$(1) compile loader.$(LOADER_TYPE)
|
|
mv "$@.$(LOADER_TYPE)" "$@"
|
|
rm -rf $@.src
|
|
endef
|
|
|
|
define Build/loader-kernel
|
|
$(call Build/loader-common, \
|
|
LOADER_DATA="$@" \
|
|
BOARD="$(DEVICE_NAME)" )
|
|
endef
|
|
|
|
define Build/loader-okli-compile
|
|
$(call Build/loader-common, \
|
|
FLASH_OFFS=$(LOADER_FLASH_OFFS) \
|
|
FLASH_MAX=$(LOADER_FLASH_MAX) \
|
|
KERNEL_MAGIC=$(LOADER_KERNEL_MAGIC) \
|
|
BOARD="$(DEVICE_NAME)" )
|
|
endef
|
|
|
|
# Arguments: <output name> <kernel offset>
|
|
define Build/loader-okli
|
|
dd if=$(KDIR)/loader-$(word 1,$(1)).$(LOADER_TYPE) bs=$(word 2,$(1)) conv=sync of="$@.new"
|
|
cat "$@" >> "$@.new"
|
|
mv "$@.new" "$@"
|
|
endef
|
|
|
|
define Build/append-loader-okli
|
|
cat "$(KDIR)/loader-$(word 1,$(1)).$(LOADER_TYPE)" >> "$@"
|
|
endef
|
|
|
|
define Build/append-loader-okli-uimage
|
|
cat "$(KDIR)/loader-$(word 1,$(1)).uImage" >> "$@"
|
|
endef
|
|
|
|
define Build/relocate-kernel
|
|
rm -rf $@.relocate
|
|
$(CP) ../../generic/image/relocate $@.relocate
|
|
$(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS)
|
|
( \
|
|
dd if=$@.relocate/loader.bin bs=32 conv=sync && \
|
|
perl -e '@s = stat("$@"); print pack("N", @s[7])' && \
|
|
cat "$@" \
|
|
) > "$@.new"
|
|
mv "$@.new" "$@"
|
|
rm -rf $@.relocate
|
|
endef
|
|
|
|
|
|
define Device/Default
|
|
DEVICE_DTS_DIR := ../dts
|
|
DEVICE_DTS = $$(SOC)_$(1)
|
|
PROFILES = Default
|
|
MTDPARTS :=
|
|
BLOCKSIZE := 64k
|
|
KERNEL := kernel-bin | append-dtb | lzma | uImage lzma
|
|
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma
|
|
LOADER_KERNEL_MAGIC :=
|
|
LOADER_FLASH_MAX :=
|
|
LOADER_FLASH_OFFS :=
|
|
LOADER_TYPE :=
|
|
COMPILE :=
|
|
IMAGES := sysupgrade.bin
|
|
IMAGE/sysupgrade.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | \
|
|
append-rootfs | pad-rootfs | check-size | append-metadata
|
|
endef
|
|
|
|
define Device/loader-okli-uimage
|
|
LOADER_TYPE := bin
|
|
COMPILE := loader-$(1).bin loader-$(1).uImage
|
|
COMPILE/loader-$(1).bin := loader-okli-compile
|
|
COMPILE/loader-$(1).uImage := append-loader-okli $(1) | pad-to 64k | \
|
|
lzma | uImage lzma
|
|
endef
|
|
|
|
include $(SUBTARGET).mk
|
|
|
|
ifeq ($(SUBTARGET),generic)
|
|
include generic-tp-link.mk
|
|
include generic-ubnt.mk
|
|
endif
|
|
|
|
ifeq ($(SUBTARGET),tiny)
|
|
include tiny-netgear.mk
|
|
include tiny-tp-link.mk
|
|
include tiny-ubnt.mk
|
|
endif
|
|
|
|
$(eval $(call BuildImage))
|