The gameboy advance

The big picture :

gameboy flash2advance crosscompil embedded ecos ezusb flasher

the gameboy

The specs are :

cross compil

I compile for an arm7tdmi, arm-eabi :

I use the combined tree method, so i had to "recombine" the tree :

rm -fr ${SOURCES}/combined
cp -R ${SOURCES}/gcc-${GCC_VER} ${SOURCES}/combined
ln -s ${SOURCES}/gmp-${GMP_VER} ${SOURCES}/combined/gmp
ln -s ${SOURCES}/mpfr-${MPFR_VER} ${SOURCES}/combined/mpfr
ln -s ${SOURCES}/binutils-${BINUTILS_VER}/bfd ${SOURCES}/combined/
ln -s ${SOURCES}/binutils-${BINUTILS_VER}/binutils ${SOURCES}/combined/
ln -s ${SOURCES}/binutils-${BINUTILS_VER}/gas ${SOURCES}/combined/
ln -s ${SOURCES}/binutils-${BINUTILS_VER}/ld ${SOURCES}/combined/
ln -s ${SOURCES}/binutils-${BINUTILS_VER}/opcodes ${SOURCES}/combined/
ln -s ${SOURCES}/binutils-${BINUTILS_VER}/include/* ${SOURCES}/combined/include/
ln -s ${SOURCES}/newlib-${NEWLIB_VER}/newlib ${SOURCES}/combined/
ln -s ${SOURCES}/newlib-${NEWLIB_VER}/libgloss ${SOURCES}/combined/
ln -s ${SOURCES}/insight-${INSIGHT_VER}/gdb ${SOURCES}/combined/
ln -s ${SOURCES}/insight-${INSIGHT_VER}/itcl ${SOURCES}/combined/
ln -s ${SOURCES}/insight-${INSIGHT_VER}/libgui ${SOURCES}/combined/
ln -s ${SOURCES}/insight-${INSIGHT_VER}/readline ${SOURCES}/combined/
ln -s ${SOURCES}/insight-${INSIGHT_VER}/sim ${SOURCES}/combined/
ln -s ${SOURCES}/insight-${INSIGHT_VER}/tcl ${SOURCES}/combined/
ln -s ${SOURCES}/insight-${INSIGHT_VER}/tk ${SOURCES}/combined/
Then there is only one configure invocation :

mkdir -p ${BUILDS}/combined
cd ${BUILDS}/combined
${SOURCES}/combined/configure \
     --prefix=${PREFIX} \
     --target=${TARGET} \
     --with-cpu=${TARGET_CPU} \
     --with-newlib \
     --disable-shared \
     --disable-nls \
     --disable-libgomp \
     --disable-libmudflap \
     --disable-libssp \
     --enable-languages=c,c++ \
Then the famous make && make install. Here is the script i use for automatic building and a patch for bfd and zlib issues.


All you need is an ld script and a startup (kind of minimalist project). Then the makefile can look like this :


ASFLAGS=-Wall -mthumb
CFLAGS=-Wall -mthumb
LDFLAGS=-mthumb -T gba.ld -nostartfiles

default: main.gba

main : main.o printf.o text_disp.o startup.o

main.gba : main
        $(OBJCOPY) -v -O binary $< $@

clean :
        rm -fr main main.gba *.o

For running your code, you can use a real hardware or an emulator (VisualBoyAdvance is good).

VisualBoyAdvance main.gba
Hello eCos world!


We need the sources.

cd ${BASE}/sources/
cvs -z3 -d co -P ecos
cvs -z3 -d co -P host
export ECOSSRCDIR=${BASE}/sources/ecos/host

cd ${BASE}/downloads/
cd ${BASE}/sources/
tar -jxvf ${BASE}/downloads/ecos-3.0.i386linux.tar.bz2
export ECOSSRCDIR=${BASE}/sources/ecos-3.0/tools/src

Then, we build the host tools.

mkdir -p ${BASE}/builds/ecos-tools
cd ${BASE}/builds/ecos-tools
${BASE}/sources/ecos/configure --prefix=${BASE}/ecos-tools
make install

mkdir -p tools/src/tools/configtool/standalone/wxwin/
mkdir -p host/tools/configtool/standalone/wxwin/

make -f ${ECOSSRCDIR}/tools/configtool/standalone/wxwin/makefile.gnu install WXDIR=/path/to/wx/installation INSTALLDIR=${BASE}/ecos-tools OSTYPE=linux-gnu

Launch the config tool.

cd $(base)/builds/ecos-$(ECOS_VER)
export ECOS_REPOITORY=${BASE}/sources/ecos-3.0/packages

Import the gba package.

Tools->Administration : Add : browse to gbax.epk : Ok.

Choose the target.

Build->Template : in Hardware choose 'Game Boy Advance with Xport' : Ok.

Configure and save the configuration.

File->save : choose : $(BASE)/builds/ecos-gba/redboot.ecc : Ok.

Build the tree.

Build->Generate Build Tree

Run the compilation.


Refs : ecos for gba

the flash2advance

The Flash2Advance linkers allow to flash a Gameboy Advance card via USB (see if2a project).
However we can customize the linker for making a serial debuger for example.


The linker have one usb plug on one side, and a gba serial plug on the other.
Between, there is an AN2135 chip (cypress AN21xx, AN2131, or EZ-Usb family) with a 8051 core. It's firmware is loadable and customizable.
The pinout to the serial port is :

PIN0 PC0 RXD0 = 1 <----  So
PIN1 PC1 TXD0 = 1  ----> Si   GBA
PIN4 PC4 T0   = 0 <----  Sd   
PIN6 PC6 WR#  = 0  ----> Sc   
Liens chip-connecteur

Here is a kernel module to recognize the flash2advance as an usb serial tty.

Refs : et