e7991cffde98e321407d4dad9ff3f24c19555921
[15.05/openwrt.git] / target / linux / sunxi / 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 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9 include $(INCLUDE_DIR)/host.mk
10
11 FAT32_BLOCK_SIZE=1024
12 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_SUNXI_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
13
14 BOARDS:= \
15         sun4i-a10-cubieboard \
16         sun4i-a10-olinuxino-lime \
17         sun4i-a10-pcduino \
18         sun5i-a13-olinuxino \
19         sun6i-a31-colombus \
20         sun7i-a20-bananapi \
21         sun7i-a20-cubieboard2 \
22         sun7i-a20-cubietruck \
23         sun7i-a20-olinuxino-micro \
24         sun7i-a20-pcduino3
25
26 define Image/BuildKernel
27         mkimage -A arm -O linux -T kernel -C none \
28                 -a 0x40008000 -e 0x40008000 \
29                 -n 'ARM OpenWrt Linux-$(LINUX_VERSION)' \
30                 -d $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-uImage
31         
32     ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
33         $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
34         echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
35         $(call Image/BuildKernel/MkuImage, \
36                 none, 0x40008000, 0x40008000, \
37                 $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
38                 $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
39         )
40     endif
41
42         $(foreach board,$(BOARDS),
43                 $(CP) $(DTS_DIR)/$(board).dtb $(BIN_DIR)/
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 $(BIN_DIR)/uboot-sunxi-$(PROFILE)/openwrt-sunxi-$(PROFILE)-uEnv.txt ::uEnv.txt
52         mcopy -i $(KDIR)/boot.img $(BIN_DIR)/$(2).dtb ::dtb
53         mcopy -i $(KDIR)/boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
54         
55         ./gen_sunxi_sdcard_img.sh \
56                 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
57                 $(KDIR)/boot.img \
58                 $(KDIR)/root.$(1) \
59                 $(CONFIG_SUNXI_SD_BOOT_PARTSIZE) \
60                 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
61                 $(BIN_DIR)/uboot-sunxi-$(PROFILE)/openwrt-sunxi-$(PROFILE)-u-boot-with-spl.bin
62 endef
63
64 define Image/Build/Profile/A10-OLinuXino-Lime
65         $(call Image/Build/SDCard,$(1),sun4i-a10-olinuxino-lime)
66 endef
67
68 define Image/Build/Profile/A13-OLinuXino
69         $(call Image/Build/SDCard,$(1),sun5i-a13-olinuxino)
70 endef
71
72 define Image/Build/Profile/A20-OLinuXino_MICRO
73         $(call Image/Build/SDCard,$(1),sun7i-a20-olinuxino-micro)
74 endef
75
76 define Image/Build/Profile/Bananapi
77         $(call Image/Build/SDCard,$(1),sun7i-a20-bananapi)
78 endef
79
80 define Image/Build/Profile/Cubieboard
81         $(call Image/Build/SDCard,$(1),sun4i-a10-cubieboard)
82 endef
83
84 define Image/Build/Profile/Cubieboard2
85         $(call Image/Build/SDCard,$(1),sun7i-a20-cubieboard2)
86 endef
87
88 define Image/Build/Profile/OLIMEX-A13-SOM
89         $(call Image/Build/SDCard,$(1),sun5i-a13-olinuxino)
90 endef
91
92 define Image/Build/Profile/pcDuino
93         $(call Image/Build/SDCard,$(1),sun4i-a10-pcduino)
94 endef
95
96 define Image/Build/Profile/Linksprite_pcDuino3
97         $(call Image/Build/SDCard,$(1),sun7i-a20-pcduino3)
98 endef
99
100 define Image/Build
101         $(call Image/Build/$(1),$(1))
102         $(call Image/Build/Profile/$(PROFILE),$(1))
103         
104         dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/openwrt-$(BOARD)-root.$(1) bs=128k conv=sync
105 endef
106
107 $(eval $(call BuildImage))