c3e7cbac4858adbccff064e0374c24a74681a9ce
[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-img
25 rm -f $@.boot
26 mkfs.fat -C $@.boot $(FAT32_BLOCKS)
27 mcopy -i $@.boot $(KDIR)/COPYING.linux ::
28 mcopy -i $@.boot $(KDIR)/bootcode.bin ::
29 mcopy -i $@.boot $(KDIR)/LICENCE.broadcom ::
30 mcopy -i $@.boot $(KDIR)/start.elf ::
31 mcopy -i $@.boot $(KDIR)/start_cd.elf ::
32 mcopy -i $@.boot $(KDIR)/start_x.elf ::
33 mcopy -i $@.boot $(KDIR)/fixup.dat ::
34 mcopy -i $@.boot $(KDIR)/fixup_cd.dat ::
35 mcopy -i $@.boot $(KDIR)/fixup_x.dat ::
36 mcopy -i $@.boot cmdline.txt ::
37 mcopy -i $@.boot config.txt ::
38 mcopy -i $@.boot $(IMAGE_KERNEL) ::$(KERNEL_IMG)
39 $(foreach dts,$(shell echo $(DEVICE_DTS)),mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::;)
40 mmd -i $@.boot ::/overlays
41 mcopy -i $@.boot $(DTS_DIR)/overlays/*.dtbo ::/overlays/
42 mcopy -i $@.boot $(DTS_DIR)/overlays/README ::/overlays/
43 endef
44
45 define Build/sdcard-img
46 ./gen_rpi_sdcard_img.sh $@ $@.boot $(IMAGE_ROOTFS) \
47 $(CONFIG_TARGET_KERNEL_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
48 endef
49
50 ### Devices ###
51 define Device/Default
52 KERNEL := kernel-bin | kernel-img
53 KERNEL_IMG := kernel.img
54 IMAGES := factory.img.gz sysupgrade.img.gz
55 IMAGE/sysupgrade.img.gz := boot-img | sdcard-img | gzip | append-metadata
56 IMAGE/factory.img.gz := boot-img | sdcard-img | gzip
57 endef
58
59 define Device/rpi
60 DEVICE_TITLE := Raspberry Pi B/B+/CM/Zero/ZeroW
61 DEVICE_DTS := bcm2708-rpi-b bcm2708-rpi-b-plus bcm2708-rpi-cm bcm2708-rpi-zero bcm2708-rpi-zero-w
62 SUPPORTED_DEVICES := \
63 rpi-b rpi-b-plus rpi-cm rpi-zero rpi-zero-w \
64 raspberrypi,model-b raspberrypi,model-b-plus raspberrypi,model-b-rev2 \
65 raspberrypi,compute-module raspberrypi,compute-module-1 \
66 raspberrypi,model-zero raspberrypi,model-zero-w
67 DEVICE_PACKAGES := \
68 brcmfmac-firmware-43430-sdio \
69 brcmfmac-firmware-43430-sdio-rpi-zero-w \
70 kmod-brcmfmac wpad-basic
71 endef
72 ifeq ($(SUBTARGET),bcm2708)
73 TARGET_DEVICES += rpi
74 endif
75
76 define Device/rpi-2
77 DEVICE_TITLE := Raspberry Pi 2B/3B/3B+/3CM
78 DEVICE_DTS := bcm2709-rpi-2-b bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3
79 SUPPORTED_DEVICES := \
80 rpi-2-b rpi-3-b rpi-3-b-plus rpi-cm \
81 raspberrypi,2-model-b \
82 raspberrypi,3-model-b raspberrypi,3-model-b-plus \
83 raspberrypi,3-compute-module raspberrypi,compute-module-3
84 DEVICE_PACKAGES := \
85 brcmfmac-firmware-43430-sdio \
86 brcmfmac-firmware-43430-sdio-rpi-3b \
87 brcmfmac-firmware-43455-sdio brcmfmac-firmware-43455-clm_blob \
88 brcmfmac-firmware-43455-sdio-rpi-3b-plus \
89 kmod-brcmfmac wpad-basic
90 endef
91 ifeq ($(SUBTARGET),bcm2709)
92 TARGET_DEVICES += rpi-2
93 endif
94
95 define Device/rpi-3
96 KERNEL_IMG := kernel8.img
97 DEVICE_TITLE := Raspberry Pi 3B/3B+/3CM
98 DEVICE_DTS := broadcom/bcm2710-rpi-3-b broadcom/bcm2710-rpi-3-b-plus broadcom/bcm2710-rpi-cm3
99 SUPPORTED_DEVICES := \
100 rpi-3-b rpi-3-b-plus \
101 raspberrypi,3-model-b raspberrypi,3-model-b-plus \
102 raspberrypi,3-compute-module raspberrypi,compute-module-3
103 DEVICE_PACKAGES := \
104 brcmfmac-firmware-43430-sdio \
105 brcmfmac-firmware-43430-sdio-rpi-3b \
106 brcmfmac-firmware-43455-sdio brcmfmac-firmware-43455-clm_blob \
107 brcmfmac-firmware-43455-sdio-rpi-3b-plus \
108 kmod-brcmfmac wpad-basic
109 endef
110 ifeq ($(SUBTARGET),bcm2710)
111 TARGET_DEVICES += rpi-3
112 endif
113
114 $(eval $(call BuildImage))