brcm2708: copy overlays README to boot partition
[openwrt/staging/yousong.git] / target / linux / brcm2708 / image / Makefile
index 53716e0d773943945343364c9550747df4d08f16..cf263bdf01abb32d0dac89221f8e2b94af606c10 100644 (file)
@@ -11,11 +11,17 @@ include $(INCLUDE_DIR)/host.mk
 FAT32_BLOCK_SIZE=1024
 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_BRCM2708_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
 
-### Image scripts ###
-define Build/build-dtb
-       $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $@.dtb $(DTS_DIR)/$(DEVICE_DTS).dts
-endef
+ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
+  define Image/gzip
+    gzip -9n -c $(1) > $(1).gz
+    mv $(1).gz $(BIN_DIR)
+  endef
+else
+  define Image/gzip
+  endef
+endif
 
+### Image scripts ###
 define Build/gen-cfg
        cat config.txt > $@.config
        echo -e "\ndevice_tree=$(DEVICE_DTS).dtb" >> $@.config
@@ -34,15 +40,16 @@ define Build/boot-img
        mcopy -i $@.boot cmdline.txt ::
        mcopy -i $@.boot $@.config ::config.txt
        mcopy -i $@.boot $(word 1,$^) ::kernel.img
-       mcopy -i $@.boot $@.dtb ::$(DEVICE_DTS).dtb
+       mcopy -i $@.boot $(DTS_DIR)/$(DEVICE_DTS).dtb ::$(DEVICE_DTS).dtb
+       mmd -i $@.boot ::/overlays
+       mcopy -i $@.boot $(DTS_DIR)/overlays/*.dtb ::/overlays/
+       mcopy -i $@.boot $(DTS_DIR)/overlays/README ::/overlays/
 endef
 
 define Build/sdcard-img
        ./gen_rpi_sdcard_img.sh $@ $@.boot $(word 2,$^) \
                $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
-  ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
-       gzip -k -f9 $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img
-  endif
+       $(call Image/gzip,$@)
 endef
 
 ### Device macros ###
@@ -51,12 +58,11 @@ define Device/Default
   PROFILES = Default $$(DEVICE_PROFILE)
   KERNEL := kernel-bin
   IMAGES := sdcard.bin
-  IMAGE/sdcard.bin := build-dtb | gen-cfg | boot-img | sdcard-img
+  IMAGE/sdcard.bin := gen-cfg | boot-img | sdcard-img
   DEVICE_PROFILE :=
-  DEVICE_NAME :=
   DEVICE_DTS :=
 endef
-DEVICE_VARS += DEVICE_PROFILE DEVICE_NAME DEVICE_DTS
+DEVICE_VARS += DEVICE_PROFILE DEVICE_DTS
 
 # $(1) = profile
 # $(2) = image name
@@ -64,17 +70,25 @@ DEVICE_VARS += DEVICE_PROFILE DEVICE_NAME DEVICE_DTS
 define add_bcm2708
   define Device/$(2)
     DEVICE_PROFILE := $(1)
-    DEVICE_NAME := $(2)
     DEVICE_DTS := $(3)
   endef
   TARGET_DEVICES += $(2)
 endef
 
-# Raspberry Pi Model B
-$(eval $(call add_bcm2708,RaspberryPi,rpi-b,bcm2708-rpi-b))
-# Raspberry Pi Model B+
-$(eval $(call add_bcm2708,RaspberryPi,rpi-b-plus,bcm2708-rpi-b-plus))
-# Raspberry Pi 2 Model B
-$(eval $(call add_bcm2708,RaspberryPi2,rpi-2-b,bcm2709-rpi-2-b))
+### BCM2708/BCM2835 ###
+ifeq ($(SUBTARGET),bcm2708)
+  # Raspberry Pi Model B
+  $(eval $(call add_bcm2708,RaspberryPi_B,rpi-b,bcm2708-rpi-b))
+  # Raspberry Pi Model B+
+  $(eval $(call add_bcm2708,RaspberryPi_BPlus,rpi-b-plus,bcm2708-rpi-b-plus))
+  # Raspberry Pi Compute Module
+  $(eval $(call add_bcm2708,RaspberryPi_CM,rpi-cm,bcm2708-rpi-cm))
+endif
+
+### BCM2709/BCM2836 ###
+ifeq ($(SUBTARGET),bcm2709)
+  # Raspberry Pi 2 Model B
+  $(eval $(call add_bcm2708,RaspberryPi_2,rpi-2-b,bcm2709-rpi-2-b))
+endif
 
 $(eval $(call BuildImage))