Makefile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. ### Image scripts ###
  13. define Build/kernel-img
  14. perl $(LINUX_DIR)/scripts/mkknlimg $@ $@.tmp
  15. mv $@.tmp $@
  16. endef
  17. define Build/boot-img
  18. rm -f $@.boot
  19. mkfs.fat -C $@.boot $(FAT32_BLOCKS)
  20. mcopy -i $@.boot $(LINUX_DIR)/COPYING ::COPYING.linux
  21. mcopy -i $@.boot $(KDIR)/bootcode.bin ::
  22. mcopy -i $@.boot $(KDIR)/LICENCE.broadcom ::
  23. mcopy -i $@.boot $(KDIR)/start.elf ::
  24. mcopy -i $@.boot $(KDIR)/start_cd.elf ::
  25. mcopy -i $@.boot $(KDIR)/fixup.dat ::
  26. mcopy -i $@.boot $(KDIR)/fixup_cd.dat ::
  27. mcopy -i $@.boot cmdline.txt ::
  28. mcopy -i $@.boot config.txt ::
  29. mcopy -i $@.boot $(word 1,$^) ::kernel.img
  30. $(foreach dts,$(shell echo $(DEVICE_DTS)),mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::;)
  31. mmd -i $@.boot ::/overlays
  32. mcopy -i $@.boot $(DTS_DIR)/overlays/*.dtbo ::/overlays/
  33. mcopy -i $@.boot $(DTS_DIR)/overlays/README ::/overlays/
  34. endef
  35. define Build/sdcard-img
  36. ./gen_rpi_sdcard_img.sh $@ $@.boot $(word 2,$^) \
  37. $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  38. $(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
  39. endef
  40. ### Device macros ###
  41. define Device/Default
  42. FILESYSTEMS := ext4
  43. PROFILES = Default $$(DEVICE_PROFILE)
  44. KERNEL := kernel-bin | kernel-img
  45. IMAGES := sdcard.img
  46. IMAGE/sdcard.img := boot-img | sdcard-img
  47. DEVICE_PROFILE :=
  48. DEVICE_DTS :=
  49. endef
  50. DEVICE_VARS += DEVICE_PROFILE DEVICE_DTS
  51. # $(1) = profile
  52. # $(2) = image name
  53. # $(3) = dts
  54. define bcm27xx
  55. define Device/$(2)
  56. DEVICE_PROFILE := $(1)
  57. DEVICE_DTS := $(3)
  58. endef
  59. TARGET_DEVICES += $(2)
  60. endef
  61. ### BCM2708/BCM2835 ###
  62. ifeq ($(SUBTARGET),bcm2708)
  63. # Raspberry Pi Models B/B+/CM
  64. $(eval $(call bcm27xx,RaspberryPi,rpi,bcm2708-rpi-b bcm2708-rpi-b-plus bcm2708-rpi-cm))
  65. endif
  66. ### BCM2709/BCM2836 ###
  67. ifeq ($(SUBTARGET),bcm2709)
  68. # Raspberry Pi 2 Model B
  69. $(eval $(call bcm27xx,RaspberryPi_2,rpi-2,bcm2709-rpi-2-b))
  70. endif
  71. ### BCM2710/BCM2837 ###
  72. ifeq ($(SUBTARGET),bcm2710)
  73. # Raspberry Pi 3 Model B
  74. $(eval $(call bcm27xx,RaspberryPi_3,rpi-3,bcm2710-rpi-3-b))
  75. endif
  76. $(eval $(call BuildImage))