tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

Gameboy Advance multiboot target

Open trevor403 opened this issue 4 years ago • 5 comments

There is a feature on the GBA called multiboot. The bios uses the EXT1 port on the GBA to initiate a multiboot protocol over SIO (a custom protocol that is similar to SPI) to load a game directly into EWRAM and boot it by executing a branch instruction.

This PR adds the gameboy-advance-mb target which changes the linker script to support EWRAM loading.

I also updated the crt0 assembly to include some missing header info that is required on GBA for multiboot. It is important to include the multiboot header for all GBA roms as the bios will clobber some bytes while loading the rom.

NOTE: this code is not functional likely due to an issue in the garbage collector which treats _sbss as part of heap. I am able to step through the main loop but as soon as the gc get's called, the program starts executing nop memory.

trevor403 avatar May 26 '20 22:05 trevor403

I think it might be a good idea to rename the gameboy-advance target to gameboy-advance-rom or gameboy-advance-cart to we can use gameboy-advance as an inherited target.

trevor403 avatar May 26 '20 22:05 trevor403

I am not quite sure that your heap start and end are set correctly. Could that be why you are having issues?

niaow avatar May 26 '20 22:05 niaow

@jaddr2line that is almost likely why I am having issues... It looks like the gc is trying to zero 0x20000c0 <_rom_header_end> which is odd.

I can mess around with breakpoints for a couple hours tonight and try to figure out why this is happening. Unfortunately there are no locals in the elf file so it may be harder said than done.

trevor403 avatar May 26 '20 22:05 trevor403

I spent all night in GDB but I was not able to track down the corruption... my heapStart is set just fine, the address is far past the end of the program.

trevor403 avatar May 27 '20 03:05 trevor403

Thanks for the code review @aykevl I'll take a look after work and play with the linker script

trevor403 avatar May 27 '20 15:05 trevor403

Due to being pretty far out of date, I am now closing this PR.

PLease see https://github.com/tinygo-org/tinygba and friends for where the TinyGo GBA dev is happening now. Thanks @trevor403

deadprogram avatar Apr 30 '23 07:04 deadprogram