Skip to content

Instantly share code, notes, and snippets.

@Pharap
Created January 11, 2021 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pharap/ed4dc246fb088c7a8db59f10fab4419c to your computer and use it in GitHub Desktop.
Save Pharap/ed4dc246fb088c7a8db59f10fab4419c to your computer and use it in GitHub Desktop.

The Arduboy FX FAQ

What does FX mean?

FX is an acronym coined by @Mr.Blinky and voted for by the original 'Team Falcon'. It stands for "Flash eXpansion".

What is the FX?

The Arduboy FX is effectively a normal arduboy with an additional piece of hardware: the FX chip. The FX chip consists of two things:

  • A large 16MB block of flash memory.
  • A small ATtiny85 (in a "20-QFN package")

The flash memory has two primary purposes:

  • To store multiple additional Arduboy games, so that they can be uploaded to the Arduboy on demand without a need for an external device.
  • To provide extra read-only progmem-like memory so that new games with larger data requirements can take advantage of the extra storage provided by the FX chip

The ATtiny chip on the other hand is primarily intended to be used to update the Arduboy's bootloader.

What's all this talk about a bootloader?

The Arduboy's default bootloader ("Cathy") is normally the thing responsible for uploading games to the on-board flash memory ("progmem"), and ordinarily it does this by responding to a sequence of commands given to it by an external device capable of serial communication, i.e. a computer.

In order to accomodate loading games from the FX chip, the bootloader had to be modified.

Ordinarily writing a new bootloader to the Arduboy can be difficult, which is why the ATtiny chip has been added to the FX chip, so the new bootloader and any future updates thereupon can be written to the Arduboy without hassle.

Is the FX chip writeable?

Technically yes, but there are certain constraints that make writing to it impractical.

Writes to the flash memory can only consist of transforming 1 bits into 0 bits. In order to change a 0 bit to a 1 bit you must 'erase' a whole 4KB page of memory, which turns all of the bits in that page into 1 bits.

Given that the Arduboy only has 2.5KB, of which 1KB is reserved for the Arduboy2 library's screen buffer and a reasonable amount of RAM must be reserved for the call stack, freely writing to the FX chip's flash memory would be highly impractical.

It would be practical to write the values of a calculable sequence to the flash memory, for use as a lookup table, but it would probably be more efficient to have that sequence already loaded onto the FX chip rather than trying to get the Arduboy to calculate it after the fact.

FX Chip Functionality

The FX chip receives commands over an SPI (serial peripheral interface) connection.

Among other things, the commands enable the FX chip and specify whether data is to be read or written.

Hopefully this thread will help clear up some facts for people.

What is the FX chip?

The FX chip is an external memory chip containing a kind of memory called flash memory.
This is the same kind of memory used by progmem, which means that it's relatively straightforward to read, but writing to it has some caveats.

How does flash memory work?

Flash memory is not written to in the same way that RAM is written to.
It is divided into 'pages' which are blocks of bytes.
It is not possible to simply overwrite a single byte, instead an entire block of memory (called a 'page') must first be erased, and then written to.
When a page is erased, all the bits are set to 1.
(This is contrary to what most people would expect - people often assume that 'erasing' a bit sets it to 0.)
When the page is then written to after being erased, only the bits that need to set to 0 are actually written.

So essentially, you can think of flash memory as obeying the following rules:

  • You may transform any 1 bit to a 0 bit.
  • To transform a 0 bit to a 1 bit, you must erase an entire page of data.

The pages used by the FX chip are 256 bytes in size,
in contrast to the Arduboy's progmem, which has 128 byte pages.

How does the Arduboy FX communicate with the FX Chip?

The Arduboy FX communicates with this chip over an SPI connection, which is the same kind of connection that the Arduboy uses to communicate with the screen, so it is a relatively fast connection.

Instead of trying to explain SPI myself, I'm going to link to a very good Sparkfun article on the subject:

Sparkfun SPI Info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment