nightly gba

A crate for ‘raw’ style GBA development. If you want a ‘managed’ experience, try the agb crate instead.

26 releases (9 breaking)

0.11.2 Jun 2, 2023
0.11.0 Mar 17, 2023
0.10.0 Nov 2, 2022
0.5.3 Apr 12, 2022
0.2.0 Nov 13, 2018

#249 in Game dev

Download history 88/week @ 2023-06-05 44/week @ 2023-06-12 102/week @ 2023-06-19 96/week @ 2023-06-26 74/week @ 2023-07-03 77/week @ 2023-07-10 57/week @ 2023-07-17 91/week @ 2023-07-24 56/week @ 2023-07-31 104/week @ 2023-08-07 91/week @ 2023-08-14 61/week @ 2023-08-21 99/week @ 2023-08-28 117/week @ 2023-09-04 55/week @ 2023-09-11 59/week @ 2023-09-18

350 downloads per month
Used in rustygba

Zlib OR Apache-2.0 OR MIT

2.5K SLoC

gba Documentation

A crate for GBA development.

How To Make Your Own GBA Project Using This Crate

This will require the use of Nightly Rust. Any recent-ish version of Nightly should be fine.

  • Get The ARM Binutils: You'll need the ARM version of the GNU binutils in your path, specifically the linker (arm-none-eabi-ld). Linux folks can use the package manager. Mac and Windows folks can use the ARM Website.
  • Run rustup component add rust-src: This makes rustup keep the standard library source code on hand, which is necessary for build-std to work.
  • Create A .cargo/config.toml: You'll want to set up a file to provide all the right default settings so that a basic cargo build and cargo run will "just work". Something like the following is what you probably want.
target = "thumbv4t-none-eabi"

build-std = ["core"]

runner = "mgba-qt"
rustflags = ["-Clink-arg=-Tlinker_scripts/mono_boot.ld"]
  • Make Your Executables: At this point you can make a bin or an example file. Every executable will need to be #![no_std] and #![no_main]. They will also need a #[panic_handler] defined, as well as a #[no_mangle] extern "C" fn main() -> ! {} function, which is what the assembly runtime will call to start your Rust program after it fully initializes the system. The C ABI must be used because Rust's own ABI is not stable.

fn panic_handler(_: &core::panic::PanicInfo) -> ! {
  loop {}

extern "C" fn main() -> ! {
  loop {}
  • Optional: Use objcopy and gbafix: The cargo build will produce ELF files, which mGBA can run directly. If you want to run your program on real hardware you'll need to first objcopy the raw binary out of the ELF into its own file, then Use gbafix to give an appropriate header to the file. objcopy is part of the ARM binutils you already installed, it should be named arm-none-eabi-objcopy. You can get gbafix through cargo: cargo install gbafix.

This crate provides an API to interact with the GBA that is safe, but with minimal restrictions on what components can be changed when. If you'd like an API where the borrow checker provides stronger control over component access then the agb crate might be what you want.


All safety considerations for the crate assume that you're building for the thumbv4t-none-eabi or armv4t-none-eabi targets, using the provided linker script, and then running the code on a GBA. While it's possible to break any of these assumptions, if you do that some or all of the code provided by this crate may become unsound.