Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Support #8

Closed
Lantizia opened this issue May 20, 2018 · 7 comments
Closed

Write Support #8

Lantizia opened this issue May 20, 2018 · 7 comments

Comments

@Lantizia
Copy link

Lantizia commented May 20, 2018

Hi,

In 2016 I found myself wanting to perform whatever the closest thing to a "factory reset" would be, on the internal HDD of an Xbox. But I also wanted to have the ability to do this again and again with ease, so that I could try all kinds of different software mods and unofficial software... and know I'd have a clean slate each time.

I even modified an Xbox so that it uses two IDE ribbons which both poke out the back of the case, one connected to the motherboard and the other to the HDD. This way, when connected together it'll work as normal, but if you instead connect an USB-IDE adaptor (in the pic it is shown placed on top of the Xbox) to the ribbon cable going to the HDD then you've got super easy access to it without opening the Xbox.

img_20180520_215806

I even started working on a script so that I could repopulate the entire HDD (partition table, partitions, filesystems, contents of filesystems) from a modern Linux distribution which I'll post here...

##
#
#  This is an alternate version of your setup script...
#
#  It depends on getting mkfs.fatx from the XboxHDM Linux ISO
#  But ALSO depends on fatxfs being compiled from here...
#  https://github.com/mborgerson/fatx
#  HOWEVER they haven't added write support, until they do the below
#  is totally useless.  The XboxHDM VM is the only known thing
#  (compiled into the Kernel) to have read/write for FATX.
#
#  NOTE: the Christophe Duverger/baxter104 fusefatx is for 360 XTAF only
#
####


### Download and extract additional files needed

wget -O- http://downloads.sourceforge.net/xboxhdm2/hdparm/hdm2.3addon.tar.bz2 | tar -xj
# The below archive contains the default files for Drive C (see usual online sources if needed)
7z x Clean_C_E_files.7z

### Connect the disk using a JMicron JM20337 based USB to IDE adapter

disk="/dev/sdb"

### (as needed) Unlock the disk if pulled from your particular Xbox

./hdparm --security-eeprom-disable eeprom_xbox-1-1-samsung.bin $disk

### (optional) Wipe the beginning of the disk and where partitions should be

dd if=/dev/zero of=$disk bs=512k count=1
dd if=/dev/zero of=$disk seek=1 bs=512k count=1
dd if=/dev/zero of=$disk seek=1501 bs=512k count=1
dd if=/dev/zero of=$disk seek=3001 bs=512k count=1
dd if=/dev/zero of=$disk seek=4501 bs=512k count=1
dd if=/dev/zero of=$disk seek=5501 bs=512k count=1
dd if=/dev/zero of=$disk seek=15633072 bs=512 count=1

### Write partition table to the disk

dd if=head.raw of=$disk bs=512k
#dd if=fatx.raw of=$disk seek=1 bs=512k
#dd if=fatx.raw of=$disk seek=1501 bs=512k
#dd if=fatx.raw of=$disk seek=3001 bs=512k
#dd if=fatx.raw of=$disk seek=4501 bs=512k
#dd if=fatx.raw of=$disk seek=5501 bs=512k
#dd if=fatx.raw of=$disk seek=15633072 bs=512

### Create loop devices for each partition and store which loop device is which

x_drive="$(losetup --show -f -o 524288 --sizelimit 786432000 $disk)"
y_drive="$(losetup --show -f -o 786956288 --sizelimit 786432000 $disk)"
z_drive="$(losetup --show -f -o 1573388288 --sizelimit 786432000 $disk)"
c_drive="$(losetup --show -f -o 2359820288 --sizelimit 524288000 $disk)"
e_drive="$(losetup --show -f -o 2884108288 --sizelimit 5120024576 $disk)"
f_drive="$(losetup --show -f -o 8004132864 $disk)"

### (optional) Show the headers we wrote earlier to the disk and partitions

echo $(head -c1540 $disk|tail -c4)
echo $(head -c4 $x_drive)
echo $(head -c4 $y_drive)
echo $(head -c4 $z_drive)
echo $(head -c4 $c_drive)
echo $(head -c4 $e_drive)
echo $(head -c4 $f_drive)

### Format the partitions

./mkfs.fatx $x_drive
./mkfs.fatx $y_drive
./mkfs.fatx $z_drive
./mkfs.fatx $c_drive
./mkfs.fatx $e_drive
./mkfs.fatx $f_drive

### Mount drives C and E

mkdir -p /mnt/c_drive
mkdir -p /mnt/e_drive
./fatxfs $disk /mnt/c_drive --drive=c
./fatxfs $disk /mnt/e_drive --drive=e

### Copy files

