#16433 - Will - Mon Feb 16, 2004 6:58 am
I've just written (ported) a multi-boot loader to a microcontroller and can load a demo program that I include as hex in a header file, but I can't seem to compile multiboot code to send in the same manner. My loader code is heavily based on
http://ajo.thinknerd.com/gba/software.html and seems to work OK.
My test program is from the MultiplayerV1.zip in the "demo_data". Here it is below:
This program draws a diagonal line on a blank screen. This works, and I can successfully boot the GB from my micro-controller and the program runs OK. (Yeah, I'm pretty please about that).
However, if I try and compile a multi-boot program from source (HamDevKit's Hello World demo), fix the header using either 'gbafix' or 'gbarm', then convert using bin2c (or bin2h, b2x etc), the file will load fine with a good CRC at the end, but the screen goes white when it tries to boot. I've verified this ROM is ok when multibooted by multi-booting it from one Gameboy to another using modified Multiplayer demo code.
Here's the hex code of the troublesome Hello World program:
Any ideas why my HelloWorld program won't run? Its definately compiled as a multiboot program, and verfied by running it an emulator and checking the PC register.
Can anyone point me in the right direction on decoding the first few bytes of ROM and how the bootup works? I've tried to disassemble by hand, but gathering all the information is quite tricky. I know that the there is typically an unconditional jump at the start, but I'm not sure of the opcode and instruction formats.
I've tried playing with the header using 'gbarm', but that seems to make little difference.
http://ajo.thinknerd.com/gba/software.html and seems to work OK.
My test program is from the MultiplayerV1.zip in the "demo_data". Here it is below:
Code: |
const unsigned char LineProg[] = { 0x2e,0x00,0x00,0xea,0x24,0xff,0xae,0x51,0x69,0x9a,0xa2,0x21,0x3d,0x84,0x82,0x0a, 0x84,0xe4,0x09,0xad,0x11,0x24,0x8b,0x98,0xc0,0x81,0x7f,0x21,0xa3,0x52,0xbe,0x19, 0x93,0x09,0xce,0x20,0x10,0x46,0x4a,0x4a,0xf8,0x27,0x31,0xec,0x58,0xc7,0xe8,0x33, 0x82,0xe3,0xce,0xbf,0x85,0xf4,0xdf,0x94,0xce,0x4b,0x09,0xc1,0x94,0x56,0x8a,0xc0, 0x13,0x72,0xa7,0xfc,0x9f,0x84,0x4d,0x73,0xa3,0xca,0x9a,0x61,0x58,0x97,0xa3,0x27, 0xfc,0x03,0x98,0x76,0x23,0x1d,0xc7,0x61,0x03,0x04,0xae,0x56,0xbf,0x38,0x84,0x00, 0x40,0xa7,0x0e,0xfd,0xff,0x52,0xfe,0x03,0x6f,0x95,0x30,0xf1,0x97,0xfb,0xc0,0x85, 0x60,0xd6,0x80,0x25,0xa9,0x63,0xbe,0x03,0x01,0x4e,0x38,0xe2,0xf9,0xa2,0x34,0xff, 0xbb,0x3e,0x03,0x44,0x78,0x00,0x90,0xcb,0x88,0x11,0x3a,0x94,0x65,0xc0,0x7c,0x63, 0x87,0xf0,0x3c,0xaf,0xd6,0x25,0xe4,0x8b,0x38,0x0a,0xac,0x72,0x21,0xd4,0xf8,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x30,0x31,0x96,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00, 0x12,0x00,0xa0,0xe3,0x00,0xf0,0x29,0xe1,0x70,0xd0,0x9f,0xe5,0x1f,0x00,0xa0,0xe3, 0x00,0xf0,0x29,0xe1,0x60,0xd0,0x9f,0xe5,0x00,0x00,0x81,0xe5,0x4c,0x00,0x9f,0xe5, 0x4c,0x10,0x9f,0xe5,0xb0,0x00,0xc1,0xe1,0x00,0x00,0xa0,0xe3,0x44,0x10,0x9f,0xe5, 0xb0,0x00,0xc1,0xe1,0x06,0x14,0xa0,0xe3,0x96,0x2c,0xa0,0xe3,0x00,0x00,0xa0,0xe3, 0xb2,0x00,0xc1,0xe0,0x01,0x20,0x52,0xe2,0xfc,0xff,0xff,0x1a,0x06,0x14,0xa0,0xe3, 0x02,0x09,0xa0,0xe3,0x01,0x00,0x40,0xe2,0xa0,0x20,0xa0,0xe3,0x02,0x00,0x81,0xe4, 0x1e,0x1e,0x81,0xe2,0x01,0x20,0x52,0xe2,0xfb,0xff,0xff,0x1a,0xfe,0xff,0xff,0xea, 0x03,0x04,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x7f,0x00,0x03, 0xa0,0x7f,0x00,0x03,0x30,0x00,0x2d,0xe9,0x1e,0x4e,0xa0,0xe3,0x94,0x01,0x05,0xe0 }; |
This program draws a diagonal line on a blank screen. This works, and I can successfully boot the GB from my micro-controller and the program runs OK. (Yeah, I'm pretty please about that).
However, if I try and compile a multi-boot program from source (HamDevKit's Hello World demo), fix the header using either 'gbafix' or 'gbarm', then convert using bin2c (or bin2h, b2x etc), the file will load fine with a good CRC at the end, but the screen goes white when it tries to boot. I've verified this ROM is ok when multibooted by multi-booting it from one Gameboy to another using modified Multiplayer demo code.
Here's the hex code of the troublesome Hello World program:
Code: |
const unsigned char HelloWorld[] = { 0x2e,0x00,0x00,0xea,0x24,0xff,0xae,0x51,0x69,0x9a,0xa2,0x21,0x3d,0x84,0x82,0x0a, 0x84,0xe4,0x09,0xad,0x11,0x24,0x8b,0x98,0xc0,0x81,0x7f,0x21,0xa3,0x52,0xbe,0x19, 0x93,0x09,0xce,0x20,0x10,0x46,0x4a,0x4a,0xf8,0x27,0x31,0xec,0x58,0xc7,0xe8,0x33, 0x82,0xe3,0xce,0xbf,0x85,0xf4,0xdf,0x94,0xce,0x4b,0x09,0xc1,0x94,0x56,0x8a,0xc0, 0x13,0x72,0xa7,0xfc,0x9f,0x84,0x4d,0x73,0xa3,0xca,0x9a,0x61,0x58,0x97,0xa3,0x27, 0xfc,0x03,0x98,0x76,0x23,0x1d,0xc7,0x61,0x03,0x04,0xae,0x56,0xbf,0x38,0x84,0x00, 0x40,0xa7,0x0e,0xfd,0xff,0x52,0xfe,0x03,0x6f,0x95,0x30,0xf1,0x97,0xfb,0xc0,0x85, 0x60,0xd6,0x80,0x25,0xa9,0x63,0xbe,0x03,0x01,0x4e,0x38,0xe2,0xf9,0xa2,0x34,0xff, 0xbb,0x3e,0x03,0x44,0x78,0x00,0x90,0xcb,0x88,0x11,0x3a,0x94,0x65,0xc0,0x7c,0x63, 0x87,0xf0,0x3c,0xaf,0xd6,0x25,0xe4,0x8b,0x38,0x0a,0xac,0x72,0x21,0xd4,0xf8,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x30,0x31,0x96,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00, 0x06,0x00,0x00,0xea,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, 0x12,0x00,0xa0,0xe3,0x00,0xf0,0x29,0xe1,0xc4,0xd0,0x9f,0xe5,0x1f,0x00,0xa0,0xe3, 0x00,0xf0,0x29,0xe1,0xbc,0xd0,0x9f,0xe5,0x01,0x00,0x8f,0xe2,0x10,0xff,0x2f,0xe1, 0x2e,0x49,0x2f,0x48,0x08,0x60,0x2f,0x48,0x40,0x01,0x0a,0xd2,0x78,0x46,0x40,0x01, 0x0c,0xd3,0x40,0x23,0x1b,0x03,0xda,0x01,0x16,0x1c,0x91,0x00,0x00,0xf0,0x40,0xf8, 0x30,0x47,0x40,0x21,0x09,0x03,0xc8,0x01,0x00,0xf0,0x30,0xf8,0x03,0x20,0x00,0x06, 0x25,0x49,0x00,0xf0,0x2b,0xf8,0x25,0x48,0x25,0x49,0x09,0x1a,0x00,0xf0,0x26,0xf8, 0x24,0x49,0x25,0x4a,0x25,0x4c,0x00,0xf0,0x2a,0xf8,0x25,0x49,0x25,0x4a,0x26,0x4c, 0x00,0xf0,0x25,0xf8,0x25,0x4a,0x26,0x49,0x53,0x1a,0x02,0xd0,0x25,0x4a,0x00,0xf0, 0x1f,0xf8,0x25,0x49,0x25,0x4a,0x26,0x4c,0x00,0xf0,0x19,0xf8,0x25,0x4a,0x26,0x49, 0x53,0x1a,0x02,0xd0,0x25,0x4a,0x00,0xf0,0x13,0xf8,0x00,0x20,0x00,0x21,0x24,0x4b, ... etc.... |
Any ideas why my HelloWorld program won't run? Its definately compiled as a multiboot program, and verfied by running it an emulator and checking the PC register.
Can anyone point me in the right direction on decoding the first few bytes of ROM and how the bootup works? I've tried to disassemble by hand, but gathering all the information is quite tricky. I know that the there is typically an unconditional jump at the start, but I'm not sure of the opcode and instruction formats.
I've tried playing with the header using 'gbarm', but that seems to make little difference.