|
| 1 | +# |
| 2 | +# (C) Copyright 2000-2011 |
| 3 | +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | +# |
| 5 | +# (C) Copyright 2011 |
| 6 | +# Daniel Schwierzeck, daniel.schwierzeck@googlemail.com. |
| 7 | +# |
| 8 | +# (C) Copyright 2011 |
| 9 | +# Texas Instruments Incorporated - http://www.ti.com/ |
| 10 | +# Aneesh V <aneesh@ti.com> |
| 11 | +# |
| 12 | +# This file is released under the terms of GPL v2 and any later version. |
| 13 | +# See the file COPYING in the root directory of the source tree for details. |
| 14 | +# |
| 15 | +# Based on top-level Makefile. |
| 16 | +# |
| 17 | + |
| 18 | +include $(SPLDIR)/config.mk |
| 19 | +include $(TOPDIR)/include/autoconf.mk |
| 20 | +include $(TOPDIR)/include/autoconf.mk.dep |
| 21 | + |
| 22 | +CONFIG_SPL := y |
| 23 | +export CONFIG_SPL |
| 24 | + |
| 25 | +TOOLS_DIR := $(TOPDIR)/tools |
| 26 | + |
| 27 | +BOOT0_LDSCRIPT := $(SPLBASE)/sunxi_spl/boot0/main/boot0.lds |
| 28 | + |
| 29 | +# We want the final binaries in this directory |
| 30 | +obj := $(SPLBASE)/sunxi_spl/boot0/ |
| 31 | + |
| 32 | +BOOT0_HEAD := sunxi_spl/boot0/boot0_head.o |
| 33 | +START := sunxi_spl/boot0/boot0_entry.o |
| 34 | + |
| 35 | +LIBS-y += sunxi_spl/boot0/spl/libsource_spl.o |
| 36 | +LIBS-y += sunxi_spl/boot0/main/libmain.o |
| 37 | +LIBS-y += sunxi_spl/boot0/libs/libgeneric.o |
| 38 | +LIBS-y += sunxi_spl/spl/lib/libgeneric.o |
| 39 | +LIBS-y += sunxi_spl/dram/$(SOC)/dram/libdram.o |
| 40 | +LIBS-$(CONFIG_SUNXI_HDMI_IN_BOOT0) += sunxi_spl/display/hdmi/libdisplay.o |
| 41 | + |
| 42 | +LIBS-$(CONFIG_SUNXI_CHIPID) += sunxi_spl/dram/$(SOC)/dram/libchipid.o |
| 43 | +LIBS := $(addprefix $(SPLBASE)/,$(sort $(LIBS-y))) |
| 44 | + |
| 45 | +LIBNAND-$(CONFIG_STORAGE_MEDIA_NAND) += $(SPLBASE)/sunxi_spl/boot0/load_nand/libloadnand.o |
| 46 | +LIBNAND-$(CONFIG_STORAGE_MEDIA_NAND) += $(TOPDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/nand/libnand.o |
| 47 | +LIBNAND-$(CONFIG_STORAGE_MEDIA_SPINAND) += $(TOPDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/spinand/libspinand.o |
| 48 | + |
| 49 | +LIBNAND := $(LIBNAND-y) |
| 50 | + |
| 51 | +LIBMMC-$(CONFIG_STORAGE_MEDIA_MMC) += $(SPLBASE)/sunxi_spl/boot0/load_mmc/libloadmmc.o |
| 52 | +LIBMMC-$(CONFIG_STORAGE_MEDIA_MMC) += $(TOPDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/mmc/libmmc.o |
| 53 | + |
| 54 | +LIBMMC := $(LIBMMC-y) |
| 55 | + |
| 56 | + |
| 57 | +LIBSPINOR-$(CONFIG_STORAGE_MEDIA_SPINOR) += $(SPLBASE)/sunxi_spl/boot0/load_spinor/libloadspinor.o |
| 58 | +LIBSPINOR-$(CONFIG_STORAGE_MEDIA_SPINOR) += $(TOPDIR)/arch/$(ARCH)/cpu/$(CPU)/$(SOC)/spinor/libspinor.o |
| 59 | + |
| 60 | +LIBSPINOR := $(LIBSPINOR-y) |
| 61 | + |
| 62 | +ifndef CONFIG_BOOT0_SIZE_LIMIT |
| 63 | + BOOT0SIZE = $(CONFIG_SYS_INIT_RAM_SIZE) |
| 64 | +else |
| 65 | + BOOT0SIZE = $(CONFIG_BOOT0_SIZE_LIMIT) |
| 66 | +endif |
| 67 | + |
| 68 | +__LIBS := $(subst $(obj),,$(LIBS)) |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +# Special flags for CPP when processing the linker script. |
| 73 | +# Pass the version down so we can handle backwards compatibility |
| 74 | +# on the fly. |
| 75 | +LDPPFLAGS += \ |
| 76 | + -include $(TOPDIR)/include/u-boot/u-boot.lds.h \ |
| 77 | + -DBOOT0ADDR=$(CONFIG_BOOT0_RUN_ADDR) \ |
| 78 | + -DBOOT0SIZE=$(BOOT0SIZE) \ |
| 79 | + $(shell $(LD) --version | \ |
| 80 | + sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') |
| 81 | + |
| 82 | +ALL-$(CONFIG_STORAGE_MEDIA_NAND) += $(obj)boot0_nand.bin |
| 83 | +ALL-$(CONFIG_STORAGE_MEDIA_MMC) += $(obj)boot0_sdcard.bin |
| 84 | +ALL-$(CONFIG_STORAGE_MEDIA_SPINOR) += $(obj)boot0_spinor.bin |
| 85 | + |
| 86 | + |
| 87 | +all: $(ALL-y) |
| 88 | + |
| 89 | +$(obj)boot0_nand.bin: $(obj)boot0_nand.axf $(obj)cur.log |
| 90 | + @echo bootaddr is $(CONFIG_BOOT0_RUN_ADDR) |
| 91 | + $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@ |
| 92 | + @$(SPLDIR)/../../tools/add_hash.sh -f $(SPLDIR)/boot0/boot0_nand.bin -m boot0 |
| 93 | + |
| 94 | +$(obj)boot0_nand.axf: $(LIBS) $(LIBNAND) $(obj)boot0.lds |
| 95 | + $(LD) $(LIBS) $(LIBNAND) $(PLATFORM_LIBGCC) $(LDFLAGS) $(LDFLAGS_boot0) -T$(obj)boot0.lds -o boot0_nand.axf -Map boot0_nand.map |
| 96 | + |
| 97 | +$(obj)boot0_sdcard.bin: $(obj)boot0_sdcard.axf $(obj)cur.log |
| 98 | + $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@ |
| 99 | + @$(SPLDIR)/../../tools/add_hash.sh -f $(SPLDIR)/boot0/boot0_sdcard.bin -m boot0 |
| 100 | + |
| 101 | +$(obj)boot0_sdcard.axf: $(LIBS) $(LIBMMC) $(obj)boot0.lds |
| 102 | + $(LD) $(LIBS) $(LIBMMC) $(PLATFORM_LIBGCC) $(LDFLAGS) $(LDFLAGS_boot0) -T$(obj)boot0.lds -o boot0_sdcard.axf -Map boot0_sdcard.map |
| 103 | + |
| 104 | +$(obj)boot0_spinor.bin: $(obj)boot0_spinor.axf $(obj)cur.log |
| 105 | + $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@ |
| 106 | + @$(SPLDIR)/../../tools/add_hash.sh -f $(SPLDIR)/boot0/boot0_spinor.bin -m boot0 |
| 107 | + |
| 108 | +$(obj)boot0_spinor.axf: $(LIBS) $(LIBSPINOR) $(obj)boot0.lds |
| 109 | + $(LD) $(LIBS) $(LIBSPINOR) $(PLATFORM_LIBGCC) $(LDFLAGS) $(LDFLAGS_boot0) -T$(obj)boot0.lds -o boot0_spinor.axf -Map boot0_spinor.map |
| 110 | + |
| 111 | +$(LIBS): depend |
| 112 | + $(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@)) |
| 113 | + |
| 114 | +$(LIBNAND): depend |
| 115 | + $(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@)) |
| 116 | + |
| 117 | +$(LIBMMC): depend |
| 118 | + $(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@)) |
| 119 | + |
| 120 | +$(LIBSPINOR): depend |
| 121 | + $(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@)) |
| 122 | + |
| 123 | +$(obj)boot0.lds: $(BOOT0_LDSCRIPT) |
| 124 | + @$(CPP) $(ALL_CFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ |
| 125 | + |
| 126 | +$(obj)cur.log: |
| 127 | + @git show HEAD --pretty=format:"%H" | head -n 1 > cur.log |
| 128 | + |
| 129 | +depend: .depend |
| 130 | +######################################################################### |
| 131 | + |
| 132 | +# defines $(obj).depend target |
| 133 | +include $(SRCTREE)/rules.mk |
| 134 | + |
| 135 | +sinclude .depend |
| 136 | + |
| 137 | +######################################################################### |
0 commit comments