Author Topic: GameBoy Advance multiboot with Pic24  (Read 10302 times)

0 Members and 2 Guests are viewing this topic.

Offline kekTopic starter

  • Regular Contributor
  • *
  • Posts: 52
  • Country: ca
    • Ken's Electronics Projects
GameBoy Advance multiboot with Pic24
« on: August 12, 2010, 11:39:32 pm »
Here is a project I've been working on
http://sites.google.com/site/kenselectronicsprojects/gameboy-analog-meter

It uses the GBA as an analog type display. Also boots up the GBA without a cartridge present.

Ken

 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 38035
  • Country: au
    • EEVblog
Re: GameBoy Advance multiboot with Pic24
« Reply #1 on: August 13, 2010, 12:07:33 am »
Nice!

Dave.
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: GameBoy Advance multiboot with Pic24
« Reply #2 on: August 13, 2010, 02:31:28 pm »
Utterly awesome!  ;D

Where did you buy the GBA serial connector?

Are you planning to do more proyects? If so, could you please describe them?
 

Offline charliex

  • Frequent Contributor
  • **
  • Posts: 342
  • Country: 00
  • Car Hacker
Re: GameBoy Advance multiboot with Pic24
« Reply #3 on: August 13, 2010, 09:12:17 pm »
we actually used to have a commercial product that did something like this, it never really caught in since people felt the gba was a toy. which is a shame, since its great.
 

Offline kekTopic starter

  • Regular Contributor
  • *
  • Posts: 52
  • Country: ca
    • Ken's Electronics Projects
Re: GameBoy Advance multiboot with Pic24
« Reply #4 on: August 13, 2010, 11:47:47 pm »
Utterly awesome!  ;D

Where did you buy the GBA serial connector?

Are you planning to do more proyects? If so, could you please describe them?

You should be able to get the serial cable from ebay. The four player cables would be the ones to use - only player 3 & 4 have the all the pins brought out.

I would like to make an audio spectrum analyzer, just need to hunt around for some FFT code for the PIC.
Maybe make a serial terminal emulator, I think the demo code that comes with DevKit http://www.devkitpro.org/ has most of this done.
I'd also like to make some test equipment type projects, data logging scope type of volt meter.

I made an Infrared Analyzer for the GameBoy Color a long time ago, I find myself using it quite often.
http://webspace.webring.com/people/mk/kkaarvik/infrared.html


Ken
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: GameBoy Advance multiboot with Pic24
« Reply #5 on: August 14, 2010, 04:06:33 pm »
Cool!

Why having the PIC calculate all the FFT stuff if the GBA processor is way better? I have used the FFT split-radix algorithm on a PIC and it's quite efficient when inputing 16 samples (8 freq samples output).

You might want to search for a split radix algorithm with 64 input samples, for example.

Don't use the standard FFT algorithm because it's slower than the split-radix one.
 

Offline kekTopic starter

  • Regular Contributor
  • *
  • Posts: 52
  • Country: ca
    • Ken's Electronics Projects
Re: GameBoy Advance multiboot with Pic24
« Reply #6 on: August 15, 2010, 12:44:17 am »

Why having the PIC calculate all the FFT stuff if the GBA processor is way better? I have used the FFT split-radix algorithm on a PIC and it's quite efficient when inputing 16 samples (8 freq samples output).


Thanks for the info. My thought was to use the analog input of the PIC sample the audio signal, then send the data for each of the frequency bands over to tha GBA. The GBA would then display each instantaneous freq band value and other things derived from that such as hold the peaks and then fade off.
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: GameBoy Advance multiboot with Pic24
« Reply #7 on: August 16, 2010, 07:49:28 pm »
Ken, I've been studying your PIC24 code, could you please answer some questions?  :D

- 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.

Thanks!

PS And I was kinda wrong, the GBA processor is not better than the CPU in the PIC24H you're using. The GBA CPU runs at 16.8MHz and the PIC24H CPU may run at 40MIPS (80MHz).
« Last Edit: August 16, 2010, 07:52:10 pm by migsantiago »
 

Offline kekTopic starter

  • Regular Contributor
  • *
  • Posts: 52
  • Country: ca
    • Ken's Electronics Projects
