Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

238 lines
7.1 KiB

  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. # SPDX-License-Identifier: GPL-2.0+
  13. #
  14. # Based on top-level Makefile.
  15. #
  16. src := $(obj)
  17. # Create output directory if not already present
  18. _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
  19. include $(srctree)/scripts/Kbuild.include
  20. -include include/config/auto.conf
  21. -include $(obj)/include/autoconf.mk
  22. KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
  23. ifeq ($(CONFIG_TPL_BUILD),y)
  24. KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
  25. endif
  26. ifeq ($(CONFIG_TPL_BUILD),y)
  27. SPL_BIN := u-boot-tpl
  28. else
  29. SPL_BIN := u-boot-spl
  30. endif
  31. include $(srctree)/config.mk
  32. include $(srctree)/arch/$(ARCH)/Makefile
  33. # Enable garbage collection of un-used sections for SPL
  34. KBUILD_CFLAGS += -ffunction-sections -fdata-sections
  35. LDFLAGS_FINAL += --gc-sections
  36. # FIX ME
  37. cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
  38. $(NOSTDINC_FLAGS)
  39. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
  40. libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
  41. libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
  42. libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
  43. libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/
  44. libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
  45. libs-$(CONFIG_SPL_DM) += drivers/core/
  46. libs-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/
  47. libs-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/
  48. libs-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/
  49. libs-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/
  50. libs-$(CONFIG_SYS_MVEBU_DDR) += drivers/ddr/mvebu/
  51. libs-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/
  52. libs-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/
  53. libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/
  54. libs-y += fs/
  55. libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
  56. libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ drivers/power/pmic/
  57. libs-$(CONFIG_SPL_MTD_SUPPORT) += drivers/mtd/
  58. libs-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/
  59. libs-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/
  60. libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/
  61. libs-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/
  62. libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
  63. libs-$(CONFIG_SPL_NET_SUPPORT) += net/
  64. libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/
  65. libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/
  66. libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/
  67. libs-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/
  68. libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
  69. libs-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
  70. libs-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
  71. libs-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
  72. libs-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/
  73. head-y := $(addprefix $(obj)/,$(head-y))
  74. libs-y := $(addprefix $(obj)/,$(libs-y))
  75. u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y)))
  76. libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
  77. # Add GCC lib
  78. ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
  79. PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
  80. PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
  81. endif
  82. u-boot-spl-init := $(head-y)
  83. u-boot-spl-main := $(libs-y)
  84. # Linker Script
  85. ifdef CONFIG_SPL_LDSCRIPT
  86. # need to strip off double quotes
  87. LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
  88. endif
  89. ifeq ($(wildcard $(LDSCRIPT)),)
  90. LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot-spl.lds
  91. endif
  92. ifeq ($(wildcard $(LDSCRIPT)),)
  93. LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot-spl.lds
  94. endif
  95. ifeq ($(wildcard $(LDSCRIPT)),)
  96. LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot-spl.lds
  97. endif
  98. ifeq ($(wildcard $(LDSCRIPT)),)
  99. $(error could not find linker script)
  100. endif
  101. # Special flags for CPP when processing the linker script.
  102. # Pass the version down so we can handle backwards compatibility
  103. # on the fly.
  104. LDPPFLAGS += \
  105. -include $(srctree)/include/u-boot/u-boot.lds.h \
  106. -include $(objtree)/include/config.h \
  107. -DCPUDIR=$(CPUDIR) \
  108. $(shell $(LD) --version | \
  109. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  110. quiet_cmd_mkimage = MKIMAGE $@
  111. cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
  112. $(if $(KBUILD_VERBOSE:1=), >/dev/null)
  113. MKIMAGEFLAGS_MLO = -T omapimage -a $(CONFIG_SPL_TEXT_BASE)
  114. MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
  115. MLO MLO.byteswap: $(obj)/u-boot-spl.bin
  116. $(call if_changed,mkimage)
  117. MKIMAGEFLAGS_boot.bin = -T atmelimage
  118. ifeq ($(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER),y)
  119. MKIMAGEFLAGS_boot.bin += -n $(shell $(obj)/../tools/atmel_pmecc_params)
  120. boot.bin: $(obj)/../tools/atmel_pmecc_params
  121. endif
  122. boot.bin: $(obj)/u-boot-spl.bin
  123. $(call if_changed,mkimage)
  124. ALL-y += $(obj)/$(SPL_BIN).bin
  125. ifdef CONFIG_SAMSUNG
  126. ALL-y += $(obj)/$(BOARD)-spl.bin
  127. endif
  128. ifdef CONFIG_SUNXI
  129. ALL-y += $(obj)/sunxi-spl.bin
  130. endif
  131. ifeq ($(CONFIG_SYS_SOC),"at91")
  132. ALL-y += boot.bin
  133. endif
  134. all: $(ALL-y)
  135. ifdef CONFIG_SAMSUNG
  136. ifdef CONFIG_VAR_SIZE_SPL
  137. VAR_SIZE_PARAM = --vs
  138. else
  139. VAR_SIZE_PARAM =
  140. endif
  141. $(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin
  142. $(if $(wildcard $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
  143. $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
  144. $(objtree)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
  145. endif
  146. quiet_cmd_objcopy = OBJCOPY $@
  147. cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
  148. OBJCOPYFLAGS_$(SPL_BIN).bin = $(SPL_OBJCFLAGS) -O binary
  149. $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN) FORCE
  150. $(call if_changed,objcopy)
  151. LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
  152. ifneq ($(CONFIG_SPL_TEXT_BASE),)
  153. LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
  154. endif
  155. ifdef CONFIG_SUNXI
  156. quiet_cmd_mksunxiboot = MKSUNXI $@
  157. cmd_mksunxiboot = $(objtree)/tools/mksunxiboot $< $@
  158. $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin
  159. $(call if_changed,mksunxiboot)
  160. endif
  161. quiet_cmd_u-boot-spl = LD $@
  162. cmd_u-boot-spl = (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
  163. $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
  164. $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
  165. $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN))
  166. $(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE
  167. $(call if_changed,u-boot-spl)
  168. $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
  169. PHONY += $(u-boot-spl-dirs)
  170. $(u-boot-spl-dirs):
  171. $(Q)$(MAKE) $(build)=$@
  172. quiet_cmd_cpp_lds = LDS $@
  173. cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
  174. -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
  175. $(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
  176. $(call if_changed_dep,cpp_lds)
  177. # read all saved command lines
  178. targets := $(wildcard $(sort $(targets)))
  179. cmd_files := $(wildcard $(obj)/.*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
  180. ifneq ($(cmd_files),)
  181. $(cmd_files): ; # Do not try to update included dependency files
  182. include $(cmd_files)
  183. endif
  184. PHONY += FORCE
  185. FORCE:
  186. # Declare the contents of the .PHONY variable as phony. We keep that
  187. # information in a variable so we can use it in if_changed and friends.
  188. .PHONY: $(PHONY)