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