55e88c25f3f344d5982f84a44e599f354f43526b
[openwrt.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 FAT32_BLOCK_SIZE=1024
13 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_MXS_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
14
15 define Image/BuildKernel
16         mkimage -A arm -O linux -T kernel -C none \
17                 -a 0x40008000 -e 0x40008000 \
18                 -n 'ARM OpenWrt Linux-$(LINUX_VERSION)' \
19                 -d $(KDIR)/zImage $(KDIR)/uImage
20         cp $(KDIR)/uImage $(BIN_DIR)/$(IMG_PREFIX)-uImage
21 endef
22
23 define Image/InstallKernel
24
25   ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
26         mkdir -p $(TARGET_DIR)/boot
27         $(CP) $(LINUX_DIR)/arch/arm/boot/zImage $(TARGET_DIR)/boot/
28   endif
29   
30   ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
31         mkdir -p $(TARGET_DIR)/boot
32         $(foreach board,$(BOARDS),
33                 $(CP) $(DTS_DIR)/$(board).dtb $(TARGET_DIR)/boot/
34         )
35   endif
36
37 endef
38
39 define Image/Build/SDCard
40         rm -f $(KDIR)/boot.img
41         mkdosfs $(KDIR)/boot.img -C $(FAT32_BLOCKS)
42
43         mcopy -i $(KDIR)/boot.img $(DTS_DIR)/$(2).dtb ::$(2).dtb
44         mcopy -i $(KDIR)/boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
45
46         ./gen_mxs_sdcard_img.sh \
47                 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
48                 $(KDIR)/boot.img \
49                 $(KDIR)/root.$(1) \
50                 $(CONFIG_MXS_SD_BOOT_PARTSIZE) \
51                 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
52                 $(BIN_DIR)/uboot-mxs-$(3).sb
53 endef
54
55 define Image/Build/Profile/olinuxino-maxi
56         $(call Image/Build/SDCard,$(1),imx23-olinuxino,mx23_olinuxino)
57 endef
58
59 define Image/Build/Profile/olinuxino-micro
60         $(call Image/Build/SDCard,$(1),imx23-olinuxino,mx23_olinuxino)
61 endef
62
63 define Image/Build/Profile/duckbill
64         $(call Image/Build/SDCard,$(1),imx28-duckbill,duckbill)
65 endef
66
67 define Image/Build
68         $(call Image/Build/$(1),$(1))
69         $(call Image/Build/Profile/$(PROFILE),$(1))
70 endef
71
72 $(eval $(call BuildImage))