aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/image/lzma-loader
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/ath79/image/lzma-loader')
-rw-r--r--target/linux/ath79/image/lzma-loader/Makefile6
-rw-r--r--target/linux/ath79/image/lzma-loader/src/Makefile13
-rw-r--r--target/linux/ath79/image/lzma-loader/src/head.S13
-rw-r--r--target/linux/ath79/image/lzma-loader/src/loader.c2
-rw-r--r--target/linux/ath79/image/lzma-loader/src/loader.lds1
5 files changed, 26 insertions, 9 deletions
diff --git a/target/linux/ath79/image/lzma-loader/Makefile b/target/linux/ath79/image/lzma-loader/Makefile
index 9b81e87306..738093a958 100644
--- a/target/linux/ath79/image/lzma-loader/Makefile
+++ b/target/linux/ath79/image/lzma-loader/Makefile
@@ -47,7 +47,11 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared
clean all
loader.gz: $(PKG_BUILD_DIR)/loader.bin
- gzip -nc9 $< > $(LOADER_GZ)
+ # Workaround for buggy bootloaders: Some devices
+ # (TP-Link TL-WR1043ND v1) don't work correctly when
+ # the uncompressed loader is too small (probably a cache
+ # invalidation issue)
+ dd if=$< bs=512K conv=sync | gzip -nc9 > $(LOADER_GZ)
loader.elf: $(PKG_BUILD_DIR)/loader.elf
$(CP) $< $(LOADER_ELF)
diff --git a/target/linux/ath79/image/lzma-loader/src/Makefile b/target/linux/ath79/image/lzma-loader/src/Makefile
index 133bf6ee8f..7773f027a2 100644
--- a/target/linux/ath79/image/lzma-loader/src/Makefile
+++ b/target/linux/ath79/image/lzma-loader/src/Makefile
@@ -21,7 +21,6 @@ LOADER_DATA :=
BOARD :=
FLASH_OFFS :=
FLASH_MAX :=
-KERNEL_CMDLINE := rootfstype=squashfs
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
@@ -34,15 +33,17 @@ BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug \
CFLAGS = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 \
-mno-abicalls -fno-pic -ffunction-sections -pipe -mlong-calls \
- -fno-common -ffreestanding -fhonour-copts \
+ -fno-common -ffreestanding -fhonour-copts -nostartfiles \
-mabi=32 -march=mips32r2 \
-Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap
CFLAGS += -D_LZMA_PROB32
+CFLAGS += -flto
ASFLAGS = $(CFLAGS) -D__ASSEMBLY__
-LDFLAGS = -static --gc-sections -no-warn-mismatch
-LDFLAGS += -e startup -T loader.lds -Ttext $(LZMA_TEXT_START)
+LDFLAGS = -static -Wl,--gc-sections -Wl,-no-warn-mismatch
+LDFLAGS += -Wl,-e,startup -T loader.lds -Wl,-Ttext,$(LZMA_TEXT_START)
+LDFLAGS += -flto -fwhole-program
O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
@@ -87,7 +88,7 @@ data.o: $(LOADER_DATA)
$(LD) -r -b binary --oformat $(O_FORMAT) -T lzma-data.lds -o $@ $<
loader: $(OBJECTS)
- $(LD) $(LDFLAGS) -o $@ $(OBJECTS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS)
loader.bin: loader
$(OBJCOPY) $(BIN_FLAGS) $< $@
@@ -96,7 +97,7 @@ loader2.o: loader.bin
$(LD) -r -b binary --oformat $(O_FORMAT) -o $@ $<
loader.elf: loader2.o
- $(LD) -e startup -T loader2.lds -Ttext $(LOADADDR) -o $@ $<
+ $(LD) -z max-page-size=0x1000 -e startup -T loader2.lds -Ttext $(LOADADDR) -o $@ $<
mrproper: clean
diff --git a/target/linux/ath79/image/lzma-loader/src/head.S b/target/linux/ath79/image/lzma-loader/src/head.S
index 47a7c9bd63..d414b14d11 100644
--- a/target/linux/ath79/image/lzma-loader/src/head.S
+++ b/target/linux/ath79/image/lzma-loader/src/head.S
@@ -42,6 +42,19 @@ LEAF(startup)
mtc0 t0, CP0_STATUS
ehb
+ /*
+ * Some bootloaders set the 'Kseg0 coherency algorithm' to
+ * 'Cacheable, noncoherent, write-through, no write allocate'
+ * and this cause performance issues. Let's go and change it to
+ * 'Cacheable, noncoherent, write-back, write allocate'
+ */
+ mfc0 t0, CP0_CONFIG
+ li t1, ~7 #~CONF_CM_CMASK
+ and t0, t1
+ ori t0, 3 #CONF_CM_CACHABLE_NONCOHERENT
+ mtc0 t0, CP0_CONFIG
+ nop
+
mtc0 zero, CP0_COUNT
mtc0 zero, CP0_COMPARE
ehb
diff --git a/target/linux/ath79/image/lzma-loader/src/loader.c b/target/linux/ath79/image/lzma-loader/src/loader.c
index cc73eb1721..794c4b6285 100644
--- a/target/linux/ath79/image/lzma-loader/src/loader.c
+++ b/target/linux/ath79/image/lzma-loader/src/loader.c
@@ -75,7 +75,7 @@ static unsigned long kernel_la;
#ifdef CONFIG_KERNEL_CMDLINE
#define kernel_argc 2
static const char kernel_cmdline[] = CONFIG_KERNEL_CMDLINE;
-static const char *kernel_argv[] = {
+static const char *const kernel_argv[] = {
NULL,
kernel_cmdline,
NULL,
diff --git a/target/linux/ath79/image/lzma-loader/src/loader.lds b/target/linux/ath79/image/lzma-loader/src/loader.lds
index 80cc7ca3ec..01ff852361 100644
--- a/target/linux/ath79/image/lzma-loader/src/loader.lds
+++ b/target/linux/ath79/image/lzma-loader/src/loader.lds
@@ -13,7 +13,6 @@ SECTIONS {
.data : {
*(.data)
*(.data.*)
- . = . + 524288; /* workaround for buggy bootloaders */
}
. = ALIGN(32);