Re: GameBoy Advance multiboot with Pic24
« Reply #8 on: August 17, 2010, 04:01:33 am »

- 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:

Code: [Select]
@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
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: GameBoy Advance multiboot with Pic24
« Reply #9 on: August 17, 2010, 07:28:18 pm »
OOhhh  ;D

I was reading that a 250kB/s SPI speed was enough and that 2MBps was dangerous, and only usable with short cables, as you said. I will use 250kHz for my SPI speed.

I didn't open that .s file, but that's a neat trick to use ASM to embed the file. What I do to embed bin files into C code directly is the SL File2array application I wrote. Just enter the file path and the program will generate a BYTE array that you can include in your code... for example:

Code: [Select]
//Volcado de archivo C:\Users\Link\Desktop\splash.pcx
//9461 bytes totales

//Convertido por SL File2Array v0.01
//http://www.migsantiago.com

const u8 splash_pcx[] = {
0x0A, 0x05, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0xEF, 0x00, 0x9F, 0x00, 0x48, 0x00, 0x48, 0x00,
0x01, 0x01, 0x01, 0x08, 0x08, 0x17, 0x16, 0x09, 0x03, 0x1B, 0x05, 0x16, 0x1D, 0x13, 0x0C, 0x14,
0x13, 0x13, 0x0E, 0x0E, 0x27, 0x1A, 0x0B, 0x2A, 0x18, 0x0F, 0x39, 0x14, 0x14, 0x2B, 0x16, 0x14,
0x37, 0x2A, 0x07, 0x05, 0x29, 0x06, 0x19, 0x22, 0x17, 0x0F, 0x29, 0x18, 0x15, 0x37, 0x07, 0x05,
0x00, 0x01, 0xF0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

...

That's how I embedded a PCX file onto a GBA "hello world" program I compiled.

http://img840.imageshack.us/img840/841/gbar.png


So, I would like to ask for your permission to use your multiboot xfer functions on my PIC24. I haven't built my xboo cable, but I will eventually.

Thanks!!

PS The SL File2Array program can be found here:
http://www.migsantiago.com/index.php?option=com_content&view=article&id=14&Itemid=14
You may use the Google translator options to read it in english.
 

Offline kekTopic starter

  • Regular Contributor
  • *
  • Posts: 52
  • Country: ca
    • Ken's Electronics Projects
Re: GameBoy Advance multiboot with Pic24
« Reply #10 on: August 17, 2010, 11:34:19 pm »

So, I would like to ask for your permission to use your multiboot xfer functions on my PIC24. I haven't built my xboo cable, but I will eventually.


Feel free to use anything you find on my site for any purpose you wish. If others hadn't done the same I'd still be trying to get an LED to flash!

Have you tried any of the .gba files I've included in the download with an emulator? (a couple of them might complain about an unsupported bios call - that is the auto reboot I'm using to reboot the GBA when I download a new file into the PIC - I should have compiled without). I got code in there to move the needles with no PIC attached - try all the buttons.

When I first got this working, I was storing the .gba file in the PIC as a c array. The max file size was 32kB, a PSV limit. So I had to do table reads. I left the code in that treated the .gba file as an array but commented it out so if someone were to port it to something else there would be clues.

No need for an XBOO cable if you get this working - use your PICKIT 2 instead! The XBOO would be able to program the whole 256kB however and your PICKIT2 and PIC combo depends on the size of your PIC.

Any details of what you're planning to do with the GBA?
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: GameBoy Advance multiboot with Pic24
« Reply #11 on: August 18, 2010, 12:13:05 am »
No need for an XBOO cable if you get this working - use your PICKIT 2 instead! The XBOO would be able to program the whole 256kB however and your PICKIT2 and PIC combo depends on the size of your PIC.

Any details of what you're planning to do with the GBA?


Thanks Ken.

I tested 2 of your gba files on the emulator, they look great! In one of them, the needle keeps spinning like crazy due to the missing SPI comm from the PIC.

Well, I'd like to use the GBA it as a console (plain text), just to start. Then I'd do a JPG viewer using a USB memory being read by the pic24. I just want to program it to learn about it. Who knows... it may eventually turn up into a big project.  ;D
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf