brcm2708: copy overlays README to boot partition
[openwrt/staging/lynxis.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 ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
15 define Image/gzip
16 gzip -9n -c $(1) > $(1).gz
17 mv $(1).gz $(BIN_DIR)
18 endef
19 else
20 define Image/gzip
21 endef
22 endif
23
24 ### Image scripts ###
25 define Build/gen-cfg
26 cat config.txt > $@.config
27 echo -e "\ndevice_tree=$(DEVICE_DTS).dtb" >> $@.config
28 endef
29
30 define Build/boot-img
31 rm -f $@.boot
32 mkfs.fat -C $@.boot $(FAT32_BLOCKS)
33 mcopy -i $@.boot $(KDIR)/bootcode.bin ::
34 mcopy -i $@.boot $(KDIR)/COPYING.linux ::
35 mcopy -i $@.boot $(KDIR)/LICENCE.broadcom ::
36 mcopy -i $@.boot $(KDIR)/start.elf ::
37 mcopy -i $@.boot $(KDIR)/start_cd.elf ::
38 mcopy -i $@.boot $(KDIR)/fixup.dat ::
39 mcopy -i $@.boot $(KDIR)/fixup_cd.dat ::
40 mcopy -i $@.boot cmdline.txt ::
41 mcopy -i $@.boot $@.config ::config.txt
42 mcopy -i $@.boot $(word 1,$^) ::kernel.img
43 mcopy -i $@.boot $(DTS_DIR)/$(DEVICE_DTS).dtb ::$(DEVICE_DTS).dtb
44 mmd -i $@.boot ::/overlays
45 mcopy -i $@.boot $(DTS_DIR)/overlays/*.dtb ::/overlays/
46 mcopy -i $@.boot $(DTS_DIR)/overlays/README ::/overlays/
47 endef
48
49 define Build/sdcard-img
50 ./gen_rpi_sdcard_img.sh $@ $@.boot $(word 2,$^) \
51 $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
52 $(call Image/gzip,$@)
53 endef
54
55 ### Device macros ###
56 define Device/Default
57 FILESYSTEMS := ext4
58 PROFILES = Default $$(DEVICE_PROFILE)
59 KERNEL := kernel-bin
60 IMAGES := sdcard.bin
61 IMAGE/sdcard.bin := gen-cfg | boot-img | sdcard-img
62 DEVICE_PROFILE :=
63 DEVICE_DTS :=
64 endef
65 DEVICE_VARS += DEVICE_PROFILE DEVICE_DTS
66
67 # $(1) = profile
68 # $(2) = image name
69 # $(3) = dts
70 define add_bcm2708
71 define Device/$(2)
72 DEVICE_PROFILE := $(1)
73 DEVICE_DTS := $(3)
74 endef
75 TARGET_DEVICES += $(2)
76 endef
77
78 ### BCM2708/BCM2835 ###
79 ifeq ($(SUBTARGET),bcm2708)
80 # Raspberry Pi Model B
81 $(eval $(call add_bcm2708,RaspberryPi_B,rpi-b,bcm2708-rpi-b))
82 # Raspberry Pi Model B+
83 $(eval $(call add_bcm2708,RaspberryPi_BPlus,rpi-b-plus,bcm2708-rpi-b-plus))
84 # Raspberry Pi Compute Module
85 $(eval $(call add_bcm2708,RaspberryPi_CM,rpi-cm,bcm2708-rpi-cm))
86 endif
87
88 ### BCM2709/BCM2836 ###
89 ifeq ($(SUBTARGET),bcm2709)
90 # Raspberry Pi 2 Model B
91 $(eval $(call add_bcm2708,RaspberryPi_2,rpi-2-b,bcm2709-rpi-2-b))
92 endif
93
94 $(eval $(call BuildImage))