summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/image/lzma-loader/src/Makefile
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2013-08-16 11:44:04 +0300
committerRoman Yeryomin <roman@advem.lv>2013-08-16 11:44:04 +0300
commitdee99ab0143122146ab7713cfe171790bc796dd3 (patch)
tree907ad856f6ceae17a70dd1df004a1adee8a1b2fd /target/linux/realtek/image/lzma-loader/src/Makefile
parent4ed5985ada0f0420d69d7d959ecc3c9c8515efa0 (diff)
Get rid of rtkload. Use OpenWrt lzma-loader (with kernel_entry hack). Use mgbin for unified tftp image generation.
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'target/linux/realtek/image/lzma-loader/src/Makefile')
-rw-r--r--target/linux/realtek/image/lzma-loader/src/Makefile117
1 files changed, 117 insertions, 0 deletions
diff --git a/target/linux/realtek/image/lzma-loader/src/Makefile b/target/linux/realtek/image/lzma-loader/src/Makefile
new file mode 100644
index 000000000..3355d7b20
--- /dev/null
+++ b/target/linux/realtek/image/lzma-loader/src/Makefile
@@ -0,0 +1,117 @@
+#
+# Makefile for the LZMA compressed kernel loader for
+# Realtek rtl819xx based boards
+#
+# Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
+# Copyright (C) 2013 Roman Yeryomin <roman@advem.lv>
+#
+# Some parts of this file was based on the OpenWrt specific lzma-loader
+# for the BCM47xx and ADM5120 based boards:
+# Copyright (C) 2004 Manuel Novoa III (mjn3@codepoet.org)
+# Copyright (C) 2005 Mineharu Takahara <mtakahar@yahoo.com>
+# Copyright (C) 2005 by Oleg I. Vdovikin <oleg@cs.msu.su>
+#
+# 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.
+#
+
+LOADADDR :=
+KERNELENTRY :=
+LZMA_TEXT_START := 0x80a00000
+LOADER_DATA :=
+BOARD :=
+FLASH_OFFS :=
+FLASH_MAX :=
+
+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
+
+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 -mabi=32 -Wa,-32
+CFLAGS += -D_LZMA_PROB32
+CFLAGS += -I$(LINUX_DIR)/arch/rlx/include
+CFLAGS += -I$(LINUX_DIR)/include/linux
+CFLAGS += -I$(LINUX_DIR)/arch/rlx/bsp
+CFLAGS += -I$(LINUX_DIR)/include
+CFLAGS += -I$(LINUX_DIR)/arch/rlx/include/asm/mach-generic
+
+ASFLAGS = $(CFLAGS) -D__ASSEMBLY__
+
+LDFLAGS = -static --gc-sections -no-warn-mismatch
+LDFLAGS += -e startup -T loader.lds -Ttext $(LZMA_TEXT_START)
+
+O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
+
+OBJECTS := head.o loader.o cache.o board.o printf.o LzmaDecode.o
+
+# Realtek chips have different march'es, e.g. rlx4181 and rlx5281
+ifneq ($(strip $(MARCH)),)
+CFLAGS += -Wa,-march=$(MARCH) -march=$(MARCH)
+else
+CFLAGS += -Wa,-march=rlx4181 -march=rlx4181
+endif
+
+# hacky way to get/define real kernel_entry address
+# see image/Makefile and loader.c for details
+ifneq ($(strip $(KERNELENTRY)),)
+CFLAGS += -DKERNELENTRY=$(KERNELENTRY)
+endif
+
+ifneq ($(strip $(LOADER_DATA)),)
+OBJECTS += data.o
+CFLAGS += -DLZMA_WRAPPER=1 -DLOADADDR=$(LOADADDR)
+endif
+
+ifneq ($(strip $(KERNEL_CMDLINE)),)
+CFLAGS += -DCONFIG_KERNEL_CMDLINE='"$(KERNEL_CMDLINE)"'
+endif
+
+ifneq ($(strip $(FLASH_OFFS)),)
+CFLAGS += -DCONFIG_FLASH_OFFS=$(FLASH_OFFS)
+endif
+
+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.bin
+
+# Don't build dependencies, this may die if $(CC) isn't gcc
+dep:
+
+install:
+
+%.o : %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.o : %.S
+ $(CC) $(ASFLAGS) -c -o $@ $<
+
+data.o: $(LOADER_DATA)
+ $(LD) -r -b binary --oformat $(O_FORMAT) -T lzma-data.lds -o $@ $<
+
+loader.bin: loader.elf
+ $(OBJCOPY) $(BIN_FLAGS) $< $@
+
+loader.elf: $(OBJECTS)
+ $(LD) $(LDFLAGS) -o $@ $(OBJECTS)
+
+mrproper: clean
+
+clean:
+ rm -f *.elf *.bin *.o
+
+
+