by erik · 3y ago · 0 comments
Probably the most interesting feature of this project was how it handled memory. The DS only has 4mb of ram. And there is no MMU, so swap isn't an option. But the gameboy cartridge port has 32mb of address space mapped to the bus. And there are homebrew/piracy cartridges that fill that space with 32mb of ram. Which is great, except that the DS can only write to the cartridge port on 16-bit aligned addresses. And almost all software will assume that 8-bit aligned writes will work. To make use of the expansion memory the developers ended up creating a patched GCC that would convert any writes to unaligned locations to an appropriate read, 16-bit write, and set of shift operations.
There's even an official one, the Opera Web Browser came with a second cartridge for the "GBA" slot to add 8 MB of RAM and a MMU: https://en.wikipedia.org/wiki/Nintendo_DS_Browser#Memory_Exp...
(I've long lost the Opera DS cartridge, but the memory expansion is still in my DS Lite as a slot cover)
But perhaps my memory is going bad and my Google Fu is worse.
Edit: gbatek doesn't document an MMU in those cards either. https://problemkaputt.de/gbatek.htm#dscartexpansionram
When trying to port some industrial control software to DSLinux, I ran into some bugs around how the SLOB allocator behaved under memory pressure. One of my patches landed upstream, even though SLOB is deprecated now. Still, as a kid starting out in the embedded space, it opened my eyes to the joys of hacking around with homebrew.
Fun fact: a modded DS still powers a large part of my local observatory's equipment.
I'm interested! I'd like to read more about that.