Makefile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #
  2. # Copyright (C) 2012-2015 OpenWrt.org
  3. # Copyright (C) 2016-2017 LEDE project
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. include $(TOPDIR)/rules.mk
  9. include $(INCLUDE_DIR)/image.mk
  10. include $(INCLUDE_DIR)/host.mk
  11. FAT32_BLOCK_SIZE=1024
  12. FAT32_BLOCKS=$(shell echo $$(($(CONFIG_BRCM2708_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
  13. define Build/Compile
  14. $(CP) $(LINUX_DIR)/COPYING $(KDIR)/COPYING.linux
  15. endef
  16. ### Image scripts ###
  17. define Build/kernel-img
  18. perl $(LINUX_DIR)/scripts/mkknlimg $@ $@.tmp
  19. mv $@.tmp $@
  20. endef
  21. define Build/boot-img
  22. rm -f $@.boot
  23. mkfs.fat -C $@.boot $(FAT32_BLOCKS)
  24. mcopy -i $@.boot $(KDIR)/COPYING.linux ::
  25. mcopy -i $@.boot $(KDIR)/bootcode.bin ::
  26. mcopy -i $@.boot $(KDIR)/LICENCE.broadcom ::
  27. mcopy -i $@.boot $(KDIR)/start.elf ::
  28. mcopy -i $@.boot $(KDIR)/start_cd.elf ::
  29. mcopy -i $@.boot $(KDIR)/fixup.dat ::
  30. mcopy -i $@.boot $(KDIR)/fixup_cd.dat ::
  31. mcopy -i $@.boot cmdline.txt ::
  32. mcopy -i $@.boot config.txt ::
  33. mcopy -i $@.boot $(IMAGE_KERNEL) ::kernel.img
  34. $(foreach dts,$(shell echo $(DEVICE_DTS)),mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::;)
  35. mmd -i $@.boot ::/overlays
  36. mcopy -i $@.boot $(DTS_DIR)/overlays/*.dtbo ::/overlays/
  37. mcopy -i $@.boot $(DTS_DIR)/overlays/README ::/overlays/
  38. endef
  39. define Build/sdcard-img
  40. ./gen_rpi_sdcard_img.sh $@ $@.boot $(IMAGE_ROOTFS) \
  41. $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  42. endef
  43. ### Devices ###
  44. define Device/Default
  45. FILESYSTEMS := ext4
  46. KERNEL := kernel-bin | kernel-img
  47. IMAGES := sdcard.img
  48. IMAGE/sdcard.img := boot-img | sdcard-img
  49. endef
  50. define Device/rpi
  51. DEVICE_TITLE := Raspberry Pi B/B+/CM/Zero/ZeroW
  52. DEVICE_DTS := bcm2708-rpi-b bcm2708-rpi-b-plus bcm2708-rpi-cm bcm2708-rpi-0-w
  53. DEVICE_PACKAGES := brcmfmac-firmware-43430-sdio kmod-brcmfmac wpad-mini
  54. endef
  55. ifeq ($(SUBTARGET),bcm2708)
  56. TARGET_DEVICES += rpi
  57. endif
  58. define Device/rpi-2
  59. DEVICE_TITLE := Raspberry Pi 2 B
  60. DEVICE_DTS := bcm2709-rpi-2-b
  61. endef
  62. ifeq ($(SUBTARGET),bcm2709)
  63. TARGET_DEVICES += rpi-2
  64. endif
  65. define Device/rpi-3
  66. DEVICE_TITLE := Raspberry Pi 3 B/CM
  67. DEVICE_DTS := bcm2710-rpi-3-b bcm2710-rpi-cm3
  68. DEVICE_PACKAGES := brcmfmac-firmware-43430-sdio kmod-brcmfmac wpad-mini
  69. endef
  70. ifeq ($(SUBTARGET),bcm2710)
  71. TARGET_DEVICES += rpi-3
  72. endif
  73. $(eval $(call BuildImage))