This is the script I use to create the firmware with the original inventel partitions.
#!/bin/bash
mod=../
dd if=$mod/user_fs.squashfs of=user_fs.squashfs bs=65536 conv=sync
dd if=$mod/user_2_fs.squashfs of=user_2_fs.squashfs bs=65536 conv=sync
gzip -9 -c $mod/Image > vmlinux.bin.gz
dd if=vmlinux.bin.gz of=vmlinux.gz bs=65536 conv=sync
rm vmlinux.bin.gz
userlength=`ls -l user_fs.squashfs |awk '{printf("%x\n",$5)}'`
user_2fladdr=`printf '%x\n' $[0xBE430000+0x00$userlength]`
user_2length=`ls -l user_2_fs.squashfs |awk '{printf("%x\n",$5)}'`
vmlinuxaddr=`printf '%x\n' $[0x$user_2fladdr+0x00$user_2length]`
vmlinuxleng=`ls -l vmlinux.gz |awk '{printf("%x\n",$5)}'`
jffs2addr=`printf '%x\n' $[0x$vmlinuxaddr+0x00$vmlinuxleng]`
jffs2leng=`printf '%x\n' $[0xBEBF0000-0x00$jffs2addr]`
offset2=`printf '%x\n' $[0x1000+0x$userlength]`
offset3=`printf '%x\n' $[0x1000+0x$userlength+0x$user_2length]`
echo "fis init -f
fconfig boot_script true
fconfig boot_script_data
fis load -b 0x80010000 -d vmlinux
exec -c \"boot_loader=RedBoot root=1F01 mem=16M\" 0x80010000
fconfig boot_script_timeout 20
fis create -f 0x$jffs2addr -r 0x$jffs2addr -l 0x00$jffs2leng -n jffs_system
fis create -o 0x1000 -f 0xBE430000 -l 0x00$userlength user_fs
fis create -o 0x$offset2 -f 0x$user_2fladdr -l 0x00$user_2length user_2_fs
fis create -o 0x$offset3 -f 0x$vmlinuxaddr -l 0x00$vmlinuxleng vmlinux
reset" > redbootscript.tmp
dd if=redbootscript.tmp of=redbootscriptpad.tmp bs=4096 conv=sync
cat redbootscriptpad.tmp user_fs.squashfs user_2_fs.squashfs vmlinux.gz > factory_script
rm redbootscriptpad.tmp redbootscript.tmp user_fs.squashfs user_2_fs.squashfs vmlinux.gz
Note the kernel is extracted from one of those partitions, also it is needed to remove some security checks in the latest firmwares. For older firmwares using a cramfs partition this is not needed, and the script should be a little different.
(Last edited by danitool on 24 Nov 2011, 10:34)