8cf83a4563a7fc671750b414899648d2976fadc6
[openwrt/staging/dedeckeh.git] / target / linux / brcm2708 / image / Makefile
1 #
2 # Copyright (C) 2012-2015 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9 include $(INCLUDE_DIR)/host.mk
10
11 FAT32_BLOCK_SIZE=1024
12 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_BRCM2708_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
13
14 ### Image scripts ###
15 define Build/kernel-img
16 perl $(LINUX_DIR)/scripts/mkknlimg $@ $@.tmp
17 mv $@.tmp $@
18 endef
19
20 define Build/boot-img
21 rm -f $@.boot
22 mkfs.fat -C $@.boot $(FAT32_BLOCKS)
23 mcopy -i $@.boot $(KDIR)/bootcode.bin ::
24 mcopy -i $@.boot $(KDIR)/COPYING.linux ::
25 mcopy -i $@.boot $(KDIR)/LICENCE.broadcom ::
26 mcopy -i $@.boot $(KDIR)/start.elf ::
27 mcopy -i $@.boot $(KDIR)/start_cd.elf ::
28 mcopy -i $@.boot $(KDIR)/fixup.dat ::
29 mcopy -i $@.boot $(KDIR)/fixup_cd.dat ::
30 mcopy -i $@.boot cmdline.txt ::
31 mcopy -i $@.boot config.txt ::
32 mcopy -i $@.boot $(word 1,$^) ::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/*.dtb ::/overlays/
36 mcopy -i $@.boot $(DTS_DIR)/overlays/README ::/overlays/
37 endef
38
39 define Build/sdcard-img
40 ./gen_rpi_sdcard_img.sh $@ $@.boot $(word 2,$^) \
41 $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
42 $(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
43 endef
44
45 ### Device macros ###
46 define Device/Default
47 FILESYSTEMS := ext4
48 PROFILES = Default $$(DEVICE_PROFILE)
49 KERNEL := kernel-bin | kernel-img
50 IMAGES := sdcard.img
51 IMAGE/sdcard.img := boot-img | sdcard-img
52 DEVICE_PROFILE :=
53 DEVICE_DTS :=
54 endef
55 DEVICE_VARS += DEVICE_PROFILE DEVICE_DTS
56
57 # $(1) = profile
58 # $(2) = image name
59 # $(3) = dts
60 define bcm27xx
61 define Device/$(2)
62 DEVICE_PROFILE := $(1)
63 DEVICE_DTS := $(3)
64 endef
65 TARGET_DEVICES += $(2)
66 endef
67
68 ### BCM2708/BCM2835 ###
69 ifeq ($(SUBTARGET),bcm2708)
70 # Raspberry Pi Models B/B+/CM
71 $(eval $(call bcm27xx,RaspberryPi,rpi,bcm2708-rpi-b bcm2708-rpi-b-plus bcm2708-rpi-cm))
72 endif
73
74 ### BCM2709/BCM2836 ###
75 ifeq ($(SUBTARGET),bcm2709)
76 # Raspberry Pi 2 Model B
77 $(eval $(call bcm27xx,RaspberryPi_2,rpi-2,bcm2709-rpi-2-b))
78 endif
79
80 ### BCM2710/BCM2837 ###
81 ifeq ($(SUBTARGET),bcm2710)
82 # Raspberry Pi 3 Model B
83 $(eval $(call bcm27xx,RaspberryPi_3,rpi-3,bcm2710-rpi-3-b))
84 endif
85
86 $(eval $(call BuildImage))