views:

123

answers:

1

I am trying to figure out how to program the PSRAM in the GBA sized EZ Flash 3 in 1 card. Basically repeat what GBA Exploader and other programs do.

If I select a block and program it then read it back the first halfword is always 0x1500 or something like that, but the rest of the data is fine.

If on the write I select the previous block, start writing at 0x20000 bytes into that block (the size of a block from what I have determined). Reading back from the desired block still shows that first halfword as wrong but the rest of the halfwords are correct.

A: 

I was this " close. I had tried to back up one and then two blocks but not three and that was the trick. In hind sight notice how many of the functions write to 0x08000000, 0x08020000, and 0x08040000:

void            OpenNorWrite()
{
        *(vuint16 *)0x9fe0000 = 0xd200;
        *(vuint16 *)0x8000000 = 0x1500;
        *(vuint16 *)0x8020000 = 0xd200;
        *(vuint16 *)0x8040000 = 0x1500;
        *(vuint16 *)0x9C40000 = 0x1500;
        *(vuint16 *)0x9fc0000 = 0x1500;
}

The corrupt data was always 0x1500, which make sense now too.

The solution is to back up three (or more) blocks and address forward three (or more) blocks:

CloseNorWrite();
SetRompage(0x180-3);
OpenNorWrite();
rb=FLASHBASE+(0x20000*3);
for(ra=0;ra<(sizeof(prog)>>2);ra++)
{
    rc=prog[ra];
    PUT16(rb,(rc>> 0)&0xFFFF); rb+=2;
    PUT16(rb,(rc>>16)&0xFFFF); rb+=2;
}
CloseNorWrite();
SetRomPage(0x180);
reboot();
dwelch