mxs: fix imagebuilder
[openwrt/svn-archive/archive.git] / target / linux / mxs / image / Makefile
1 #
2 # Copyright (C) 2013 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/image.mk
10 include $(INCLUDE_DIR)/host.mk
11
12 BOARDS:= \
13 imx23-olinuxino \
14 imx28-duckbill
15 FAT32_BLOCK_SIZE=1024
16 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_MXS_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
17
18 define Image/BuildKernel
19 mkimage -A arm -O linux -T kernel -C none \
20 -a 0x40008000 -e 0x40008000 \
21 -n 'ARM OpenWrt Linux-$(LINUX_VERSION)' \
22 -d $(KDIR)/zImage $(KDIR)/uImage
23 cp $(KDIR)/uImage $(BIN_DIR)/$(IMG_PREFIX)-uImage
24 endef
25
26 define Image/InstallKernel
27
28 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
29 mkdir -p $(TARGET_DIR)/boot
30 cp $(KDIR)/zImage $(TARGET_DIR)/boot/
31 endif
32
33 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE),)
34 mkdir -p $(TARGET_DIR)/boot
35 cp $(KDIR)/uImage $(TARGET_DIR)/boot/
36 endif
37
38 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
39 mkdir -p $(TARGET_DIR)/boot
40 $(foreach board,$(BOARDS),
41 $(CP) $(DTS_DIR)/$(board).dtb $(TARGET_DIR)/boot/
42 )
43 endif
44
45 endef
46
47 define Image/Build/SDCard
48 rm -f $(KDIR)/boot.img
49 mkdosfs $(KDIR)/boot.img -C $(FAT32_BLOCKS)
50
51 mcopy -i $(KDIR)/boot.img $(DTS_DIR)/$(2).dtb ::$(2).dtb
52 mcopy -i $(KDIR)/boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
53
54 ./gen_mxs_sdcard_img.sh \
55 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
56 $(KDIR)/boot.img \
57 $(KDIR)/root.$(1) \
58 $(CONFIG_MXS_SD_BOOT_PARTSIZE) \
59 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
60 $(BIN_DIR)/uboot-mxs-$(3).sb
61 endef
62
63 define Image/Build/Profile/olinuxino-maxi
64 $(call Image/Build/SDCard,$(1),imx23-olinuxino,mx23_olinuxino)
65 endef
66
67 define Image/Build/Profile/olinuxino-micro
68 $(call Image/Build/SDCard,$(1),imx23-olinuxino,mx23_olinuxino)
69 endef
70
71 define Image/Build/Profile/duckbill
72 $(call Image/Build/SDCard,$(1),imx28-duckbill,duckbill)
73 endef
74
75 define Image/Build
76 $(call Image/Build/$(1),$(1))
77 $(call Image/Build/Profile/$(PROFILE),$(1))
78 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
79 endef
80
81 $(eval $(call BuildImage))