Makefile 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #
  2. # Copyright (C) 2012-2015 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/image.mk
  9. include $(INCLUDE_DIR)/host.mk
  10. FAT32_BLOCK_SIZE=1024
  11. FAT32_BLOCKS=$(shell echo $$(($(CONFIG_BRCM2708_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
  12. ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
  13. define Image/gzip
  14. gzip -9n -c $(1) > $(1).gz
  15. mv $(1).gz $(BIN_DIR)
  16. endef
  17. else
  18. define Image/gzip
  19. endef
  20. endif
  21. ### Image scripts ###
  22. define Build/gen-cfg
  23. cat config.txt > [email protected]
  24. echo -e "\ndevice_tree=$(DEVICE_DTS).dtb" >> [email protected]
  25. endef
  26. define Build/boot-img
  27. rm -f [email protected]
  28. mkfs.fat -C [email protected] $(FAT32_BLOCKS)
  29. mcopy -i [email protected] $(KDIR)/bootcode.bin ::
  30. mcopy -i [email protected] $(KDIR)/COPYING.linux ::
  31. mcopy -i [email protected] $(KDIR)/LICENCE.broadcom ::
  32. mcopy -i [email protected] $(KDIR)/start.elf ::
  33. mcopy -i [email protected] $(KDIR)/start_cd.elf ::
  34. mcopy -i [email protected] $(KDIR)/fixup.dat ::
  35. mcopy -i [email protected] $(KDIR)/fixup_cd.dat ::
  36. mcopy -i [email protected] cmdline.txt ::
  37. mcopy -i [email protected] [email protected] ::config.txt
  38. mcopy -i [email protected] $(word 1,$^) ::kernel.img
  39. mcopy -i [email protected] $(DTS_DIR)/$(DEVICE_DTS).dtb ::$(DEVICE_DTS).dtb
  40. mmd -i [email protected] ::/overlays
  41. mcopy -i [email protected] $(DTS_DIR)/overlays/*.dtb ::/overlays/
  42. mcopy -i [email protected] $(DTS_DIR)/overlays/README ::/overlays/
  43. endef
  44. define Build/sdcard-img
  45. ./gen_rpi_sdcard_img.sh $@ [email protected] $(word 2,$^) \
  46. $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  47. $(call Image/gzip,$@)
  48. endef
  49. ### Device macros ###
  50. define Device/Default
  51. FILESYSTEMS := ext4
  52. PROFILES = Default $$(DEVICE_PROFILE)
  53. KERNEL := kernel-bin
  54. IMAGES := sdcard.bin
  55. IMAGE/sdcard.bin := gen-cfg | boot-img | sdcard-img
  56. DEVICE_PROFILE :=
  57. DEVICE_DTS :=
  58. endef
  59. DEVICE_VARS += DEVICE_PROFILE DEVICE_DTS
  60. # $(1) = profile
  61. # $(2) = image name
  62. # $(3) = dts
  63. define add_bcm2708
  64. define Device/$(2)
  65. DEVICE_PROFILE := $(1)
  66. DEVICE_DTS := $(3)
  67. endef
  68. TARGET_DEVICES += $(2)
  69. endef
  70. ### BCM2708/BCM2835 ###
  71. ifeq ($(SUBTARGET),bcm2708)
  72. # Raspberry Pi Model B
  73. $(eval $(call add_bcm2708,RaspberryPi_B,rpi-b,bcm2708-rpi-b))
  74. # Raspberry Pi Model B+
  75. $(eval $(call add_bcm2708,RaspberryPi_BPlus,rpi-b-plus,bcm2708-rpi-b-plus))
  76. # Raspberry Pi Compute Module
  77. $(eval $(call add_bcm2708,RaspberryPi_CM,rpi-cm,bcm2708-rpi-cm))
  78. endif
  79. ### BCM2709/BCM2836 ###
  80. ifeq ($(SUBTARGET),bcm2709)
  81. # Raspberry Pi 2 Model B
  82. $(eval $(call add_bcm2708,RaspberryPi_2,rpi-2-b,bcm2709-rpi-2-b))
  83. endif
  84. $(eval $(call BuildImage))