GameBoy ROM Dumper - Round 3 - USB Mass Storage
So I stumbled upon this really sweet and unique cartridge dumper about a couple months ago. It's called the Retrode and it shows up as a storage device with the ROM as a file on the drive. It creates the files from only the carts ROM and RAM.
I've been working on my third revision of my Gameboy ROM Dumper that is based on the Retrode. I've been working on it off and on since November. I'm almost at the point where I can offload the ROM but I was running into a problem. I recently figured out that the source of my problem was that the processor was crashing.
So how did I get to this point?
I spent some time in the beginning researching FAT file systems since I was going to have to emulate one in order to get the ROM to appear as a file on faked mass storage device. Once I understand how the FAT system worked, I wrote code to interface with the cartridge the way the file system would and wrote code to build the necessary data structures(FAT table, Directory Entry, Boot record) that the host would expect to see on the mass storage device.
I'm using the StellarisWare drivers again and there happens to be a mass storage device example that I've based my application on. When I first started this I couldn't find a lot of information about other people that had done this but then I came across NXP microcontrollers and they use this concept as their programmer. Basically when you plug the micro into a usb slot it shows up as a mass storage device with the firmware on it. You can then drag and drop new firmware onto the micro. Travis Goodspeed also gave a talk about faking mass storage devices at CCC this year.
I got to the point where I could view the contents of the device in WinHex but I couldn't transfer the file to my computer. The readout from WinHex gave me confidence that I had setup everything correctly but doing a file transfer broke my system. Around that time someone had ported the drag/drop firmware transfer to the Stellaris Launchpad. I compared my code to theirs and didn't find much difference in our process. I was a little confused as to why mine wasn't not working. I used their debug messages in my code and found that it would read sectors then freeze. It would freeze on different sectors every time. I assumed it was timing out and the host wasn't requesting the data again. I finally put a debug message in the mainloop and that message stopped when the sector reading froze. The USB mass storage is interrupt driver. This could still mean that its getting into an infinite loop. I haven't had the chance to dig through the USB driver library and see if there's anywhere it could get stuck. It could also mean that the processor is crashing, due to a stack overflow, out of bound array reading, etc. I don't have a JTAG debugger so it will be difficult to track this down. Well I do have a bus pirate so I might be able to setup some debugger with OpenOCD or something. That is something I will have to check out.
That's where I'm at and I hoping to get this solved at some point. When I do I'll post my code.
I've been working on my third revision of my Gameboy ROM Dumper that is based on the Retrode. I've been working on it off and on since November. I'm almost at the point where I can offload the ROM but I was running into a problem. I recently figured out that the source of my problem was that the processor was crashing.
So how did I get to this point?
I spent some time in the beginning researching FAT file systems since I was going to have to emulate one in order to get the ROM to appear as a file on faked mass storage device. Once I understand how the FAT system worked, I wrote code to interface with the cartridge the way the file system would and wrote code to build the necessary data structures(FAT table, Directory Entry, Boot record) that the host would expect to see on the mass storage device.
I'm using the StellarisWare drivers again and there happens to be a mass storage device example that I've based my application on. When I first started this I couldn't find a lot of information about other people that had done this but then I came across NXP microcontrollers and they use this concept as their programmer. Basically when you plug the micro into a usb slot it shows up as a mass storage device with the firmware on it. You can then drag and drop new firmware onto the micro. Travis Goodspeed also gave a talk about faking mass storage devices at CCC this year.
I got to the point where I could view the contents of the device in WinHex but I couldn't transfer the file to my computer. The readout from WinHex gave me confidence that I had setup everything correctly but doing a file transfer broke my system. Around that time someone had ported the drag/drop firmware transfer to the Stellaris Launchpad. I compared my code to theirs and didn't find much difference in our process. I was a little confused as to why mine wasn't not working. I used their debug messages in my code and found that it would read sectors then freeze. It would freeze on different sectors every time. I assumed it was timing out and the host wasn't requesting the data again. I finally put a debug message in the mainloop and that message stopped when the sector reading froze. The USB mass storage is interrupt driver. This could still mean that its getting into an infinite loop. I haven't had the chance to dig through the USB driver library and see if there's anywhere it could get stuck. It could also mean that the processor is crashing, due to a stack overflow, out of bound array reading, etc. I don't have a JTAG debugger so it will be difficult to track this down. Well I do have a bus pirate so I might be able to setup some debugger with OpenOCD or something. That is something I will have to check out.
That's where I'm at and I hoping to get this solved at some point. When I do I'll post my code.
