2 # Copyright (C) 2008-2010 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
10 IMGNAME
:=$(BIN_DIR
)/openwrt-
$(BOARD
)
13 $(IMGNAME
)-$(2)-$(patsubst jffs2-
%,jffs2
,$(patsubst squashfs-
%,squashfs
,$(1)))
16 VMLINUX
:=$(IMGNAME
)-vmlinux
17 UIMAGE
:=$(IMGNAME
)-uImage
18 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
19 VMLINUX
:=$(IMGNAME
)-vmlinux-initramfs
20 UIMAGE
:=$(IMGNAME
)-uImage-initramfs
23 ifeq ($(CONFIG_RALINK_RT305X
),y
)
25 -a
0x80000000 -e
0x80000000
29 -a
0x88000000 -e
0x88000000
34 $(STAGING_DIR_HOST
)/bin
/lzma e
$(1) -lc1
-lp2
-pb2
$(2)
37 define PatchKernelLzma
38 cp
$(KDIR
)/vmlinux
$(KDIR
)/vmlinux-
$(1)
39 $(STAGING_DIR_HOST
)/bin
/patch-cmdline
$(KDIR
)/vmlinux-
$(1) '$(strip $(2))'
40 $(call CompressLzma
,$(KDIR
)/vmlinux-
$(1),$(KDIR
)/vmlinux-
$(1).bin.lzma
)
44 mkimage
-A mips
-O linux
-T kernel
-C
$(1) $(call kernel_entry
)\
45 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
49 define Image
/BuildKernel
50 cp
$(KDIR
)/vmlinux.elf
$(VMLINUX
).elf
51 cp
$(KDIR
)/vmlinux
$(VMLINUX
).bin
52 $(call CompressLzma
,$(KDIR
)/vmlinux
,$(KDIR
)/vmlinux.bin.lzma
)
53 $(call MkImage
,lzma
,$(KDIR
)/vmlinux.bin.lzma
,$(KDIR
)/uImage.lzma
)
54 cp
$(KDIR
)/uImage.lzma
$(UIMAGE
).bin
57 define BuildFirmware
/Generic
58 $(call PatchKernelLzma
,$(2),$(3) $($(4)))
59 if
[ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt
$(5) ]; then \
60 echo
"Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
61 else if
[ `stat -c%s $(KDIR)/root.$(1)` -gt
$(6) ]; then \
62 echo
"Warning: $(KDIR)/root.$(1) is too big"; \
64 mkimage
-A mips
-O linux
-T kernel
-C lzma \
65 $(call kernel_entry
) \
66 -n
'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
67 -d
$(KDIR
)/vmlinux-
$(2).bin.lzma
$(KDIR
)/vmlinux-
$(2).uImage
; \
69 dd if
=$(KDIR
)/vmlinux-
$(2).uImage bs
=$(5) conv
=sync
; \
70 dd if
=$(KDIR
)/root.
$(1) bs
=64k conv
=sync
; \
71 ) > $(call imgname
,$(1),$(2))-sysupgrade.bin
; \
75 mtdlayout_4M
=mtdparts
=physmap-flash
.0:192k
(u-boot
)ro
,64k
(u-boot-env
)ro
,64k
(factory
)ro
,832k
(kernel
),2944k
(rootfs
),3776k@
0x50000(firmware
)
76 define Image
/Build
/Template
/GENERIC_4M
77 $(call BuildFirmware
/Generic
,$(1),$(2),board
=$(3),mtdlayout_4M
,851968,3014656)
80 mtdlayout_8M
=mtdparts
=physmap-flash
.0:192k
(u-boot
)ro
,64k
(u-boot-env
)ro
,64k
(factory
)ro
,832k
(kernel
),7040k
(rootfs
),7872k@
0x50000(firmware
)
81 define Image
/Build
/Template
/GENERIC_8M
82 $(call BuildFirmware
/Generic
,$(1),$(2),board
=$(3),mtdlayout_8M
,851968,7208960)
85 define Image
/Build
/Profile
/DIR300B1
86 $(call Image
/Build
/Template
/GENERIC_4M
,$(1),dir-300-b1
,DIR-300-revB
)
89 define Image
/Build
/Profile
/FONERA20N
90 $(call Image
/Build
/Template
/GENERIC_8M
,$(1),fonera20n
,FONERA20N
)
93 define Image
/Build
/Profile
/V22RW2X2
94 $(call Image
/Build
/Template
/GENERIC_4M
,$(1),v22rw-2x2
,V22RW-2X2
)
97 define Image
/Build
/Profile
/WHRG300N
98 $(call Image
/Build
/Template
/GENERIC_4M
,$(1),whr-g300n
,WHR-G300N
)
101 ifeq ($(CONFIG_RALINK_RT305X
),y
)
102 define Image
/Build
/Profile
/Default
103 $(call Image
/Build
/Profile
/DIR300B1
,$(1))
104 $(call Image
/Build
/Profile
/FONERA20N
,$(1))
105 $(call Image
/Build
/Profile
/V22RW2X2
,$(1))
106 $(call Image
/Build
/Profile
/WHRG300N
,$(1))
110 define Image
/Build
/squashfs
111 $(call prepare_generic_squashfs
,$(KDIR
)/root.squashfs
)
115 $(call Image
/Build
/$(1))
116 dd if
=$(KDIR
)/root.
$(1) of
=$(IMGNAME
)-root.
$(1) bs
=128k conv
=sync
117 $(call Image
/Build
/Profile
/$(PROFILE
),$(1))
120 $(eval
$(call BuildImage
))