2011-12-05 14:52:25 +00:00
|
|
|
#
|
|
|
|
# Makefile for the LZMA compressed kernel loader for
|
|
|
|
# Atheros AR7XXX/AR9XXX based boards
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
|
|
|
|
#
|
|
|
|
# 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 :=
|
|
|
|
LZMA_TEXT_START := 0x80a00000
|
|
|
|
LOADER_DATA :=
|
2012-08-02 09:54:33 +00:00
|
|
|
BOARD :=
|
2011-12-05 14:52:25 +00:00
|
|
|
FLASH_OFFS :=
|
|
|
|
FLASH_MAX :=
|
|
|
|
|
|
|
|
CC := $(CROSS_COMPILE)gcc
|
|
|
|
LD := $(CROSS_COMPILE)ld
|
|
|
|
OBJCOPY := $(CROSS_COMPILE)objcopy
|
|
|
|
OBJDUMP := $(CROSS_COMPILE)objdump
|
|
|
|
|
2015-09-12 18:57:37 +00:00
|
|
|
BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug \
|
|
|
|
-R .MIPS.abiflags -S
|
2011-12-05 14:52:25 +00:00
|
|
|
|
|
|
|
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 \
|
2017-12-13 10:12:11 +00:00
|
|
|
-fno-common -ffreestanding -fhonour-copts -nostartfiles \
|
2011-12-05 14:52:25 +00:00
|
|
|
-mabi=32 -march=mips32r2 \
|
|
|
|
-Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap
|
|
|
|
CFLAGS += -D_LZMA_PROB32
|
2017-07-19 13:45:08 +00:00
|
|
|
CFLAGS += -flto
|
2011-12-05 14:52:25 +00:00
|
|
|
|
|
|
|
ASFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
|
|
|
|
2017-07-19 13:45:08 +00:00
|
|
|
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
|
2011-12-05 14:52:25 +00:00
|
|
|
|
|
|
|
O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
|
|
|
|
|
|
|
|
OBJECTS := head.o loader.o cache.o board.o printf.o LzmaDecode.o
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2012-08-02 09:54:33 +00:00
|
|
|
BOARD_DEF := $(shell echo $(strip $(BOARD)) | tr a-z A-Z | tr - _)
|
|
|
|
ifneq ($(BOARD_DEF),)
|
|
|
|
CFLAGS += -DCONFIG_BOARD_$(BOARD_DEF)
|
|
|
|
endif
|
|
|
|
|
2012-11-20 12:17:41 +00:00
|
|
|
all: loader.elf
|
2011-12-05 14:52:25 +00:00
|
|
|
|
|
|
|
# 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 $@ $<
|
|
|
|
|
2012-11-20 12:17:41 +00:00
|
|
|
loader: $(OBJECTS)
|
2017-07-19 13:45:08 +00:00
|
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS)
|
2012-11-20 12:17:41 +00:00
|
|
|
|
|
|
|
loader.bin: loader
|
2011-12-05 14:52:25 +00:00
|
|
|
$(OBJCOPY) $(BIN_FLAGS) $< $@
|
|
|
|
|
2012-11-20 12:17:41 +00:00
|
|
|
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 $@ $<
|
2011-12-05 14:52:25 +00:00
|
|
|
|
|
|
|
mrproper: clean
|
|
|
|
|
|
|
|
clean:
|
2012-11-20 12:17:41 +00:00
|
|
|
rm -f loader *.elf *.bin *.o
|
2011-12-05 14:52:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|