diff options
author | Tobias Schramm <tobleminer@gmail.com> | 2018-05-03 16:27:10 +0200 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2018-06-21 06:55:10 +0200 |
commit | 5529e713578217fc9fac706783b8c61f3c649274 (patch) | |
tree | 9cd31545b9c1a22ced30f0d8bd2a4f897a0b8ff4 | |
parent | 615186d415054836363644d0cf2c437dd47a7abe (diff) | |
download | mtk-20170518-5529e713578217fc9fac706783b8c61f3c649274.zip mtk-20170518-5529e713578217fc9fac706783b8c61f3c649274.tar.gz mtk-20170518-5529e713578217fc9fac706783b8c61f3c649274.tar.bz2 |
ramips: Add support for mt7621 to lzma-loader
Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
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 7833016..f22151c 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 f861666..d20cd77 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 0000000..b90b2ed --- /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 1d42bfa..c73b60b 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 0000000..3ff5fdd --- /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 |