- What's the SPI speed you're using?
- How do you store the .gba file into the PIC24 memory? I tried to find an external or binary file embedded into the C code but found nothing.
- Where did you find the multiboot protocol explained? I was reading this Technical Guide and found the xboo cable and the multiboot protocol, but it seems to complicated to implement in one day.
The Pic is the source of clock for SPI. The speed is about 450 kHz. The Pic sends the 32 bits out in two groups of 16 bits. If you have short leads you might be able to get it to work up to 2MHz.
The .gba file (gba rom file) is included by an "incbin" command in "\pic_files\gba_multiboot\gba_multiboot.s" (It's assembly). The .gba file to be embedded is "\gba_files\devkitPro_gba_analog_meter\gba_analog_meter_mb.gba" I couldn't figure out how to do it any other way. Then is the main file I grab the starting location and length like so:
asm volatile ("mov #.sizeof.(.gba), w0");
asm volatile ("mov w0,_gba_bin_length");
asm volatile ("mov #.startof.(.gba), w0");
asm volatile ("mov w0,_gba_binary_pointer_offset"); //gba_binary_start_address
asm volatile ("mov #tblpage(_gba_binary), w0");
asm volatile ("mov w0,_gba_binary_pointer_tblpage");
Anyone know a better way to include a binary file using only c?
I could have used "pincbin" to store 50% extra .gba file (would have to change unpack logic).
I did alot of playing around to get the multiboot working. Those links provided the seed value constant needed to send data to the gba encrypted. I also made an xboo cable (parallel port cable to GBA) and put a PIC18F on it to send all the raw data to a serial port so I coluld read it and study it. The debug serial output that I show on my drawing can also send out all the raw data being transfered if you change the debug level in the main program:
#define debug_uart2 1 //0=no gba loading info out uart2
//1=display text description
//2=display text description and raw hex data
There is a "agb programming manual" out there with detailed info on the GameBoy Advance.
I didn't use MPLAB for the PIC beacause I couldn't get it to work so I used the CLI. I made a batch file that did all the compiling and programmming in one go. It is in "\bat_files\build_all_program_pic.bat". I've copied below:
@echo off
echo PIC24 gba loader
@echo.
echo Compiling GBA Program...........................................................
@echo.
cd ..\gba_files\devkitPro_gba_analog_meter\
make
if errorlevel 1 pause
@echo.
echo Compiling PIC Program........................................for PIC24HJ128GP502
@echo.
cd ..\..\pic_files\gba_multiboot\
pic30-gcc -T p24HJ128GP502.gld -mcpu=24HJ128GP502 -o gba_multiboot.cof gba_multiboot.s gba_multiboot.c -Wl,--heap=0
if errorlevel 1 pause
pic30-bin2hex gba_multiboot.cof
if errorlevel 1 pause
@echo.
echo Programming PIC..............................................for PIC24HJ128GP502
@echo.
pk2cmd -pPIC24HJ128GP502 -fgba_multiboot.hex -M -J -R
if errorlevel 1 pause
:end
Ken