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)
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
$(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) $< $@
$(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
--- /dev/null
+/*
+ * 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)
+{
+}