9d3b6353a67ae87ff095b099a285613fc4d727fc
[openwrt/openwrt.git] / target / linux / mvebu / image / Makefile
1 #
2 # Copyright (C) 2012-2014 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 TARGET_DTBS := armada-xp-db armada-370-db armada-xp-openblocks-ax3-4 armada-370-mirabox \
11 armada-370-rd armada-xp-gp armada-xp-mamba
12
13 LOADADDR:=0x00008000
14
15 JFFS2_BLOCKSIZE = 128k
16
17 UBIFS_OPTS = -F -m 2048 -e 124KiB -c 4096 -U
18 UBI_OPTS = -m 2048 -p 128KiB -s 512 -O 2048
19
20 KDIR_TMP:=$(KDIR)/tmp
21
22
23 UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
24
25 define Image/Build/MkuImage
26 mkimage -A arm -O linux -T kernel -a $(LOADADDR) -C none -e $(LOADADDR) \
27 -n 'ARM OpenWrt Linux-$(LINUX_VERSION)' -d $(1) $(2);
28 endef
29
30 define Image/Build/DTB
31 cp $(KDIR)/zImage$(2) $(KDIR)/zImage$(2)-$(1);
32 cat $(DTS_DIR)/$(1).dtb >> $(KDIR)/zImage$(2)-$(1);
33 $(call Image/Build/MkuImage,$(KDIR)/zImage$(2)-$(1),$(KDIR)/uImage$(2)-$(1))
34 cp $(KDIR)/uImage$(2)-$(1) $(UIMAGE)$(2)-$(1);
35 endef
36
37 define Image/BuildKernel
38 $(foreach dtb,$(TARGET_DTBS),$(call Image/Build/DTB,$(dtb)))
39 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
40 $(call Image/Build/Initramfs)
41 endif
42 endef
43
44 define Image/Build/squashfs
45 $(STAGING_DIR_HOST)/bin/padjffs2 $(KDIR)/root.squashfs 128
46 $(foreach dtb,$(TARGET_DTBS),$(call Image/Build/UbinizeImage,$(dtb),,squashfs,$(UBI_OPTS));)
47 ( \
48 dd if=$(KDIR)/uImage-armada-xp-mamba bs=3072k conv=sync; \
49 dd if=$(BIN_DIR)/$(IMG_PREFIX)-armada-xp-mamba-squashfs-ubinized.bin \
50 bs=2048 conv=sync; \
51 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-mamba-squashfs-factory.img
52 endef
53
54 define Image/Build/Initramfs
55 $(foreach dtb,$(TARGET_DTBS),$(call Image/Build/DTB,$(dtb),-initramfs))
56 endef
57
58 define BuildSysupgrade
59 $(call Image/Build/SysupgradeNAND,$(2),$(1),$(KDIR)/uImage-$(2))
60 endef
61
62 define Image/Build
63 $(call Image/Build/$(1))
64 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
65 $(foreach dtb,$(TARGET_DTBS),$(call BuildSysupgrade,$(1),$(dtb));)
66 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
67 $(call Image/Build/Initramfs)
68 endif
69 endef
70
71 $(eval $(call BuildImage))