...and max flash offset
The mtdsplit parser was recently refactored
to allow the kernel to have custom image header magic.
Let's also do this for the lzma-loader
For example:
When implemented together,
this allows the kernel to "appear" to be a rootfs
by OEM software in order to write an image
that is actually kernel + rootfs.
At the same time,
it would boot to openwrt normally
by setting the same magic in DTS.
Both of the variables
have a default value that is unchanged
when not defined in the makefiles
This has no effect on the size of the loader
when lzma compressed.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
(cherry picked from commit
1b8bd17c2d07c7397015a86941db9e114e1d349a)
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
endef
define Build/loader-okli-compile
- $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0)
+ $(call Build/loader-common, \
+ FLASH_OFFS=$(LOADER_FLASH_OFFS) \
+ FLASH_MAX=$(LOADER_FLASH_MAX) \
+ KERNEL_MAGIC=$(LOADER_KERNEL_MAGIC) )
endef
# Arguments: <output name> <kernel offset>
LOADER := loader.bin
LOADER_NAME := $(basename $(notdir $(LOADER)))
LOADER_DATA :=
+KERNEL_MAGIC :=
TARGET_DIR :=
FLASH_OFFS :=
FLASH_MAX :=
LZMA_TEXT_START=$(LZMA_TEXT_START) \
LOADADDR=$(LOADADDR) \
LOADER_DATA=$(LOADER_DATA) \
+ KERNEL_MAGIC=$(KERNEL_MAGIC) \
FLASH_OFFS=$(FLASH_OFFS) \
FLASH_MAX=$(FLASH_MAX) \
BOARD="$(BOARD)" \
LOADADDR :=
LZMA_TEXT_START := 0x80a00000
LOADER_DATA :=
+KERNEL_MAGIC :=
BOARD :=
FLASH_OFFS :=
FLASH_MAX :=
CFLAGS += -DLZMA_WRAPPER=1 -DLOADADDR=$(LOADADDR)
endif
+ifneq ($(strip $(KERNEL_MAGIC)),)
+CFLAGS += -DCONFIG_KERNEL_MAGIC=$(KERNEL_MAGIC)
+endif
+
ifneq ($(strip $(KERNEL_CMDLINE)),)
CFLAGS += -DCONFIG_KERNEL_CMDLINE='"$(KERNEL_CMDLINE)"'
endif
p = flash_base + flash_ofs;
magic = get_be32(p);
+#ifdef CONFIG_KERNEL_MAGIC
+ if (magic == CONFIG_KERNEL_MAGIC) {
+#else
if (magic == IH_MAGIC_OKLI) {
+#endif
hdr = (struct image_header *) p;
break;
}