brcm2708: update to latest version
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / image / Makefile
1 #
2 # Copyright (C) 2012-2015 OpenWrt.org
3 # Copyright (C) 2016 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
12 FAT32_BLOCK_SIZE=1024
13 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_BRCM2708_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
14
15 ### Image scripts ###
16 define Build/kernel-img
17 perl $(LINUX_DIR)/scripts/mkknlimg $@ $@.tmp
18 mv $@.tmp $@
19 endef
20
21 define Build/boot-img
22 rm -f $@.boot
23 mkfs.fat -C $@.boot $(FAT32_BLOCKS)
24 mcopy -i $@.boot $(LINUX_DIR)/COPYING ::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 $(word 1,$^) ::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
40 define Build/sdcard-img
41 ./gen_rpi_sdcard_img.sh $@ $@.boot $(word 2,$^) \
42 $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
43 $(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
44 endef
45
46 ### Device macros ###
47 define Device/Default
48 FILESYSTEMS := ext4
49 PROFILES = Default $$(DEVICE_PROFILE)
50 KERNEL := kernel-bin | kernel-img
51 IMAGES := sdcard.img
52 IMAGE/sdcard.img := boot-img | sdcard-img
53 DEVICE_PROFILE :=
54 DEVICE_DTS :=
55 endef
56 DEVICE_VARS += DEVICE_PROFILE DEVICE_DTS
57
58 # $(1) = profile
59 # $(2) = image name
60 # $(3) = dts
61 define bcm27xx
62 define Device/$(2)
63 DEVICE_PROFILE := $(1)
64 DEVICE_DTS := $(3)
65 endef
66 TARGET_DEVICES += $(2)
67 endef
68
69 ### BCM2708/BCM2835 ###
70 ifeq ($(SUBTARGET),bcm2708)
71 # Raspberry Pi Models B/B+/CM
72 $(eval $(call bcm27xx,RaspberryPi,rpi,bcm2708-rpi-b bcm2708-rpi-b-plus bcm2708-rpi-cm))
73 endif
74
75 ### BCM2709/BCM2836 ###
76 ifeq ($(SUBTARGET),bcm2709)
77 # Raspberry Pi 2 Model B
78 $(eval $(call bcm27xx,RaspberryPi_2,rpi-2,bcm2709-rpi-2-b))
79 endif
80
81 ### BCM2710/BCM2837 ###
82 ifeq ($(SUBTARGET),bcm2710)
83 # Raspberry Pi 3 Model B
84 $(eval $(call bcm27xx,RaspberryPi_3,rpi-3,bcm2710-rpi-3-b))
85 endif
86
87 $(eval $(call BuildImage))