Can I use the Arduboy without Arduino?

Hello!

I am mostly programming in Rust. I have a lot of questions related to the Arduboy but cannot find anything online. I hope that people with more knowledge can help me out! I own the Arduboy FX.

  1. How large can a game be exactly? The FX seems to have more flash memory and can store multiple games. Does that mean I can have larger games as well? My game has A LOT of text.

  2. Is it possible to program the Arduboy bare-metal in C/Rust without using the Arduino library? That way one could save a lot of bytes.

  3. If 2 is possible, does that mean the bootloader will not work anymore or won’t be available anymore?

  4. Is it possible to re-flash the old bootloader via USB or so I have to use another uC to flash the old bootloader onto a bare-metal Arduboy?

I know it’s a lot of questions, but I really couldn’t find anything online. Thanks for helping me out!

1 Like

The Arduboy’s CPU (the ATmega32u4) has 32KiB of flash memory (typically referred to as ‘progmem’, and of which 4KiB is reserved by the bootloader), 2.5KiB of RAM (of which 1KiB is occupied by the Arduboy2 frame buffer) and 1 KiB of EEPROM (of which 16 bytes are reserved by the Arduboy2 library for user settings).

The FX chip adds additional flash memory, but it’s accessed differently to the on-chip memory (specifically, it’s connected via an SPI interface and must be communicated with over SPI, as must the screen).

The FX chip can store data, but not executable machine code. Any machine code must be stored in the on-chip memory because the chip can only read machine code from the on-chip memory’s address space (which does not include the external FX chip, the on-chip RAM or the on-chip EEPROM - those all exist as separate address spaces).

Thus it would be theoretically viable to store all your text on the FX chip.

Theoretically, yes - it all just compiles to machine code anyway.

However you’d have to reimplement a lot of the functionality provided by Arduino and/or the Arduboy2 library by yourself.

Fortunately they’re open source, so that would remove a large chunk of the work for you, but it still leaves a lot of writing.

The biggest hurdle to interfacing C++ code is name mangling, so in some scenarios you might be able to either extern "C" or use some compiler features to specify some unmangled aliases for function overloads that you could then hook onto with Rust.

Failing that, it ought to be possible to write an extern "C" wrapper for C++ code.

On the bright side, you should be able to use avr-libc with relative ease, since it was written in C, though it only provides the basics of the C standard library and some extra AVR-specific functions.

No, the bootloader does not get overwritten as part of the normal game upload process. You have to perform a special operation to overwrite the bootloader.

This one I’m not entirely sure of. The Arduboy FXs do ship with a companion chip (an ATmega328P I think?) that’s capable of flashing a new bootloader, but I’m not sure how to go about instructing it to do so.

For an Arduboy without an FX mod you’d almost certainly need a secondary device to overwrite the bootloader, be it a standard Arduino board or a specialised bootloader flashing device (I forget what those are typically called).

@Mr.Blinky may be able to help more with that one since he designed the FX chip, though there may be someone else who understands how it works.


To be honest, I think it would be easier to learn enough C++ to get by than it would be to spend the effort providing the necessary infrastructure to use Rust.

I don’t think you’re likely to get much smaller code by using Rust, and safety is going to be limited because you’re going to have to deal with raw pointers from time to time. You’d also have to disable the GC because there’s no way you’re going to get that working decently with the Arduboy’s limited resources. You wouldn’t even be able to use dynamic memory allocation really - there just isn’t enough RAM for it to be viable. Global variables, stack allocation, or registers, no heap allocation.

Thank you for the answer! This helped out a lot! I do have a follow-up question though:

The Arduboy FX does come pre-installed with the FX mod, right?

Yes. That’s precisely why it’s the ‘Arduboy FX’. Or at least, sort of…

The Arduboy FX comes with the flash expansion (‘FX’) chip preinstalled:

(If I’m not mistaken, the FX chip is the black square to the right of the down button.)

A regular Arduboy (what I like to call a ‘classic Arduboy’ or ‘Arduboy Classic’, though I’m waiting for the terminology to catch on :P) has no such chip:

(Note: the missing black square.)

But it’s possible to add the FX chip onto a ‘classic Arduboy’ by purchasing an FX mod separately and soldering it in:

(Note: two visible black squares.)

Both approaches get you the extra flash memory, but I’ve got a suspicion that the Arduboy FX doesn’t have the extra support chip that the FX mod does because the Arduboy FX comes with the custom bootloader preinstalled whereas an ‘Arduboy Classic’ would need to have its bootloader upgraded, which is what the extra chip is supposed to do. I’m not certain, but that vaguely rings a bell. (@Mr.Blinky or @bateske could likely confirm either way.)

Of course, if you’re just writing games and you’ve got an Arduboy FX then you don’t really need to worry about the bootloader at all, I’m just trying to be as informative as is practical for the benefit of future readers.


While I think of it, there was someone who once managed to write an Arduboy game in Nim:

Which proves that it is possible to use other languages. Hence getting Rust working is plausible, it’s just likely to be quite a bit of work. If you’re prepared to do that work for the sake of using Rust then fair enough, but if you’re prepared to try C++, it would be the easier option.

1 Like

I had to use C++ back in university and just did not like the language at all. But it mightbe a good idea to use this to freshen up my skills. Thanks for the detailed explanations. I do really appreciate it.

It is sad that there is no single wiki where all the knowledge is accumulated. Similar to the Archwiki. Would make it a lot easier for newcomers like me to reference stuff.

1 Like

When looking for some unrelated information I stumbled upon an old comment that confirms this:


I expect the fact you were being taught it as part of a university course probably didn’t help.

In my experience, tertiary education establishments aren’t very good at teaching programming languages for various reasons.

Though in fairness, C++ is quite different to most other languages. It works best when you understand both low-level details (like how RAM and registers work, how pointers and dynamic allocation work…) and high-level design concepts (like type theory, generics, OOP, and the different kinds of polymorphism…).

I somewhat agree.

Though I can definitely see quite a few hurdles - wikis need hosting and moderating, and some kind of consensus on style and tone.

You’re a bit of an exceptional case though.

Most people come here intending to make a game with the existing libraries, not to rewrite the libraries from the ground up.

Also, most newcomers have next to no programming knowledge (or have knowledge of a very different system, e.g. Unity) and are trying to build their first game (or at least their first game with C++).

1 Like

I will definitely keep my findings documented when I start working on this. And GitHub Pages hosting is free for open-source projects. So I will probably end up using that :slight_smile:

2 Likes

I keep meaning to look into GHP, but have never quite got around to it.

Its basically static HTML - no server side scripts at all. You can register your own domain name though.

I tried looking to move the cart builder to it.