2 # Copyright (C) 2013 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9 include $(INCLUDE_DIR)/host.mk
12 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_SUNXI_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
15 sun4i-a10-cubieboard \
16 sun4i-a10-olinuxino-lime \
23 sun7i-a20-cubieboard2 \
24 sun7i-a20-cubietruck \
25 sun7i-a20-olinuxino-lime \
26 sun7i-a20-olinuxino-micro \
30 define Image/BuildKernel
31 mkimage -A arm -O linux -T kernel -C none \
32 -a 0x40008000 -e 0x40008000 \
33 -n 'ARM OpenWrt Linux-$(LINUX_VERSION)' \
34 -d $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-uImage
36 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
37 $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
38 echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
39 $(call Image/BuildKernel/MkuImage, \
40 none, 0x40008000, 0x40008000, \
41 $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
42 $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
46 $(foreach board,$(BOARDS),
47 $(CP) $(DTS_DIR)/$(board).dtb $(BIN_DIR)/
51 define Image/Build/SDCard
52 rm -f $(KDIR)/boot.img
53 mkdosfs $(KDIR)/boot.img -C $(FAT32_BLOCKS)
55 mcopy -i $(KDIR)/boot.img $(BIN_DIR)/uboot-sunxi-$(PROFILE)/openwrt-sunxi-$(PROFILE)-boot.scr ::boot.scr
56 mcopy -i $(KDIR)/boot.img $(BIN_DIR)/$(2).dtb ::dtb
57 mcopy -i $(KDIR)/boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
59 ./gen_sunxi_sdcard_img.sh \
60 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
63 $(CONFIG_SUNXI_SD_BOOT_PARTSIZE) \
64 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
65 $(BIN_DIR)/uboot-sunxi-$(PROFILE)/openwrt-sunxi-$(PROFILE)-u-boot-with-spl.bin
68 define Image/Build/Profile/A10-OLinuXino-Lime
69 $(call Image/Build/SDCard,$(1),sun4i-a10-olinuxino-lime)
72 define Image/Build/Profile/A13-OLinuXino
73 $(call Image/Build/SDCard,$(1),sun5i-a13-olinuxino)
76 define Image/Build/Profile/A20-OLinuXino_Lime
77 $(call Image/Build/SDCard,$(1),sun7i-a20-olinuxino-lime)
80 define Image/Build/Profile/A20-OLinuXino_MICRO
81 $(call Image/Build/SDCard,$(1),sun7i-a20-olinuxino-micro)
84 define Image/Build/Profile/Bananapi
85 $(call Image/Build/SDCard,$(1),sun7i-a20-bananapi)
88 define Image/Build/Profile/Bananapro
89 $(call Image/Build/SDCard,$(1),sun7i-a20-bananapro)
92 define Image/Build/Profile/Lamobo_R1
93 $(call Image/Build/SDCard,$(1),sun7i-a20-lamobo-r1)
96 define Image/Build/Profile/Cubieboard
97 $(call Image/Build/SDCard,$(1),sun4i-a10-cubieboard)
100 define Image/Build/Profile/Cubieboard2
101 $(call Image/Build/SDCard,$(1),sun7i-a20-cubieboard2)
104 define Image/Build/Profile/Cubietruck
105 $(call Image/Build/SDCard,$(1),sun7i-a20-cubietruck)
108 define Image/Build/Profile/OLIMEX_A13_SOM
109 $(call Image/Build/SDCard,$(1),sun5i-a13-olinuxino)
112 define Image/Build/Profile/Mele_M9
113 $(call Image/Build/SDCard,$(1),sun6i-a31-hummingbird)
116 define Image/Build/Profile/Linksprite_pcDuino
117 $(call Image/Build/SDCard,$(1),sun4i-a10-pcduino)
120 define Image/Build/Profile/Linksprite_pcDuino3
121 $(call Image/Build/SDCard,$(1),sun7i-a20-pcduino3)
125 $(call Image/Build/$(1),$(1))
126 $(call Image/Build/Profile/$(PROFILE),$(1))
128 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/openwrt-$(BOARD)-root.$(1) bs=128k conv=sync
131 $(eval $(call BuildImage))