@ -1,5 +1,5 @@
#
# Copyright (C) 2008-2011 OpenWrt.org
# Copyright (C) 2008-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@ -12,91 +12,207 @@
### use round brackets for make variables, and curly brackets for shell variables
## Kernel mtd partition size in KiB
KERNEL_MTD_SIZE := 1024
# Netgear WNR854T: erase size is 128KiB = 0x00020000 = 131072
ERASE_SIZE_WNR854T := 128
UIMAGE_FILE_NAME_WNR854T := uImage
# Linksys WRT350N v2: erase size is 64KiB = 0x00010000 = 65536
ERASE_SIZE_WRT350Nv2 := 64
# define JFFS2 sizes for include/image.mk
JFFS2_BLOCKSIZE := 64k 128k
###
### Image/Prepare
###
d e f i n e I m a g e / P r e p a r e
### Dummy comment for indented calls of Image/Prepare
cp $( LINUX_DIR) /arch/arm/boot/uImage $( KDIR) /uImage
cp '$(LINUX_DIR)/arch/arm/boot/zImage' '$(BIN_DIR)/$(IMG_PREFIX)-zImage'
e n d e f
###
### Image/BuildKernel
###
d e f i n e I m a g e / B u i l d K e r n e l
### Dummy comment for indented calls of Image/BuildKernel
# Orion Kernel uImages
# WRT350N v2: mach id 1633 (0x661)
echo -en "\x06\x1c\xa0\xe3\x61\x10\x81\xe3" > $( KDIR) /wrt350nv2-zImage
cat $( LINUX_DIR) /arch/arm/boot/zImage >> $( KDIR) /wrt350nv2-zImage
$( STAGING_DIR_HOST) /bin/mkimage -A arm -O linux -T kernel \
-C none -a 0x00008000 -e 0x00008000 -n 'Linux-$(LINUX_VERSION)' \
-d $( KDIR) /wrt350nv2-zImage $( KDIR) /wrt350nv2-uImage
cp $( KDIR) /wrt350nv2-uImage $( BIN_DIR) /openwrt-wrt350nv2-uImage
# WNR854T: mach id 1801 (0x709)
echo -en "\x07\x1c\xa0\xe3\x09\x10\x81\xe3" > $( KDIR) /wnr854t-zImage
cat $( LINUX_DIR) /arch/arm/boot/zImage >> $( KDIR) /wnr854t-zImage
$( STAGING_DIR_HOST) /bin/mkimage -A arm -O linux -T kernel \
## Netgear WNR854T: mach id 1801 (0x0709)
$( call Image /BuildKernel /ARM /zImage ,wnr 854t ,"\x 07\x 1c \xa 0\xe 3\x 09\x 10\x 81\xe 3")
$( call Image /BuildKernel /ARM /uImage ,wnr 854t )
ifneq ( $( CONFIG_TARGET_ROOTFS_INITRAMFS) ,y) # nothing more to do for a ramdisk build
$( call Image /BuildKernel /JFFS 2uImage ,wnr 854t ,$ ( ERASE_SIZE_WNR 854T ) ,$ ( UIMAGE_FILE_NAME_WNR 854T ) )
$( call Image /Default /FileSizeCheck ,$ ( KDIR ) /wnr 854t -uImage .jffs 2,$ ( shell expr $ ( KERNEL_MTD_SIZE ) \* 1024) )
endif
## Linksys WRT350N v2: mach id 1633 (0x0661)
$( call Image /BuildKernel /ARM /zImage ,wrt 350nv 2,"\x 06\x 1c \xa 0\xe 3\x 61\x 10\x 81\xe 3")
$( call Image /BuildKernel /ARM /uImage ,wrt 350nv 2)
ifneq ( $( CONFIG_TARGET_ROOTFS_INITRAMFS) ,y) # nothing more to do for a ramdisk build
$( call Image /Default /FileSizeCheck ,$ ( KDIR ) /wrt 350nv 2-uImage ,$ ( shell expr $ ( KERNEL_MTD_SIZE ) \* 1024) )
endif
e n d e f
d e f i n e I m a g e / B u i l d K e r n e l / A R M / z I m a g e
# merge machine id and regular zImage into one file
# parameters: 1 = machine name, 2 = machine id as string in quotes
# $(BOARD) kernel zImage for $(1)
echo -en $( 2) > '$(KDIR)/$(1)-zImage'
cat '$(LINUX_DIR)/arch/arm/boot/zImage' >> '$(KDIR)/$(1)-zImage'
cp '$(KDIR)/$(1)-zImage' '$(BIN_DIR)/openwrt-$(1)-zImage'
e n d e f
d e f i n e I m a g e / B u i l d K e r n e l / A R M / u I m a g e
# create uImage from zImage
# parameters: 1 = machine name
# $(BOARD) kernel uImage for $(1)
'$(STAGING_DIR_HOST)/bin/mkimage' -A arm -O linux -T kernel \
-C none -a 0x00008000 -e 0x00008000 -n 'Linux-$(LINUX_VERSION)' \
-d $( KDIR) /wnr854t-zImage $( KDIR) /wnr854t-uImage
cp $( KDIR) /wnr854t-uImage $( BIN_DIR) /openwrt-wnr854t-uImage
-d '$(KDIR)/$(1)-zImage' '$(KDIR)/$(1)-uImage'
cp '$(KDIR)/$(1)-uImage' '$(BIN_DIR)/openwrt-$(1)-uImage'
e n d e f
d e f i n e I m a g e / B u i l d / N e t g e a r
# Orion Netgear Images
mkdir $( KDIR) /netgear_image
cp $( KDIR) /wnr854t-uImage $( KDIR) /netgear_image/uImage
$( STAGING_DIR_HOST) /bin/mkfs.jffs2 -m none -p -l -q -e 128KiB -o $( KDIR) /wnr854t-uImage.jffs2 -d $( KDIR) /netgear_image
rm -rf $( KDIR) /netgear_image
( \
dd if = $( KDIR) /wnr854t-uImage.jffs2 bs = 1024k conv = sync; \
dd if = $( KDIR) /root.$( 1) bs = 128k conv = sync; \
) > $( BIN_DIR) /openwrt-$( 2) -$( 1) .img
$( STAGING_DIR_HOST) /bin/add_header $( 3) $( BIN_DIR) /openwrt-$( 2) -$( 1) .img $( BIN_DIR) /openwrt-$( 2) -$( 1) -webupgrade.img
d e f i n e I m a g e / B u i l d K e r n e l / J F F S 2 u I m a g e
# create JFFS2 partition with uImage file (result is already padded to erase size)
# parameters: 1 = machine name, 2 = erase size in KiB, 3 = uImage file name
# $(BOARD) kernel uImage for $(1) in JFFS2-$(2)k partition
rm -rf '$(TMP_DIR)/$(1)_jffs2_uimage'
mkdir '$(TMP_DIR)/$(1)_jffs2_uimage'
cp '$(KDIR)/$(1)-uImage' '$(TMP_DIR)/$(1)_jffs2_uimage/$(3)'
$( STAGING_DIR_HOST) /bin/mkfs.jffs2 --compression-mode= none --pad --little-endian --squash -e $( 2) KiB -o '$(KDIR)/$(1)-uImage.jffs2' -d '$(TMP_DIR)/$(1)_jffs2_uimage'
rm -rf '$(TMP_DIR)/$(1)_jffs2_uimage'
e n d e f
d e f i n e I m a g e / B u i l d / L i n k s y s
# Orion Linksys Images
# sysupgrade image
( \
dd if = " ${ KDIR } / $2 -uImage " bs = $5 conv = sync; \
dd if = " ${ KDIR } /root. $1 " bs = 64k conv = sync; \
) > " ${ BIN_DIR } /openwrt- $2 - $1 .img "
# recovery image and webupgrade image for stock firmware
rm -rf " ${ TMP_DIR } / $2 _webupgrade "
mkdir " ${ TMP_DIR } / $2 _webupgrade "
# create parameter file
echo ':image 0 $(BIN_DIR)/openwrt-$(2)-$(1).img' >'$(TMP_DIR)/$(2)_webupgrade/$(2).par'
[ ! -f " $( STAGING_DIR_HOST) /share/wrt350nv2-builder/u-boot.bin " ] || ( \
echo " :u-boot 0 $( STAGING_DIR_HOST) /share/wrt350nv2-builder/u-boot.bin " >>" ${ TMP_DIR } / $2 _webupgrade/ $2 .par " ; )
echo "#version 0x2020" >>" ${ TMP_DIR } / $2 _webupgrade/ $2 .par "
# create bin file for recovery and webupgrade image
( cd " ${ TMP_DIR } / $2 _webupgrade " ; \
" ${ STAGING_DIR_HOST } /bin/wrt350nv2-builder " \
-v -b " ${ TMP_DIR } / $2 _webupgrade/ $2 .par " ; \
)
# copy bin file as recovery image
$( CP) " ${ TMP_DIR } / $2 _webupgrade/wrt350n.bin " " $( BIN_DIR) /openwrt- $2 - $1 -recovery.bin "
# create webupgrade image for stock firmware update mechanism
( cd '$(TMP_DIR)/$(2)_webupgrade' ; \
zip 'wrt350n.zip' 'wrt350n.bin' ; \
)
" ${ STAGING_DIR_HOST } /bin/wrt350nv2-builder " -v -z " ${ TMP_DIR } / $2 _webupgrade/wrt350n.zip " " ${ BIN_DIR } /openwrt- $2 - $1 -webupgrade.img "
rm -rf " ${ TMP_DIR } / $2 _webupgrade "
d e f i n e I m a g e / D e f a u l t / F i l e S i z e C h e c k
# parameters: 1 = file path, 2 = maximum size in bytes
[ ` stat -c %s '$(1)' ` -le $( 2) ] || { echo ' ERROR: $(1) too big (> $(2) bytes)' ; exit 1; }
e n d e f
###
### Image/Build
###
d e f i n e I m a g e / B u i l d
### Dummy comment for indented calls of Image/Build with $(1)
## Prepare rootfs
$( call Image /Build /$ ( 1) ,$ ( 1) )
$( call Image /Build /Netgear ,$ ( 1) ,wnr 854t ,NG_WNR 854T ,$ ( 1) )
# Leave WRT350Nv2 at last position due to webimage dependency for zip
# 5th parameter is kernel mtd size, e.g. 0x00100000 = 1048576 or 0x001A0000 = 1703936
$( call Image /Build /Linksys ,$ ( 1) ,wrt 350nv 2,WNR 350Nv 2,$ ( 1) ,1048576)
## Netgear WNR854T
$( call Image /Build /Default ,$ ( 1) ,wnr 854t ,$ ( ERASE_SIZE_WNR 854T ) ,$ ( KERNEL_MTD_SIZE ) ,.jffs 2,NG_WNR 854T )
## Linksys WRT350N v2
$( call Image /Build /Linksys /wrt 350nv 2,$ ( 1) ,wrt 350nv 2,$ ( ERASE_SIZE_WRT 350Nv 2) ,$ ( KERNEL_MTD_SIZE ) ,)
e n d e f
d e f i n e I m a g e / B u i l d / s q u a s h f s
$( call prepare_generic_squashfs ,$ ( KDIR ) /root .squashfs )
cp '$(KDIR)/root.squashfs' '$(BIN_DIR)/$(IMG_PREFIX)-root.squashfs'
e n d e f
## generate defines for all JFFS2 block sizes
d e f i n e I m a g e / B u i l d / j f f s 2 / s u b
$( eval define Image/Build/jffs2-$( 1)
cp '$$(KDIR)/root.jffs2-$(1)' '$$(BIN_DIR)/$$(IMG_PREFIX)-root.jffs2-$(1)'
endef)
e n d e f
$( foreach SZ ,$ ( JFFS 2_BLOCKSIZE ) ,$ ( call Image /Build /jffs 2/sub ,$ ( SZ ) ) )
d e f i n e I m a g e / B u i l d / D e f a u l t
# parameters: 1 = rootfs type, 2 = machine name, 3 = erase size in KiB, 4 = kernel mtd size in KiB, 5 = kernel file suffix, 6 = header
ifeq ( $( findstring jffs2-,$( 1) ) ,jffs2-) # JFFS2: build only image fitting to erase size
ifeq ( $( 1) ,jffs2-$( 3) k)
$( call Image /Build /Default /sysupgrade ,$ ( 1) ,$ ( 2) ,$ ( 4) ,$ ( 5) )
$( call Image /Build /Default /factory ,$ ( 1) ,$ ( 2) ,$ ( 6) )
endif
else
ifeq ( $( 1) ,ext4) # EXT4: ignore
# do nothing
else # do all other images
$( call Image /Build /Default /sysupgrade ,$ ( 1) ,$ ( 2) ,$ ( 4) ,$ ( 5) )
$( call Image /Build /Default /factory ,$ ( 1) ,$ ( 2) ,$ ( 6) )
endif
endif
e n d e f
d e f i n e I m a g e / B u i l d / D e f a u l t / s y s u p g r a d e
# parameters: 1 = rootfs type, 2 = machine name, 3 = pad size in KiB (kernel mtd size or erase size), 4 = kernel file suffix
# $(BOARD) $(1) sysupgrade image for $(2)
( \
dd if = '$(KDIR)/$(2)-uImage$(4)' bs = $( 3) k conv = sync; \
dd if = '$(KDIR)/root.$(1)' ; \
) > '$(BIN_DIR)/openwrt-$(2)-$(1)-sysupgrade.img'
e n d e f
d e f i n e I m a g e / B u i l d / D e f a u l t / f a c t o r y
# parameters: 1 = rootfs type, 2 = machine name, 3 = header
# $(BOARD) $(1) factory upgrade image for $(2)
'$(STAGING_DIR_HOST)/bin/add_header' $( 3) '$(BIN_DIR)/openwrt-$(2)-$(1)-sysupgrade.img' '$(BIN_DIR)/openwrt-$(2)-$(1)-factory.img'
e n d e f
##
## Image/Build/Linksys
##
d e f i n e I m a g e / B u i l d / L i n k s y s / w r t 3 5 0 n v 2
# parameters: 1 = rootfs type, 2 = machine name, 3 = erase size in KiB, 4 = kernel mtd size in KiB, 5 = kernel file suffix
ifeq ( $( findstring jffs2-,$( 1) ) ,jffs2-) # JFFS2: build only image fitting to erase size
ifeq ( $( 1) ,jffs2-$( 3) k)
$( call Image /Build /Default /sysupgrade ,$ ( 1) ,$ ( 2) ,$ ( 4) ,$ ( 5) )
$( call Image /Build /Linksys /wrt 350nv 2-builder ,$ ( 1) ,$ ( 2) )
endif
else
ifeq ( $( 1) ,ext4) # EXT4: ignore
# do nothing
else # do all other images
$( call Image /Build /Default /sysupgrade ,$ ( 1) ,$ ( 2) ,$ ( 4) ,$ ( 5) )
$( call Image /Build /Linksys /wrt 350nv 2-builder ,$ ( 1) ,$ ( 2) )
endif
endif
e n d e f
d e f i n e I m a g e / B u i l d / L i n k s y s / w r t 3 5 0 n v 2 - b u i l d e r
# parameters: 1 = rootfs type, 2 = machine name
# $(BOARD) $(1) factory and recovery image for $(2) via wrt350nv2-builder
rm -rf '$(TMP_DIR)/$(2)_factory'
mkdir '$(TMP_DIR)/$(2)_factory'
# create parameter file
echo ':image 0 $(BIN_DIR)/openwrt-$(2)-$(1)-sysupgrade.img' > '$(TMP_DIR)/$(2)_factory/$(2).par'
[ ! -f '$(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin' ] || ( \
echo ':u-boot 0 $(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin' >> '$(TMP_DIR)/$(2)_factory/$(2).par' ; \
)
echo '#version 0x2020' >> '$(TMP_DIR)/$(2)_factory/$(2).par'
# create bin file for recovery and factory image
( \
dd if = $( KDIR) /uImage bs = 1024k conv = sync; \
dd if = $( KDIR) /root.$( 1) bs = 128k conv = sync; \
) > $( BIN_DIR) /$( IMG_PREFIX) -$( 1) .img
cd '$(TMP_DIR)/$(2)_factory' ; \
'$(STAGING_DIR_HOST)/bin/wrt350nv2-builder' -b '$(TMP_DIR)/$(2)_factory/$(2).par' ; \
)
# copy bin file as recovery image
$( CP) '$(TMP_DIR)/$(2)_factory/wrt350n.bin' '$(BIN_DIR)/openwrt-$(2)-$(1)-recovery.bin'
# create factory image for stock firmware update mechanism
( \
cd '$(TMP_DIR)/$(2)_factory' ; \
zip 'wrt350n.zip' 'wrt350n.bin' ; \
)
'$(STAGING_DIR_HOST)/bin/wrt350nv2-builder' -z '$(TMP_DIR)/$(2)_factory/wrt350n.zip' '$(BIN_DIR)/openwrt-$(2)-$(1)-factory.img'
rm -rf '$(TMP_DIR)/$(2)_factory'
e n d e f
# Dependency for WRT350N v2 webupgrade image
###
### Image/PreReq
###
## Dependency for WRT350N v2 factory image
$( eval $ ( call RequireCommand ,zip , \
Please install zip. \
) )