zynq: convert to new image build code
[openwrt/openwrt.git] / target / linux / zynq / image / Makefile
1 #
2 # Copyright (C) 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
10 #################################################
11 # Images
12 #################################################
13
14 # $(1): rootfs contents directory
15 define Image/mkfs/cpio
16 ( cd $(call mkfs_target_dir,$(1))/; find . | cpio -o -H newc | gzip -9n > $@ )
17 endef
18
19 # $(1): zynq board id
20 define Build/dtb
21 $(call Image/BuildDTB,$(DTS_DIR)/zynq-$(1).dts,$@.dtb)
22 endef
23
24 define Build/uRamdisk
25 # Create uboot cpio.gz
26 mkimage -A arm -T ramdisk -C gzip -n "$(PROFILE) OpenWRT rootfs" \
27 -d $(IMAGE_ROOTFS) $@.new
28 mv $@.new $@
29 endef
30
31 # $(1): FIT name/description
32 define Build/fit
33 # create FIT image with rootfs
34 ./mkits.sh \
35 -D $(1) -o $@.its -k $(IMAGE_KERNEL) -d $(IMAGE_KERNEL).dtb \
36 -C none -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) \
37 -A $(ARCH) -v $(LINUX_VERSION) -r $(IMAGE_ROOTFS) -z gzip
38
39 PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@
40 endef
41
42 #################################################
43 # Devices
44 #################################################
45
46 # default kernel load address
47 KERNEL_LOADADDR=0x8000
48 KERNEL_ENTRY=0x8000
49
50 TARGET_FILESYSTEMS += cpio
51
52 # $(1): canonical device name
53 # $(2): lowercase device id
54 define ZynqDevice
55 define Device/$(1)
56 DEVICE_TITLE := $(1) development board
57 KERNEL := dtb $(2) | kernel-bin | uImage none
58 KERNEL_NAME = zImage
59 IMAGES := uramdisk.image.gz fit.itb
60 IMAGE/uramdisk.image.gz := uRamdisk
61 IMAGE/fit.itb := fit $(2)
62 IMAGE_NAME = $$$$(IMG_PREFIX)-$(2)-$$$$(2)
63 endef
64 TARGET_DEVICES += $(1)
65 endef
66
67 $(eval $(call ZynqDevice,ZC702,zc702))
68 $(eval $(call ZynqDevice,ZedBoard,zed))
69 $(eval $(call ZynqDevice,ZYBO,zybo))
70
71 $(eval $(call BuildImage))