cp -r C/* /mnt/c_drive
cp -r E/* /mnt/e_drive

### Unmount and tidy up loop devices

umount /mnt/c_drive
umount /mnt/e_drive
losetup -d $x_drive
losetup -d $y_drive
losetup -d $z_drive
losetup -d $c_drive
losetup -d $e_drive
losetup -d $f_drive

### Lock the disk so it can be used in your particular Xbox

./hdparm --security-eeprom-lock eeprom.bin $disk

### Other bits to tidy up

rm -R C E hdm2.3addon eeprom_xbox-1-1-samsung.bin /mnt/c_drive /mnt/e_drive

Trouble is I never really got around to using that script as it depended on fatxfs actually being able to write to the filesystems.

So my process hasn't changed really, basically I still have to grab the ageing Xbox-HDM v1.9 tool...
http://www.theisozone.com/downloads/xbox/tools/xbox-hard-drive-maker-v19-xboxhdm/
Use its make-iso-lin.sh script to make a bootable Linux ISO, and boot that ISO in VMware Workstation (configured with the Xbox HDD block device passed through to it as a VM disk). Xbox-HDM can then repopulate everything (as its Linux 2.4.25 kernel can write to FATX filesystems) but I still need to do the un-lock/re-lock of the disk outside of the VM.

Needless to say it's a lengthier process than it could be... but at least it means with a modern PC and a modern Linux distribution... it can be done - even if it does mean faffing with an old bootable Linux 2.4.25 ISO and a VM.

So I'm sticking all this information here in case anyone else was wanting to do the same or would find this information helpful.

If you are close to getting write support working or are stuck on something, count me as someone eager to help in anyway I can. Essentially in a long winded way, I'm saying the 'issue' I'm writing about is the lack of write support. But I'm also saying it'd have the really useful secondary side effect of helping people reset their Xbox's too! 😀

Steven

@mborgerson
Copy link
Owner

Hi Steven--

Thanks for the detailed info! I like the ribbon cable hack.

Yes, write support is absolutely something I want but "just haven't gotten around to yet"(tm). As you suggested, this would be beneficial for a number of reasons. I would also like to have the ability to format a new Xbox HDD image from scratch (though in reality I think this part could be as simple as writing a "blank" image (with partitions formatted, just empty/free of copyright data). And we'd finally be able to ditch the XboxHDM tool.

It's probably a few days of work. I didn't need it at the time so I didn't do it, but I expect that it's not too complicated. The most difficult part is probably just allocating clusters and updating the FAT, etc. for file creation.

As always, pull requests are welcome if someone wants to do the work!

Matt

@mborgerson mborgerson changed the title Regarding write support, what do you need? Write Support May 21, 2018
@PotcFdk
Copy link

PotcFdk commented Sep 30, 2018

Hello, I know this is not strictly the best place to ask, but I remember there being a 2.4-era fatx kernel driver with read-write support. Wouldn't native support by getting that old driver back to life make sense, too; or alternatively, seeing as the differences between regular fat and fatx are not inumanly big, wouldn't basing a new fatx driver off of the normal fat one ease things up a bit?

@Lantizia
Copy link
Author

Lantizia commented Oct 1, 2018

About that 2.4-era fatx driver... I mention it in the comment at the top of the script I posted above...

# The XboxHDM VM is the only known thing (compiled into the Kernel) to have read/write for FATX.

I call it a VM only because that's how I use it, but it's actually just a bunch of files you can download online and with them comes both a .sh and a .bat for creating an ISO you can boot on an old legacy IDE PC.

Apparently (if going down the kernel driver route is too big a job) there is another project called fusefat (sometimes called libfat) which is a FAT12/16/32 read/write driver for FUSE. Maybe this could be modified? According to Sourceforge it hasn't seen any work in 10 years though - probably because everyone just uses the kernel driver.

p.s. Minor update on that script I posted above... it can now use the normal copy of hdparm to lock/unlock drives over USB-IDE. So if we do get a working fatx driver (and a way of formatting fatx partitions)... then it means no longer having to rely on any more third party downloads - mostly it'll all be stuff available in our normal Linux distributions.

@mborgerson
Copy link
Owner

@PotcFdk Go for it! I'm sure you can find an existing FAT16/32 driver that can be modified to support FATX.

@Xeddius
Copy link

Xeddius commented May 23, 2019

Definitely hoping to see progress on this. Trying to upgrade my Xbox and I don't have any systems with IDE connectors (only have an IDE-to-SATA for the SSD I'm installing in it). I've had quite a headache trying to get XboxHDM working with a sata based drive. The Virtual Machine route seemed viable using the Windows version of XboxHDM in a Win7 VM, but turned out to be more of a headache than it was worth. I'll try what Lantizia suggested with the VM to see if this might work better. Having write support directly from my main os (Linux) would save me (and many others) so much time and effort.

Since this project seems dead, I purchased a new IDE cable, y splitter, etc and just used CHIMP. I recommend this overall as I doubt proper write support will be coming anytime soon.

EDIT: It has been more than a year, I've done mods for others, I highly recommend going with the Y splitter, IDE cable, and CHIMP method, if you're thinking of using this to edit the filesystem it's a waste of time until full write support is completed (Which is probably going to be a very long time.)

@PotcFdk
Copy link

PotcFdk commented May 23, 2020

Just a short reminder that the XBox source code seems to be leaked - though I both see people who claim this is definitely a new thing, and also people who claim it's been around for a few years already.
Anyways, it seems to contain fatx sources, too, so maybe one day we will see good, full fatx support with modern kernels. I just hope it doesn't have to be me who will write one in 10 years. ;-)
Actually, I've tried to start a modern-day kernel module project for fatx in 2019, but soon noticed that my entire concept was flawed to the point where I had to throw it all away and re-start, but haven't had any time since then. Turns out, it's a bit more complicated than I initially assumed. Sorry to disappoint, lol.

@mborgerson
Copy link
Owner

Done via #14 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants