raincoat flash script update

Here you can discuss things that are not directly related to running or using XBMC4XBOX.
Post Reply
User avatar
professor_jonny
Posts: 1298
Joined: Thu Jul 05, 2012 5:41 am
Location: New Zealand
Has thanked: 66 times
Been thanked: 196 times

raincoat flash script update

Post by professor_jonny »

So I just did a marathon task of tsop flashing 15 xboxes and some were ver 1.0 and some were winbond etc and i got P*** off with my damed cd drive not working and burning coasters and switching dvd's.

So I made up a script for raincoat from linux to flash multiple flash files selectable via emulated keyboard presses using xboxdrv and a game controller (including non microsoft ones.

I made the script init the xbox from a ram block loop device then read a user modifiable script off a fat x partition ignoring the execute bit.
the game controller also can be customised as it will read the config file of the fatx partition and you basically have the option to do any thing you want or extend it with out opening up the initrd block device.

So the code below is all three parts jammed together.

One would just need to get the package for xboxdrv and kill the xpad driver and build an image of their fav distro and then could have a customised shell based flash tool boot from an xbox partition and flash any thing with ease without ftp telnet or messing with bios files in the udata dir on e.

It is setup to load config files off of e:\ apps\flash folder

[update] it works now i just need to find a better distro to install it into as the current one i have is missing libusb, sudo, stat and a few other things i need as part of the script.


linuxrc script in root of package

Code: Select all

#!/bin/bash
# linuxrc startup script inital script to setup flash enviroment and 
# handle control over to second stage
#-----------------------------------------------------------------------------
# (c) Copyright 2002    Edgar Hucek <hostmaster@ed-soft.at>
#                       All Rights Reserved.
#
#                       http://xbox-linux.sourceforge.net
#
#       This program is free software; you can redistribute it and/or
#       modify it under the terms of the GNU General Public License
#       as published by the Free Software Foundation; either version
#       2 of the License, or (at your option) any later version.
#
#       Neither Edgar Hucek nor xbox-linux admit liability nor provide
#       warranty for any of this software. This material is provided
#       "AS-IS" and at no charge.
#
#       (c) Copyright 2002      Edgar Hucek <hostmaster@ed-soft.at>
#-----------------------------------------------------------------------------
#	  Modified by professor_jonny
#	  Dont email me I'm too busy :-)
# 
# 
#-----------------------------------------------------------------------------


# Output boot sequence to console
/bin/dmesg -n 1
# done


# Setup path
PATH=/bin:/sbin
export PATH
# done

# Setup user read write access
umask 022
#done

# Mount kernel and terminal 
mount -t proc none /proc
mount -t devpts none /dev/pts
echo 0x100 > /proc/sys/kernel/real-root-dev
#done

# Make folders for mountpoints
mkdir -p /cdrom /ram /proc /mnt/xbox
# done

# Setup constants for paths to make easy changes in future
XBOXMOUNTPATH=/mnt/xbox
MASTERHDDEPARTITION=/dev/discs/disc0/part50
FLASHAPPPATH=/mnt/xbox/apps/flash
# done

# Loading i2c modules for the XBox DVD-Rom for control of dvd from yellow cable
insmod i2c-core
insmod i2c-xbox
insmod i2c-proc
insmod i2c-dev
# done

# load in fat and fatx kernel modules
insmod fat
insmod fatx
# done

# Mount $MASTERHDDEPARTITION at $XBOXMOUNTPATH
mount -t fatx -o rw $MASTERHDDEPARTITION $XBOXMOUNTPATH
# done

# Now fatxfile system is loaded and mounted setup xboxdrv xbox game controller driver and
# load config from from $XBOXMOUNTPATH/$FLASHAPPPATH
sudo xboxdrv --silent --config $FLASHAPPPATH/game.cfg 
# done

# Force loading 2nd stage flash script from $XBOXMOUNTPATH/$FLASHAPPPATH/ 
# ignoring execute bit as we cant set it on a fatx partition
/bin/bash $FLASHAPPPATH/Flash.sh
# done


# end
Flash script stored of fatx

Code: Select all

#!/bin/bash
# second stage flash script to do the actual flashing and log file
# flash.sh setup file stored on xbox  @ $XBOXMOUNTPATH
#-----------------------------------------------------
# 
#
#
# (c) Copyright 2002    Professor_jonny 
#                       All Rights Reserved.
#
#                       http://www.xbmc4xbox.org.uk
#
#       This program is free software; you can redistribute it and/or
#       modify it under the terms of the GNU General Public License
#       as published by the Free Software Foundation.
#
#       This material is provided AS-IS" and at no charge if it
#	   makes your toaster catch fire dont blame me.
#
#       (c) Copyright 2002      
#-----------------------------------------------------
#
#



# Setup constants for paths to make easy changes in future
RELEASETITLE="MECHASSAULT RAINCOAT FLASH DISK MODDED BY PROFESSOR_JONNY"
XBOXMOUNTPATH=/mnt/xbox
FLASHAPPPATH=/mnt/xbox/apps/flash

# Setup constants for logic to make code more readable
FLASHED=0
DONE=1
ZEROCOND=0
DATE=`date`


LOGFILE=flash.log
ORGBIOSFILE=original_bios.bin
FLASHFILE0=256.bin
FLASHFILE1=512.bin
FLASHFILE2=1024.bin
FLASHFILESIZE0=262144
FLASHFILESIZE0=524288
FLASHFILESIZE0=1048576
FILESIZE0=1
FILESIZE1=1
FILESIZE2=1

# Check file sizes of flash files for peace of mind and ouput to screen.
# This could be extended to halt the xbox but ill give the user the ability
# to decide this.
echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo
echo "     $RELEASETITLE"
echo "     ======================================================="
echo "	flash file size check procedure."
echo

cd $FLASHAPPPATH
X=1
while [[ $x -le 3 ]] 
do
	FILENAME=$FLASHAPPPATH/$FLASHFILE$X
	FILESIZE=$(stat -c %s $FILENAME)
	
	echo "Size of $FILENAME = $FILESIZE bytes."
	
	if [[$x -eq 0]]
	then
		[[FILESIZE = $FILESIZE0]]
	fi
	if [[$x -eq 1]]
	then
		[[[FILESIZE = $FILESIZE1]] 
	fi
	if [[$x -eq 2]]
	then
		[[FILESIZE = $FILESIZE2]]
	fi
	x=$(($x+1))
done
#done

echo "-[ $RELEASETITLE started: $DATE ]-----" >>$LOGFILE
echo " " >>$LOGFILE

if $FILESIZE0=$FLASHFILESIZE0
then
	echo "     $FLASHFILE0 is correct" >>$LOGFILE
else
	echo "     $FLASHFILE0 is incorrect" >>$LOGFILE
fi
if $FILESIZE1=$FLASHFILESIZE1
then
	echo "     $FLASHFILE1 is correct" >>$LOGFILE
else
	echo "     $FLASHFILE1 is incorrect" >>$LOGFILE
fi
if $FILESIZE2=$FLASHFILESIZE2
then
	echo "     $FLASHFILE2 is correct" >>$LOGFILE
else
	echo "     $FLASHFILE2 is incorrect" >>$LOGFILE
fi


sleep 50



# Nice screen art
echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo
echo "     $RELEASETITLE based on raincoat 0.5"
echo "     ======================================================="
echo
echo "     Modified release by Professor_jonny."
echo
echo "     Check http://www.xbmc4xbox.org.uk for news and updates."
echo 
echo "     Press A to flash 256k bios"
echo      
echo "     Press X to flash 512k bios"
echo      
echo "     Press Y to flash 1024k bios"
echo      
echo "     Press B to shutdown with out flash or wait"
echo      
echo "                          !!!!WARNING!!!!!"
echo "     SELECT THE CORRECT ONE AND BE SURE THE BIOS IS THE CORRECT SIZE IN THE XBOX APP DIR"
echo      
echo "     --------------------------------------"
echo

# If no key is pressed with in 10 seconds shutdown console (in a nice way)
if read -n 1 -t 10 RESPONCE;
then
	echo "Great, you made it in time!"
	wait 5
else
	echo "Sorry, you are too slow in selecting an option and I will now shutdown!"
	wait 5
	sleep 50
	halt -n -f -p
fi

#-----------------------------------------------------
# user selected X Flash 256k bios
if $responce -eq X 
then
	# Flash procedure script
	cd $FLASHAPPPATH
	/bin/test -e $XBOXMOUNTPATH/$ORGBIOSFILE
	FILEEXIST=$?
	if /bin/test $FILEEXIST -ne $ZEROCOND
	then
		/bin/raincoat -r $XBOXMOUNTPATH/$ORGBIOSFILE -v >>$LOGFILE
		echo " " >>$LOGFILE
		echo "     Saved original bios..."
	fi
	/bin/raincoat -p $FLASHFILE0 -v >>$LOGFILE
	FLASHRTN=$?
	if /bin/test $FLASHRTN -eq $ZEROCOND
	then
		echo " " >>$LOGFILE
		echo "     Flashed ok..."
		echo "     Power off..."
		cd /
		sleep 15
		halt -n -f -p
	else	
		echo " " >>$LOGFILE
		echo "     Flashing failed, check $LOGFILE for result..."
		echo "     DVD tray eject..."
		cd /
		sleep 15
		eject.xbox.real
		while :
			do
				sleep 5
			done
	fi
fi





#-----------------------------------------------------
# user selected X Flash 512k bios
if $responce -eq X
then
	# Flash procedure script
	cd $FLASHAPPPATH
	/bin/test -e $XBOXMOUNTPATH/$ORGBIOSFILE
	FILEEXIST=$?
	if /bin/test $FILEEXIST -ne $ZEROCOND
	then
		/bin/raincoat -r $XBOXMOUNTPATH/$ORGBIOSFILE -v >>$LOGFILE
		echo " " >>$LOGFILE
		echo "     Saved original bios..."
	fi
	/bin/raincoat -p $FLASHFILE1 -v >>$LOGFILE
	FLASHRTN=$?
	if /bin/test $FLASHRTN -eq $ZEROCOND
	then
		echo " " >>$LOGFILE
		echo "     Flashed ok..."
		echo "     Power off..."
		cd /
		umount $XBOXMOUNTPATH
		sleep 15
		halt -n -f -p
	else	
		echo " " >>$LOGFILE
		echo "     Flashing failed, check $LOGFILE for result..."
		echo "     DVD tray eject..."
		cd /
		sleep 15
		eject.xbox.real
		while :
			do
				sleep 5
			done
	fi
fi




#-----------------------------------------------------
# user selected Y Flash 1024k bios
if $responce -eq Y
then
	# Flash procedure script
	cd $FLASHAPPPATH
	/bin/test -e $XBOXMOUNTPATH/$ORGBIOSFILE
	FILEEXIST=$?
	if /bin/test $FILEEXIST -ne $ZEROCOND
	then
		/bin/raincoat -r $XBOXMOUNTPATH/$ORGBIOSFILE -v >>$LOGFILE
		echo " " >>$LOGFILE
		echo "     Saved original bios..."
	fi
	/bin/raincoat -p $FLASHFILE2 -v >>$LOGFILE
	FLASHRTN=$?
	if /bin/test $FLASHRTN -eq $ZEROCOND
	then
		echo " " >>$LOGFILE
		echo "     Flashed ok..."
		echo "     Power off..."
		cd /
		sleep 15
		halt -n -f -p
	else	
		echo " " >>$LOGFILE
		echo "     Flashing failed, check $LOGFILE for result..."
		echo "     DVD tray eject..."
		cd /
		sleep 15
		eject.xbox.real
		while :
			do
				sleep 5
			done
	fi
fi




#-----------------------------------------------------
# dont flash user selected shutdown
if $responce -eq B 
then
    echo "     Flashing failed, user selected shutdown" >>$LOGFILE
	echo "     Flashing failed, check $LOGFILE for result..."
	sleep 15
	halt -n -f -p
fi

# end

game.cfg stored on fatx

Code: Select all

#!/bin/bash
#-----------------------------------------------------
# game.cfg xboxdrv keyboard setup file stored on xbox  @ $XBOXMOUNTPATH
#
#
# (c) Copyright 2002    Professor_jonny 
#                       All Rights Reserved.
#
#                       http://www.xbmc4xbox.org.uk
#
#       This program is free software; you can redistribute it and/or
#       modify it under the terms of the GNU General Public License
#       as published by the Free Software Foundation.
#
#       This material is provided AS-IS" and at no charge if it
#	   makes your toaster catch fire dont blame me.
#
#       (c) Copyright 2002      
#-----------------------------------------------------
#
#
# 	A is keyboard key A
# 	B is keyboard key B
# 	X is keyboard key X
# 	Y is keyboard key Y

[xboxdrv]
ui-clear=true
trigger-as-button = true
silent = true

[ui-buttonmap]
a = KEY_A
b = KEY_B
x = KEY_X
y = KEY_Y

# EOF #



Last edited by professor_jonny on Wed Aug 14, 2013 7:35 pm, edited 1 time in total.
User avatar
professor_jonny
Posts: 1298
Joined: Thu Jul 05, 2012 5:41 am
Location: New Zealand
Has thanked: 66 times
Been thanked: 196 times

Re: raincoat flash script update

Post by professor_jonny »

how would i expand the size of an initial ram disk with out building a new one?

i have a copy of linux and i have run out of space in the distro to add in some extra things?

it is a pain in the as from linux my dial up wont work (stupid winmodem)
User avatar
Xphazer
Posts: 524
Joined: Wed Jul 04, 2012 4:39 am
Location: Montréal
Has thanked: 240 times
Been thanked: 106 times

Re: raincoat flash script update

Post by Xphazer »

This might help. Though, I never tested it with an XDSL image.
http://www.tehfear.com/2007/10/08/resiz ... isk-image/
User avatar
professor_jonny
Posts: 1298
Joined: Thu Jul 05, 2012 5:41 am
Location: New Zealand
Has thanked: 66 times
Been thanked: 196 times

Re: raincoat flash script update

Post by professor_jonny »

right that worked thanks for the pm's and reply there everyone.

I have it working and flashing things bypassing some of the logic for the xpad drivers as i cant get them to work as of yet after extending the image from the mechassault tsopflash pack i have found out it is very cut down.

I'm missing a lot of required modules and binarys to run the basics such as libusb, sudo,stat and some dependancys for xboxdrv which is expected as it is only the size of a floppy disk.

So i need a better distro I can cut down and put my script in what would be the best linux distro to start from it needs to end up small to fit in memory so i can port across some of the scripts from xboxhdm to possibly make a crude auto installer able with ability to lock the hdd from a dump of the eeprom.

I'm in the process of making it able to read the 2nd stage script following a hierarchy so it could be run from other places.

just thinking there is no reason I can't convert from a block loop device to a gpio archive type image on the xbox as it will save memory and be easier to work with or is there limitations on this with the xbox and the boot loaders ?
Post Reply