#!/bin/bash # (C) 2003-2007 Willem Jan Hengeveld # Web: http://www.xs4all.nl/~itsme/ # http://wiki.xda-developers.com/ # # $Id: mkrom.sh 1502 2007-04-15 07:54:20Z itsme $ # # this is a sample script how to create your own windowsce/pocketpc rom # this script was once developed for the htc wallaby, running pocketpc-2002, # it probably requires major adjustments to make it work for newer devices #. ../../kitchen.local/mkrom-inc.sh target_name=$1 case "$target_name" in *.nb1.zip | *.nb1) out_type=nb1 ;; *.nbf.zip | *.nbf | *.exe) out_type=nbf ;; *) echo "unknown target type" && exit 1 ;; esac mkdir out tmp cfg 2>/dev/null case $OSTYPE in linux-gnu) tounicode=./tounicode ;; cygwin) tounicode=./tounicode.exe ;; *) echo Warning: OS type not detected, you may need to set tounicode variable manually tounicode=./tounicode ;; esac out_basename=out/xdaromimg op_basename=tmp/xdaopimg xda1_basename=tmp/xda1 xda2_basename=tmp/xda2 chain_basename=tmp/xipchain # number roms sequentially last=`ls $chain_basename-[0-9]* 2>/dev/null |sort -t- -n +1 |tail -1|cut -sd- -f2` xda1_name=$xda1_basename-$[$last+1].bin xda2_name=$xda2_basename-$[$last+1].bin chain_name=$chain_basename-$[$last+1] out_name=$out_basename-$[$last+1].$out_type op_name=$op_basename-$[$last+1] splash_name=cfg/bootimage.bmp templatechain_name=cfg/xipchain bootloader_name=cfg/bootloader.nb0 rom_name=cfg/rom.nb1 romopts= wincever=3 start1=81800000 size1=00100000 start2=81940000 size2=00500000 startbmp=81900000 startop=81940000 # these values are for 4.x roms: #wincever=4 #start1=81740000 #size1=00040000 #start2=81b00000 #size2=003c0000 #startbmp=81ec0000 #startop=81b00000 # warning: make sure this file does not have CRLF inside it. if [[ -e cfg/params ]]; then . cfg/params fi if [[ ! -e $rom_name || ! -e $bootloader_name || ! -e $splash_name || ! -e $templatechain_name ]]; then echo "rom, bootloader, splash or xipchain missing" exit 1 fi rm -rf files1 files2 modules1 modules2 mkdir files1 files2 modules1 modules2 # create bootup init files perl reg2fdf.pl -$wincever cfg/default.reg files/default.fdf \ || { echo Error creating fdf file && exit 1; } $tounicode cfg/initobj.txt files/initobj.dat cp cfg/initdb.ini files if [[ -e cfg/operator.cfg && -d operator ]]; then perl dir2opimg.pl ./cfg/operator.cfg ./operator $op_name \ || { echo Error creating operator image && exit 1; } romopts="$romopts -rm $op_name:0x$startop" start2=`perl -e "\\$os= -s q($op_name); printf(qq(%08lx), 0x$startop+(\\$os+0x3ffff)&~0x3ffff);"` else start2=$startop fi size2=`printf "%08lx" $[0x81f00000-0x$start2]` # moves files to files1 and files2 perl makefiles.pl ./files ./files1 0x$size1 ./files2 0x$size2 \ || { echo Error splitting files && exit 1; } perl makexip.pl $start1 ./files1 ./modules1 $xda1_name \ || { echo Error making xip section && exit 1; } romopts="$romopts -rm $xda1_name:0x$start1" perl makexip.pl $start2 ./files2 ./modules2 $xda2_name \ || { echo Error making xip section && exit 1; } romopts="$romopts -rm $xda2_name:0x${start2}" perl chainedit.pl load $templatechain_name add XDA_DEVELOPERS1:$start1,$size1 add XDA_DEVELOPERS2:$start2,$size2 save $chain_name \ || { echo Error editing xip chain && exit 1; } romopts="$romopts -rx $chain_name" # bootsplash romopts="$romopts -rb $splash_name -ob 0x$startbmp" # bootloader romopts="$romopts -rl $bootloader_name" if [[ $wincever == 4 ]]; then # this adss a special file relocation trick to get 4.x to recognise the new default.fdf etc. romopts="$romopts `perl drparse.pl $rom_name $xda1_name $xda2_name`" fi echo perl splitrom.pl $rom_name $romopts -wo $out_name -t $out_type -n PW10A1-ENG-3.16-007 \ || { echo Error creating new rom && exit 1; } case "$target_name" in *.nb1.zip | *.nbf.zip) finalname=`dirname $out_name`/`basename $target_name .zip` mv $out_name $finalname zip -j $target_name $finalname ;; *.nb1 | *.nbf) mv $out_name $target_name ;; *.exe) mkdir out/English 2>/dev/null mv $out_name out/English/NK.nbf ( cd out ; zip ../$target_name English/NK.nbf ) unzip -v $target_name rm -rf out/English ;; *) echo "unknown target type" && exit 1 ;; esac