mxs: Include the right kernel image in the rootfs
[15.05/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_ZIMAGE),)
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_UIMAGE),)
31         mkdir -p $(TARGET_DIR)/boot
32         cp $(KDIR)/uImage $(TARGET_DIR)/boot/
33   endif
34   
35   ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
36         mkdir -p $(TARGET_DIR)/boot
37         $(foreach board,$(BOARDS),
38                 $(CP) $(DTS_DIR)/$(board).dtb $(TARGET_DIR)/boot/
39         )
40   endif
41
42 endef
43
44 define Image/Build/SDCard
45         rm -f $(KDIR)/boot.img
46         mkdosfs $(KDIR)/boot.img -C $(FAT32_BLOCKS)
47
48         mcopy -i $(KDIR)/boot.img $(DTS_DIR)/$(2).dtb ::$(2).dtb
49         mcopy -i $(KDIR)/boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
50
51         ./gen_mxs_sdcard_img.sh \
52                 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
53                 $(KDIR)/boot.img \
54                 $(KDIR)/root.$(1) \
55                 $(CONFIG_MXS_SD_BOOT_PARTSIZE) \
56                 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
57                 $(BIN_DIR)/uboot-mxs-$(3).sb
58 endef
59
60 define Image/Build/Profile/olinuxino-maxi
61         $(call Image/Build/SDCard,$(1),imx23-olinuxino,mx23_olinuxino)
62 endef
63
64 define Image/Build/Profile/olinuxino-micro
65         $(call Image/Build/SDCard,$(1),imx23-olinuxino,mx23_olinuxino)
66 endef
67
68 define Image/Build/Profile/duckbill
69         $(call Image/Build/SDCard,$(1),imx28-duckbill,duckbill)
70 endef
71
72 define Image/Build
73         $(call Image/Build/$(1),$(1))
74         $(call Image/Build/Profile/$(PROFILE),$(1))
75 endef
76
77 $(eval $(call BuildImage))