cns21xx: add initial support for the Cavium CNS21xx SoC
[openwrt.git] / target / linux / cns21xx / image / Makefile
1 #
2 # Copyright (C) 2010 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
9 JFFS2_BLOCKSIZE:=64k
10
11 include $(INCLUDE_DIR)/image.mk
12
13 INITRAMFS_SUFFIX:=
14
15 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
16 INITRAMFS_SUFFIX:=-initramfs
17 endif
18
19 define zimage_name
20 $(IMG_PREFIX)-$(1)-zImage$(INITRAMFS_SUFFIX)
21 endef
22
23 define uimage_name
24 $(IMG_PREFIX)-$(1)-uImage$(INITRAMFS_SUFFIX)
25 endef
26
27 define imgname
28 $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
29 endef
30
31 define rootfsname
32 $(BIN_DIR)/$(IMG_PREFIX)-$(2)-root.$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
33 endef
34
35 define build_squashfs
36 dd if=$(KDIR)/root.squashfs of=$(KDIR)/root.squashfs-$(1) bs=$(1) conv=sync
37 $(call add_jffs2_mark,$(KDIR)/root.squashfs-$(1))
38 dd if=$(KDIR)/root.squashfs-$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.squashfs-$(1) bs=$(1) conv=sync
39 endef
40
41 define prepare_zimage
42 echo -en "\x$(2)\x1c\xa0\xe3\x$(3)\x10\x81\xe3" > $(KDIR)/$(call zimage_name,$(1))
43 cat $(LINUX_DIR)/arch/arm/boot/zImage >> $(KDIR)/$(call zimage_name,$(1))
44 endef
45
46 define prepare_uimage
47 $(call prepare_zimage,$(1),$(2),$(3))
48 mkimage -A arm -O linux -T kernel -a 0x100000 -e 0x100000 -C none \
49 -n 'OpenWrt Linux-$(LINUX_VERSION)' \
50 -d $(KDIR)/$(call zimage_name,$(1)) \
51 $(KDIR)/$(call uimage_name,$(1))
52 endef
53
54 define Image/Prepare
55 # NSB3AST : mach id 2917 (0xb65)
56 $(call prepare_zimage,nsb3ast,0b,65)
57 # NS-K330 : mach id 3108 (0xc24)
58 $(call prepare_zimage,ns-k330,0c,24)
59 endef
60
61 define Image/BuildKernel
62 cat $(KDIR)/$(call zimage_name,nsb3ast) > $(BIN_DIR)/$(call zimage_name,nsb3ast)
63 cat $(KDIR)/$(call zimage_name,ns-k330) > $(BIN_DIR)/$(call zimage_name,ns-k330)
64 endef
65
66 define Image/Build/Generic
67 if [ `stat -c%s "$(KDIR)/$(call zimage_name,$(2))"` -gt 1048576 ]; then \
68 echo "Warning: $(KDIR)/$(call zimage_name,$(2)) is too big"; \
69 else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(3) ]; then \
70 echo "Warning: of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) is too big"; \
71 else \
72 cat $(KDIR)/root.$(1) > $(call rootfsname,$(1),$(2)); \
73 ( \
74 dd if=$(KDIR)/$(call zimage_name,$(2)) bs=1024k conv=sync; \
75 dd if=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
76 ) > $(call imgname,$(1),$(2)).img; \
77 fi; fi
78 endef
79
80 define Image/Build/uImage
81 if [ `stat -c%s "$(KDIR)/$(call uimage_name,$(2))"` -gt 1048576 ]; then \
82 echo "Warning: $(KDIR)/$(call uimage_name,$(2)) is too big"; \
83 else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(3) ]; then \
84 echo "Warning: of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) is too big"; \
85 else \
86 cat $(KDIR)/root.$(1) > $(call rootfsname,$(1),$(2)); \
87 ( \
88 dd if=$(KDIR)/$(call uimage_name,$(2)) bs=1024k conv=sync; \
89 dd if=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
90 ) > $(call imgname,$(1),$(2))-uImage.img; \
91 fi; fi
92 endef
93
94 define Image/Build/NSB3AST
95 $(call Image/Build/Generic,$(1),nsb3ast,7077888)
96 endef
97
98 define Image/Build/NSK330
99 $(call Image/Build/Generic,$(1),ns-k330,2686976)
100 endef
101
102 define Image/Build/squashfs
103 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
104
105 $(call build_squashfs,64k)
106 $(call Image/Build/NSB3AST,squashfs-64k)
107 $(call Image/Build/NSK330,squashfs-64k)
108 endef
109
110 define Image/Build/jffs2-64k
111 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=64k conv=sync
112 endef
113
114 define Image/Build
115 $(call Image/Build/$(1),$(1))
116 endef
117
118 $(eval $(call BuildImage))
This page took 0.061068 seconds and 5 git commands to generate.