gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Hardware > How to boost write flash speed?

#3939 - ZhouChang - Thu Mar 13, 2003 9:01 am

Hello all:
I download flash image from rs232 ,then write into flash,but speed is very slow.
This is my code:
Code:

int write_data(u32 addr, u32 wlen, u32 data)
{
    u32 len;
    u16 ready;

    len = 0;

    while( len < wlen)
    {
        do { read_sr(FLASH_ROM ,ready); } while ( (ready & 0x80)==0 ); 

        write_flash (FLASH_ROM , INTEL28F_WRITE);
        write_flash (addr + len * 2, *(u16 *)(data + len * 2) );
        len ++;
    }

    do { read_sr(FLASH_ROM ,ready); } while ((ready & 0x80)==0);   

    write_flash(FLASH_ROM, INTEL28F_CLEARSR);
    write_flash(FLASH_ROM, INTEL28F_READARRAY);

    return 0;
}

#3960 - peebrain - Thu Mar 13, 2003 8:17 pm

I don't know anything about hardware, but as far as optimized coding goes, at least do this:

Code:
        write_flash (FLASH_ROM , INTEL28F_WRITE);
        write_flash (addr + len, *(u16 *)(data + len) );
        len += 2;


And make sure to change the comparison at the top. Use shifts to multiply by 2, etc...

And if you really want to speed it up, you can get rid of len all together and just increase data and addr.

And if you REALLY want to speed it up, use ASM :-P.

Other than that, I don't know anything about the hardware... so I can't help you anywhere else.

~Sean
_________________
http://www.pbwhere.com

#3984 - ampz - Fri Mar 14, 2003 1:22 pm

Sorry, but optimizing the flash programming code is useless. The flash memory itself limits the programming speed.