Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. #
  3. # Copyright (C) 2012-2019 OpenWrt.org
  4. # Copyright (C) 2016-2017 LEDE project
  5. include $(TOPDIR)/rules.mk
  6. include $(INCLUDE_DIR)/image.mk
  7. FAT32_BLOCK_SIZE=1024
  8. FAT32_BLOCKS=$(shell echo $$(($(CONFIG_TARGET_KERNEL_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
  9. define Build/Compile
  10. $(CP) $(LINUX_DIR)/COPYING $(KDIR)/COPYING.linux
  11. endef
  12. ### Image scripts ###
  13. define Build/boot-common
  14. rm -f [email protected]
  15. mkfs.fat -n boot -C [email protected] $(FAT32_BLOCKS)
  16. mcopy -i [email protected] $(KDIR)/COPYING.linux ::
  17. mcopy -i [email protected] $(KDIR)/LICENCE.broadcom ::
  18. mcopy -i [email protected] cmdline.txt ::
  19. mcopy -i [email protected] config.txt ::
  20. mcopy -i [email protected] distroconfig.txt ::
  21. mcopy -i [email protected] $(IMAGE_KERNEL) ::$(KERNEL_IMG)
  22. $(foreach dts,$(shell echo $(DEVICE_DTS)),mcopy -i [email protected] $(DTS_DIR)/$(dts).dtb ::;)
  23. mmd -i [email protected] ::/overlays
  24. mcopy -i [email protected] $(DTS_DIR)/overlays/*.dtbo ::/overlays/
  25. mcopy -i [email protected] $(DTS_DIR)/overlays/README ::/overlays/
  26. endef
  27. define Build/boot-2708
  28. mcopy -i [email protected] $(KDIR)/bootcode.bin ::
  29. mcopy -i [email protected] $(KDIR)/start.elf ::
  30. mcopy -i [email protected] $(KDIR)/start_cd.elf ::
  31. mcopy -i [email protected] $(KDIR)/start_x.elf ::
  32. mcopy -i [email protected] $(KDIR)/fixup.dat ::
  33. mcopy -i [email protected] $(KDIR)/fixup_cd.dat ::
  34. mcopy -i [email protected] $(KDIR)/fixup_x.dat ::
  35. endef
  36. define Build/boot-2711
  37. mcopy -i [email protected] $(KDIR)/start4.elf ::
  38. mcopy -i [email protected] $(KDIR)/start4cd.elf ::
  39. mcopy -i [email protected] $(KDIR)/start4x.elf ::
  40. mcopy -i [email protected] $(KDIR)/fixup4.dat ::
  41. mcopy -i [email protected] $(KDIR)/fixup4cd.dat ::
  42. mcopy -i [email protected] $(KDIR)/fixup4x.dat ::
  43. endef
  44. define Build/sdcard-img
  45. ./gen_rpi_sdcard_img.sh $@ [email protected] $(IMAGE_ROOTFS) \
  46. $(CONFIG_TARGET_KERNEL_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  47. endef
  48. ### Devices ###
  49. define Device/Default
  50. DEVICE_VENDOR := Raspberry Pi
  51. KERNEL := kernel-bin
  52. KERNEL_IMG := kernel.img
  53. IMAGES := factory.img.gz sysupgrade.img.gz
  54. IMAGE/sysupgrade.img.gz := boot-common | boot-2708 | sdcard-img | gzip | append-metadata
  55. IMAGE/factory.img.gz := boot-common | boot-2708 | sdcard-img | gzip
  56. endef
  57. define Device/rpi
  58. DEVICE_MODEL := B/B+/CM/Zero/ZeroW
  59. DEVICE_DTS := \
  60. bcm2708-rpi-b bcm2708-rpi-b-plus \
  61. bcm2708-rpi-cm \
  62. bcm2708-rpi-zero bcm2708-rpi-zero-w
  63. SUPPORTED_DEVICES := \
  64. rpi-b rpi-b-plus rpi-cm rpi-zero rpi-zero-w \
  65. raspberrypi,model-b raspberrypi,model-b-plus raspberrypi,model-b-rev2 \
  66. raspberrypi,compute-module raspberrypi,compute-module-1 \
  67. raspberrypi,model-zero raspberrypi,model-zero-w
  68. DEVICE_PACKAGES := \
  69. cypress-firmware-43430-sdio \
  70. cypress-nvram-43430-sdio-rpi-zero-w \
  71. kmod-brcmfmac wpad-basic-wolfssl
  72. endef
  73. ifeq ($(SUBTARGET),bcm2708)
  74. TARGET_DEVICES += rpi
  75. endif
  76. define Device/rpi-2
  77. DEVICE_MODEL := 2B/2B 1.2
  78. DEVICE_VARIANT := (32bit)
  79. DEVICE_ALT0_VENDOR := Raspberry Pi
  80. DEVICE_ALT0_MODEL := 3B/3B+/3CM
  81. DEVICE_ALT0_VARIANT := (32bit)
  82. DEVICE_ALT1_VENDOR := Raspberry Pi
  83. DEVICE_ALT1_MODEL := 4B
  84. DEVICE_ALT1_VARIANT := (32bit)
  85. DEVICE_DTS := \
  86. bcm2709-rpi-2-b bcm2710-rpi-2-b \
  87. bcm2710-rpi-3-b bcm2710-rpi-3-b-plus \
  88. bcm2711-rpi-4-b \
  89. bcm2710-rpi-cm3
  90. SUPPORTED_DEVICES := \
  91. rpi-2-b rpi-3-b rpi-3-b-plus rpi-cm \
  92. raspberrypi,2-model-b raspberrypi,2-model-b-rev2 \
  93. raspberrypi,3-model-b raspberrypi,3-model-b-plus \
  94. raspberrypi,3-compute-module raspberrypi,compute-module-3 \
  95. raspberrypi,4-model-b
  96. DEVICE_PACKAGES := \
  97. cypress-firmware-43430-sdio \
  98. cypress-nvram-43430-sdio-rpi-3b \
  99. cypress-firmware-43455-sdio \
  100. cypress-nvram-43455-sdio-rpi-3b-plus cypress-nvram-43455-sdio-rpi-4b \
  101. kmod-brcmfmac wpad-basic-wolfssl
  102. IMAGE/sysupgrade.img.gz := boot-common | boot-2708 | boot-2711 | sdcard-img | gzip | append-metadata
  103. IMAGE/factory.img.gz := boot-common | boot-2708 | boot-2711 | sdcard-img | gzip
  104. endef
  105. ifeq ($(SUBTARGET),bcm2709)
  106. TARGET_DEVICES += rpi-2
  107. endif
  108. define Device/rpi-3
  109. DEVICE_MODEL := 3B/3B+/3CM
  110. DEVICE_VARIANT := (64bit)
  111. DEVICE_ALT0_VENDOR := Raspberry Pi
  112. DEVICE_ALT0_MODEL := 2B-1.2
  113. DEVICE_ALT0_VARIANT := (64bit)
  114. KERNEL_IMG := kernel8.img
  115. DEVICE_DTS := \
  116. broadcom/bcm2710-rpi-2-b \
  117. broadcom/bcm2710-rpi-3-b broadcom/bcm2710-rpi-3-b-plus \
  118. broadcom/bcm2710-rpi-cm3
  119. SUPPORTED_DEVICES := \
  120. rpi-3-b rpi-3-b-plus \
  121. raspberrypi,2-model-b-rev2 \
  122. raspberrypi,3-model-b raspberrypi,3-model-b-plus \
  123. raspberrypi,3-compute-module raspberrypi,compute-module-3
  124. DEVICE_PACKAGES := \
  125. cypress-firmware-43430-sdio \
  126. cypress-nvram-43430-sdio-rpi-3b \
  127. cypress-firmware-43455-sdio \
  128. cypress-nvram-43455-sdio-rpi-3b-plus \
  129. kmod-brcmfmac wpad-basic-wolfssl
  130. endef
  131. ifeq ($(SUBTARGET),bcm2710)
  132. TARGET_DEVICES += rpi-3
  133. endif
  134. define Device/rpi-4
  135. DEVICE_MODEL := 4B
  136. DEVICE_VARIANT := (64bit)
  137. KERNEL_IMG := kernel8.img
  138. DEVICE_DTS := broadcom/bcm2711-rpi-4-b
  139. SUPPORTED_DEVICES := \
  140. raspberrypi,4-model-b
  141. DEVICE_PACKAGES := \
  142. cypress-firmware-43455-sdio \
  143. cypress-nvram-43455-sdio-rpi-4b \
  144. kmod-brcmfmac wpad-basic-wolfssl
  145. IMAGE/sysupgrade.img.gz := boot-common | boot-2711 | sdcard-img | gzip | append-metadata
  146. IMAGE/factory.img.gz := boot-common | boot-2711 | sdcard-img | gzip
  147. endef
  148. ifeq ($(SUBTARGET),bcm2711)
  149. TARGET_DEVICES += rpi-4
  150. endif
  151. $(eval $(call BuildImage))