ramips: lzma-loader: make FLASH_START configurable
authorChuanhong Guo <gch981213@gmail.com>
Wed, 2 Sep 2020 06:22:29 +0000 (14:22 +0800)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Thu, 3 Sep 2020 12:15:30 +0000 (14:15 +0200)
FLASH_START is supposed to point at the memory area where NOR flash are
mapped. We currently have an incorrect FLASH_START copied from ar71xx
back then and the loader doesn't work under OKLI mode.
On ramips, mt7621 has it's flash mapped to 0x1fc00000 and other SoCs
uses 0x1c000000. This commit makes FLASH_START a configurable value to
handle both cases.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
target/linux/ramips/image/lzma-loader/Makefile
target/linux/ramips/image/lzma-loader/src/Makefile
target/linux/ramips/image/lzma-loader/src/loader.c

index f22151c9d7059b3a36e63e136d438e0b8f33b8fa..4cf700d8c6463b4f2e7094409b793f8a8f5a0b03 100644 (file)
@@ -13,6 +13,7 @@ LOADER                := loader.bin
 LOADER_NAME    := $(basename $(notdir $(LOADER)))
 LOADER_DATA    :=
 TARGET_DIR     :=
+FLASH_START    :=
 FLASH_OFFS     :=
 FLASH_MAX      :=
 BOARD          :=
@@ -40,6 +41,7 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared
        $(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE="$(TARGET_CROSS)" \
                LZMA_TEXT_START=$(LZMA_TEXT_START) \
                LOADER_DATA=$(LOADER_DATA) \
+               FLASH_START=$(FLASH_START) \
                FLASH_OFFS=$(FLASH_OFFS) \
                FLASH_MAX=$(FLASH_MAX) \
                BOARD="$(BOARD)" \
index d20cd77346abcaf61777897d3f42111c42f88d33..97fd6dad47b27180499a71ea3a84a5037c84a729 100644 (file)
@@ -19,6 +19,7 @@ LOADADDR      :=
 LZMA_TEXT_START        := 0x80a00000
 LOADER_DATA    :=
 BOARD          :=
+FLASH_START    :=
 FLASH_OFFS     :=
 FLASH_MAX      :=
 PLATFORM       :=
@@ -64,6 +65,10 @@ ifneq ($(strip $(KERNEL_CMDLINE)),)
 CFLAGS         += -DCONFIG_KERNEL_CMDLINE='"$(KERNEL_CMDLINE)"'
 endif
 
+ifneq ($(strip $(FLASH_START)),)
+CFLAGS         += -DCONFIG_FLASH_START=$(FLASH_START)
+endif
+
 ifneq ($(strip $(FLASH_OFFS)),)
 CFLAGS         += -DCONFIG_FLASH_OFFS=$(FLASH_OFFS)
 endif
index c73b60b3514aafa7f877e63b03a257319519309b..a3513eccf16f972727eeaf7c25d195ec2fb5fe47 100644 (file)
@@ -28,9 +28,6 @@
 #include "printf.h"
 #include "LzmaDecode.h"
 
-#define AR71XX_FLASH_START     0x1f000000
-#define AR71XX_FLASH_END       0x1fe00000
-
 #define KSEG0                  0x80000000
 #define KSEG1                  0xa0000000
 
@@ -178,7 +175,7 @@ static void lzma_init_data(void)
        unsigned long kernel_ofs;
        unsigned long kernel_size;
 
-       flash_base = (unsigned char *) KSEG1ADDR(AR71XX_FLASH_START);
+       flash_base = (unsigned char *) KSEG1ADDR(CONFIG_FLASH_START);
 
        printf("Looking for OpenWrt image... ");