2
1

uboot.mk 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #############################################################
  2. #
  3. # U-Boot
  4. #
  5. #############################################################
  6. UBOOT_VERSION = $(call qstrip,$(BR2_TARGET_UBOOT_VERSION))
  7. UBOOT_BOARD_NAME = $(call qstrip,$(BR2_TARGET_UBOOT_BOARDNAME))
  8. UBOOT_INSTALL_IMAGES = YES
  9. ifeq ($(UBOOT_VERSION),custom)
  10. # Handle custom U-Boot tarballs as specified by the configuration
  11. UBOOT_TARBALL = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION))
  12. UBOOT_SITE = $(dir $(UBOOT_TARBALL))
  13. UBOOT_SOURCE = $(notdir $(UBOOT_TARBALL))
  14. else ifeq ($(BR2_TARGET_UBOOT_CUSTOM_GIT),y)
  15. UBOOT_SITE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_GIT_REPO_URL))
  16. UBOOT_SITE_METHOD = git
  17. else
  18. # Handle stable official U-Boot versions
  19. UBOOT_SITE = ftp://ftp.denx.de/pub/u-boot
  20. UBOOT_SOURCE = u-boot-$(UBOOT_VERSION).tar.bz2
  21. endif
  22. ifeq ($(BR2_TARGET_UBOOT_FORMAT_KWB),y)
  23. UBOOT_BIN = u-boot.kwb
  24. UBOOT_MAKE_TARGET = $(UBOOT_BIN)
  25. else ifeq ($(BR2_TARGET_UBOOT_FORMAT_LDR),y)
  26. UBOOT_BIN = u-boot.ldr
  27. else ifeq ($(BR2_TARGET_UBOOT_FORMAT_NAND_BIN),y)
  28. UBOOT_BIN = u-boot-nand.bin
  29. else
  30. UBOOT_BIN = u-boot.bin
  31. endif
  32. UBOOT_ARCH=$(KERNEL_ARCH)
  33. UBOOT_CONFIGURE_OPTS += CONFIG_NOSOFTFLOAT=1
  34. UBOOT_MAKE_OPTS += \
  35. CROSS_COMPILE="$(CCACHE) $(TARGET_CROSS)" \
  36. ARCH=$(UBOOT_ARCH)
  37. # Helper function to fill the U-Boot config.h file.
  38. # Argument 1: option name
  39. # Argument 2: option value
  40. # If the option value is empty, this function does nothing.
  41. define insert_define
  42. $(if $(call qstrip,$(2)),
  43. @echo "#ifdef $(strip $(1))" >> $(@D)/include/config.h
  44. @echo "#undef $(strip $(1))" >> $(@D)/include/config.h
  45. @echo "#endif" >> $(@D)/include/config.h
  46. @echo '#define $(strip $(1)) $(call qstrip,$(2))' >> $(@D)/include/config.h)
  47. endef
  48. ifneq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_PATCH_DIR)),)
  49. define UBOOT_APPLY_CUSTOM_PATCHES
  50. support/scripts/apply-patches.sh $(@D) $(BR2_TARGET_UBOOT_CUSTOM_PATCH_DIR) \
  51. uboot-$(UBOOT_VERSION)-\*.patch
  52. endef
  53. UBOOT_POST_PATCH_HOOKS += UBOOT_APPLY_CUSTOM_PATCHES
  54. endif
  55. define UBOOT_CONFIGURE_CMDS
  56. $(TARGET_CONFIGURE_OPTS) $(UBOOT_CONFIGURE_OPTS) \
  57. $(MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
  58. $(UBOOT_BOARD_NAME)_config
  59. @echo >> $(@D)/include/config.h
  60. @echo "/* Add a wrapper around the values Buildroot sets. */" >> $(@D)/include/config.h
  61. @echo "#ifndef __BR2_ADDED_CONFIG_H" >> $(@D)/include/config.h
  62. @echo "#define __BR2_ADDED_CONFIG_H" >> $(@D)/include/config.h
  63. $(call insert_define,DATE,$(DATE))
  64. $(call insert_define,CONFIG_LOAD_SCRIPTS,1)
  65. $(call insert_define,CONFIG_IPADDR,$(BR2_TARGET_UBOOT_IPADDR))
  66. $(call insert_define,CONFIG_GATEWAYIP,$(BR2_TARGET_UBOOT_GATEWAY))
  67. $(call insert_define,CONFIG_NETMASK,$(BR2_TARGET_UBOOT_NETMASK))
  68. $(call insert_define,CONFIG_SERVERIP,$(BR2_TARGET_UBOOT_SERVERIP))
  69. $(call insert_define,CONFIG_ETHADDR,$(BR2_TARGET_UBOOT_ETHADDR))
  70. $(call insert_define,CONFIG_ETH1ADDR,$(BR2_TARGET_UBOOT_ETH1ADDR))
  71. @echo "#endif /* __BR2_ADDED_CONFIG_H */" >> $(@D)/include/config.h
  72. endef
  73. define UBOOT_BUILD_CMDS
  74. $(TARGET_CONFIGURE_OPTS) $(UBOOT_CONFIGURE_OPTS) \
  75. $(MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
  76. $(UBOOT_MAKE_TARGET)
  77. endef
  78. define UBOOT_INSTALL_IMAGES_CMDS
  79. cp -dpf $(@D)/$(UBOOT_BIN) $(BINARIES_DIR)/
  80. endef
  81. $(eval $(call GENTARGETS))
  82. ifeq ($(BR2_TARGET_UBOOT),y)
  83. # we NEED a board name unless we're at make source
  84. ifeq ($(filter source,$(MAKECMDGOALS)),)
  85. ifeq ($(UBOOT_BOARD_NAME),)
  86. $(error NO U-Boot board name set. Check your BR2_TARGET_UBOOT_BOARDNAME setting)
  87. endif
  88. endif
  89. endif