| 1 | # |
| 2 | # Authors: Wolfgang Spraul <wolfgang@sharism.cc> |
| 3 | # |
| 4 | # This program is free software; you can redistribute it and/or |
| 5 | # modify it under the terms of the GNU General Public License |
| 6 | # as published by the Free Software Foundation; either version |
| 7 | # 3 of the License, or (at your option) any later version. |
| 8 | # |
| 9 | |
| 10 | ifeq ($(CROSS_COMPILE),) |
| 11 | $(error CROSS_COMPILE variable not set, should point to .../mipsel-openwrt-linux-) |
| 12 | endif |
| 13 | |
| 14 | CC = $(CROSS_COMPILE)gcc |
| 15 | AR = $(CROSS_COMPILE)ar rcsv |
| 16 | LD = $(CROSS_COMPILE)ld |
| 17 | OBJCOPY = $(CROSS_COMPILE)objcopy |
| 18 | NM = $(CROSS_COMPILE)nm |
| 19 | OBJDUMP = $(CROSS_COMPILE)objdump |
| 20 | |
| 21 | DEBUG_CFLAGS = -g -Wa,-a=$(basename $@).lst |
| 22 | # Wolfgang saw data corruptions in stage2 when dealing with ECC data on random writes |
| 23 | # to NAND. Disabling the unit-at-a-time optimization reproducibly fixed the bug. |
| 24 | # The compiler may be optimizing in a way that conflicts with how the hardware ECC |
| 25 | # registers work. Since other register accesses might be affected too it seems the best |
| 26 | # is to disable this optimization right now. |
| 27 | CFLAGS = -mips32 -O2 -fno-exceptions -fno-unit-at-a-time -fno-zero-initialized-in-bss \ |
| 28 | -ffunction-sections -fomit-frame-pointer -msoft-float -G 0 $(DEBUG_CFLAGS) -fPIC |
| 29 | LDFLAGS = -nostdlib -T target.ld $(CFLAGS) |
| 30 | LIBS = -lstdc++ -lc -lm -lgcc |
| 31 | VPATH = ../target-common |
| 32 | |
| 33 | OBJS = echo-kernel.o serial.o |
| 34 | |
| 35 | all: echo-kernel.elf |
| 36 | $(OBJCOPY) -O binary echo-kernel.elf echo-kernel.bin |
| 37 | $(OBJDUMP) -D echo-kernel.elf > echo-kernel.dump |
| 38 | $(NM) echo-kernel.elf | sort > echo-kernel.sym |
| 39 | $(OBJDUMP) -h echo-kernel.elf > echo-kernel.map |
| 40 | |
| 41 | echo-kernel.elf: head.o $(OBJS) |
| 42 | $(CC) $(LDFLAGS) $^ -o $@ |
| 43 | |
| 44 | .c.o: |
| 45 | $(CC) $(CFLAGS) -o $@ -c $< |
| 46 | .cpp.o: |
| 47 | $(CC) $(CFLAGS) -fno-rtti -fvtable-gc -o $@ -c $< |
| 48 | .S.o: |
| 49 | $(CC) $(CFLAGS) -o $@ -c $< |
| 50 | |
| 51 | clean: |
| 52 | rm -f $(addprefix echo-kernel., bin dump elf map sym) |
| 53 | rm -f head.o head.lst $(OBJS) $(OBJS:.o=.lst) |
| 54 | |