aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorTobias Schramm <tobleminer@gmail.com>2018-05-03 16:27:10 +0200
committerMathias Kresin <dev@kresin.me>2018-06-21 06:55:10 +0200
commit5529e713578217fc9fac706783b8c61f3c649274 (patch)
tree9cd31545b9c1a22ced30f0d8bd2a4f897a0b8ff4 /target
parent615186d415054836363644d0cf2c437dd47a7abe (diff)
downloadupstream-5529e713578217fc9fac706783b8c61f3c649274.tar.gz
upstream-5529e713578217fc9fac706783b8c61f3c649274.tar.bz2
upstream-5529e713578217fc9fac706783b8c61f3c649274.zip
ramips: Add support for mt7621 to lzma-loader
Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
Diffstat (limited to 'target')
-rw-r--r--target/linux/ramips/image/lzma-loader/Makefile3
-rw-r--r--target/linux/ramips/image/lzma-loader/src/Makefile31
-rw-r--r--target/linux/ramips/image/lzma-loader/src/board-mt7621.c39
-rw-r--r--target/linux/ramips/image/lzma-loader/src/loader.c4
-rw-r--r--target/linux/ramips/image/lzma-loader/src/mt7621.mk1
5 files changed, 60 insertions, 18 deletions
diff --git a/target/linux/ramips/image/lzma-loader/Makefile b/target/linux/ramips/image/lzma-loader/Makefile
index 783301695f..f22151c9d7 100644
--- a/target/linux/ramips/image/lzma-loader/Makefile
+++ b/target/linux/ramips/image/lzma-loader/Makefile
@@ -16,6 +16,7 @@ TARGET_DIR :=
FLASH_OFFS :=
FLASH_MAX :=
BOARD :=
+PLATFORM :=
ifeq ($(TARGET_DIR),)
TARGET_DIR := $(KDIR)
@@ -42,7 +43,7 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared
FLASH_OFFS=$(FLASH_OFFS) \
FLASH_MAX=$(FLASH_MAX) \
BOARD="$(BOARD)" \
- PLATFORM="ralink" \
+ PLATFORM="$(PLATFORM)" \
clean all
loader.gz: $(PKG_BUILD_DIR)/loader.bin
diff --git a/target/linux/ramips/image/lzma-loader/src/Makefile b/target/linux/ramips/image/lzma-loader/src/Makefile
index f861666e62..d20cd77346 100644
--- a/target/linux/ramips/image/lzma-loader/src/Makefile
+++ b/target/linux/ramips/image/lzma-loader/src/Makefile
@@ -22,35 +22,39 @@ BOARD :=
FLASH_OFFS :=
FLASH_MAX :=
PLATFORM :=
+CACHE_FLAGS :=
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump
-BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
+
+include $(PLATFORM).mk
+
+BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug \
+ -R .MIPS.abiflags -S
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 -DARCH=$(PLATFORM)
+CFLAGS += -D_LZMA_PROB32
+CFLAGS += -flto
+CFLAGS += $(CACHE_FLAGS)
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 -Wl,-z,max-page-size=4096
O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
OBJECTS := head.o loader.o cache.o board-$(PLATFORM).o printf.o LzmaDecode.o
-include $(PLATFORM).mk
-CFLAGS+=$(CACHE_FLAGS)
-ASFLAGS+=$(CACHE_FLAGS)
-
ifneq ($(strip $(LOADER_DATA)),)
OBJECTS += data.o
CFLAGS += -DLZMA_WRAPPER=1 -DLOADADDR=$(LOADADDR)
@@ -68,11 +72,6 @@ ifneq ($(strip $(FLASH_MAX)),)
CFLAGS += -DCONFIG_FLASH_MAX=$(FLASH_MAX)
endif
-BOARD_DEF := $(shell echo $(strip $(BOARD)) | tr a-z A-Z | tr - _)
-ifneq ($(BOARD_DEF),)
-CFLAGS += -DCONFIG_BOARD_$(BOARD_DEF)
-endif
-
all: loader.elf
# Don't build dependencies, this may die if $(CC) isn't gcc
@@ -90,7 +89,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) $< $@
@@ -99,7 +98,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) -e startup -T loader2.lds -Ttext $(LOADADDR) -z max-page-size=4096 -o $@ $<
mrproper: clean
diff --git a/target/linux/ramips/image/lzma-loader/src/board-mt7621.c b/target/linux/ramips/image/lzma-loader/src/board-mt7621.c
new file mode 100644
index 0000000000..b90b2ed89f
--- /dev/null
+++ b/target/linux/ramips/image/lzma-loader/src/board-mt7621.c
@@ -0,0 +1,39 @@
+/*
+ * Arch specific code for mt7621 based boards, based on code for Ralink boards
+ *
+ * Copyright (C) 2018 Tobias Schramm <tobleminer@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include "config.h"
+
+#define READREG(r) *(volatile uint32_t *)(r)
+#define WRITEREG(r,v) *(volatile uint32_t *)(r) = v
+
+#define KSEG1ADDR(_x) (((_x) & 0x1fffffff) | 0xa0000000)
+
+#define UART_BASE 0xBE000C00
+
+#define UART_TBR_OFFSET 0x00
+#define UART_LSR_OFFSET 0x14
+
+#define UART_LSR_TEMT (1 << 6)
+
+#define UART_READ(r) READREG(UART_BASE + (r))
+#define UART_WRITE(r,v) WRITEREG(UART_BASE + (r), (v))
+
+void board_putc(int ch)
+{
+ while (((UART_READ(UART_LSR_OFFSET)) & UART_LSR_TEMT) == 0);
+ UART_WRITE(UART_TBR_OFFSET, ch);
+ while (((UART_READ(UART_LSR_OFFSET)) & UART_LSR_TEMT) == 0);
+}
+
+void board_init(void)
+{
+}
diff --git a/target/linux/ramips/image/lzma-loader/src/loader.c b/target/linux/ramips/image/lzma-loader/src/loader.c
index 1d42bfa2f7..c73b60b351 100644
--- a/target/linux/ramips/image/lzma-loader/src/loader.c
+++ b/target/linux/ramips/image/lzma-loader/src/loader.c
@@ -21,6 +21,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <sys/types.h>
#include "config.h"
#include "cache.h"
@@ -73,9 +74,10 @@ static unsigned long lzma_outsize;
static unsigned long kernel_la;
#ifdef CONFIG_KERNEL_CMDLINE
-#define kernel_argc 1
+#define kernel_argc 2
static const char kernel_cmdline[] = CONFIG_KERNEL_CMDLINE;
static const char *kernel_argv[] = {
+ NULL,
kernel_cmdline,
NULL,
};
diff --git a/target/linux/ramips/image/lzma-loader/src/mt7621.mk b/target/linux/ramips/image/lzma-loader/src/mt7621.mk
new file mode 100644
index 0000000000..3ff5fddf98
--- /dev/null
+++ b/target/linux/ramips/image/lzma-loader/src/mt7621.mk
@@ -0,0 +1 @@
+CACHE_FLAGS+=-DCONFIG_ICACHE_SIZE="(32 * 1024)" -DCONFIG_DCACHE_SIZE="(16 * 1024)" -DCONFIG_CACHELINE_SIZE=32