e5b8c8aa0b97826ae972af674f9b1b87b0ebb8b4
[openwrt/staging/dedeckeh.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 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 endef
72
73 define Device/rpi
74 DEVICE_MODEL := B/B+/CM/Zero/ZeroW
75 DEVICE_DTS := \
76 bcm2708-rpi-b bcm2708-rpi-b-plus \
77 bcm2708-rpi-cm \
78 bcm2708-rpi-zero bcm2708-rpi-zero-w
79 SUPPORTED_DEVICES := \
80 rpi-b rpi-b-plus rpi-cm rpi-zero rpi-zero-w \
81 raspberrypi,model-b raspberrypi,model-b-plus raspberrypi,model-b-rev2 \
82 raspberrypi,compute-module raspberrypi,compute-module-1 \
83 raspberrypi,model-zero raspberrypi,model-zero-w
84 DEVICE_PACKAGES := \
85 cypress-firmware-43430-sdio \
86 cypress-nvram-43430-sdio-rpi-zero-w \
87 kmod-brcmfmac wpad-basic
88 endef
89 ifeq ($(SUBTARGET),bcm2708)
90 TARGET_DEVICES += rpi
91 endif
92
93 define Device/rpi-2
94 DEVICE_MODEL := 2B/3B/3B+/3CM/4B
95 DEVICE_DTS := \
96 bcm2709-rpi-2-b bcm2710-rpi-2-b \
97 bcm2710-rpi-3-b bcm2710-rpi-3-b-plus \
98 bcm2711-rpi-4-b \
99 bcm2710-rpi-cm3
100 SUPPORTED_DEVICES := \
101 rpi-2-b rpi-3-b rpi-3-b-plus rpi-cm \
102 raspberrypi,2-model-b raspberrypi,2-model-b-rev2 \
103 raspberrypi,3-model-b raspberrypi,3-model-b-plus \
104 raspberrypi,3-compute-module raspberrypi,compute-module-3 \
105 raspberrypi,4-model-b
106 DEVICE_PACKAGES := \
107 cypress-firmware-43430-sdio \
108 cypress-nvram-43430-sdio-rpi-3b \
109 cypress-firmware-43455-sdio \
110 cypress-nvram-43455-sdio-rpi-3b-plus cypress-nvram-43455-sdio-rpi-4b \
111 kmod-brcmfmac wpad-basic
112 IMAGE/sysupgrade.img.gz := boot-common | boot-2708 | boot-2711 | sdcard-img | gzip | append-metadata
113 IMAGE/factory.img.gz := boot-common | boot-2708 | boot-2711 | sdcard-img | gzip
114 endef
115 ifeq ($(SUBTARGET),bcm2709)
116 TARGET_DEVICES += rpi-2
117 endif
118
119 define Device/rpi-3
120 DEVICE_MODEL := 2B-1.2/3B/3B+/3CM
121 KERNEL_IMG := kernel8.img
122 DEVICE_DTS := \
123 broadcom/bcm2710-rpi-2-b \
124 broadcom/bcm2710-rpi-3-b broadcom/bcm2710-rpi-3-b-plus \
125 broadcom/bcm2710-rpi-cm3
126 SUPPORTED_DEVICES := \
127 rpi-3-b rpi-3-b-plus \
128 raspberrypi,2-model-b-rev2 \
129 raspberrypi,3-model-b raspberrypi,3-model-b-plus \
130 raspberrypi,3-compute-module raspberrypi,compute-module-3
131 DEVICE_PACKAGES := \
132 cypress-firmware-43430-sdio \
133 cypress-nvram-43430-sdio-rpi-3b \
134 cypress-firmware-43455-sdio \
135 cypress-nvram-43455-sdio-rpi-3b-plus \
136 kmod-brcmfmac wpad-basic
137 endef
138 ifeq ($(SUBTARGET),bcm2710)
139 TARGET_DEVICES += rpi-3
140 endif
141
142 define Device/rpi-4
143 DEVICE_MODEL := 4B
144 KERNEL_IMG := kernel8.img
145 DEVICE_DTS := broadcom/bcm2711-rpi-4-b
146 SUPPORTED_DEVICES := \
147 raspberrypi,4-model-b
148 DEVICE_PACKAGES := \
149 cypress-firmware-43455-sdio \
150 cypress-nvram-43455-sdio-rpi-4b \
151 kmod-brcmfmac wpad-basic
152 IMAGE/sysupgrade.img.gz := boot-common | boot-2711 | sdcard-img | gzip | append-metadata
153 IMAGE/factory.img.gz := boot-common | boot-2711 | sdcard-img | gzip
154 endef
155 ifeq ($(SUBTARGET),bcm2711)
156 TARGET_DEVICES += rpi-4
157 endif
158
159 $(eval $(call BuildImage))