A minimal setup to build Rust into a GBA ROM.
This crate is not for general use!
If you'd like to program a GBA game try the gba crate. The point of this repo is just to ensure that crater runs which break the thumbv4t-none-eabi target get caught.
- rustup default nightly(or run all commands with- cargo +nightly)
- rustup component add rust-src
- arm-none-eabibinutils (either via The ARM Website, or your linux package manager).
- The following files:
- .cargo/config.toml
- src/rsrt0.S
- linker_script.ld
- build.rs
 
It'll go nuts, here's how you fix it:
.vscode/settings.json:
{
  "rust-analyzer.checkOnSave.allTargets": false,
  "rust-analyzer.checkOnSave.extraArgs": [
    "--lib"
  ]
}What you get with the project setup is an executable ELF file, but mgba can run it directly, so that's fine.
For a finalized ROM there's some post-processing steps:
- 
objcopymust be used to extact just the binary guts from the ELF file.- The command you want is probably something like this (change mainto your binary's own name):
- arm-none-eabi-objcopy -O binary target/thumbv4t-none-eabi/release/main target/main.gba
 
- The command you want is probably something like this (change 
- 
gbafixshould be used to apply the correct header.- You can get a Rust version of gbafixvia cargo:cargo install gbafix
- You can also get the C version of gbafix from the DevKitPro folks.
- Either way, gbafix main.gbawill ensure that the gba file has the correct header info.
 
- You can get a Rust version of