0
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-11-24 14:06:15 +00:00
openwrt/target/linux/mpc85xx/image/spi-loader/Makefile
Matthias Schiffer a296055b82 mpc85xx: add SPI kernel loader for TP-Link TL-WDR4900 v1
Similar to the lzma-loader on our MIPS targets, the spi-loader acts as
a second-stage loader that will then load and start the actual kernel.
As the TL-WDR4900 uses SPI-NOR and the P1010 family does not have support
for memory mapping of this type of flash, this loader needs to contain a
basic driver for the FSL ESPI controller.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2022-10-14 23:13:02 +02:00

61 lines
1.6 KiB
Makefile

# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (C) 2022 Matthias Schiffer <mschiffer@universe-factory.net>
CONFIG ?= $(error No configuration set)
include config/$(CONFIG).mk
MKIMAGE := mkimage
KARCH := powerpc
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
OBJCOPY := $(CROSS_COMPILE)objcopy
PROGRAM_NAME := MPC85xx SPI loader
BIN_FLAGS := -O binary --pad-to=$(PAD_TO)
CFLAGS += -std=gnu17 -Os -Wall -Wstrict-prototypes \
-fomit-frame-pointer -ffreestanding \
-ffunction-sections -fno-pic \
-Iinclude -include ../config/$(CONFIG).h \
-DCONFIG_PROGRAM_NAME='"$(PROGRAM_NAME)"' \
-DCONFIG_IMAGE_OFFSET=$(IMAGE_OFFSET)
ASFLAGS := $(CFLAGS)
LDS := loader.lds
LDFLAGS := -static --gc-sections -T $(LDS) -Ttext $(TEXT_START)
OBJECTS := head.o loader.o string.o stdio.o drivers/serial/ns16550.o \
drivers/spi/fsl_espi.o drivers/spi/spi-nor.o
OUTDIR := out
all: $(OUTDIR)/uImage
-include $(OBJECTS:%.o=$(OUTDIR)/%.d)
$(OUTDIR)/%.o: %.c Makefile config/$(CONFIG).mk
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ -MD -MP $<
$(OUTDIR)/%.o: %.S Makefile config/$(CONFIG).mk
@mkdir -p $(dir $@)
$(CC) $(ASFLAGS) -c -o $@ -MD -MP $<
$(OUTDIR)/loader.elf: $(OBJECTS:%=$(OUTDIR)/%) $(LDS)
$(LD) $(LDFLAGS) -o $@ $(OBJECTS:%=$(OUTDIR)/%)
$(OUTDIR)/loader.bin: $(OUTDIR)/loader.elf
$(OBJCOPY) $(BIN_FLAGS) $< $@
$(OUTDIR)/uImage: $(OUTDIR)/loader.bin
$(MKIMAGE) -A $(KARCH) -O linux -T kernel -C none \
-a $(TEXT_START) -e $(TEXT_START) -n '$(PROGRAM_NAME)' -d $< $@
clean:
rm -rf $(OUTDIR)
.PHONY: all clean