예제 #1
0
파일: prog_flash.c 프로젝트: 0xCA5A/dd-wrt
static void
program_flash(cyg_addrword_t arg)
{
    diag_printf("PROGRAM FLASH here!\n");
    HAL_UCACHE_SYNC();     // ROM space is marked cacheable which causes problems!
    HAL_UCACHE_DISABLE();  // So, just disable caches.
    identify_FLASH();
    diag_printf("About to program FLASH using data at %x..%x\n", flash_buffer, flash_buffer_end);
    diag_printf("*** Press RESET now to abort!\n");
    cyg_thread_delay(5*100);
    diag_printf("\n");
    diag_printf("... Erase sector\n");
    if (erase_sector(ROM_address)) {
        diag_printf("... Programming FLASH\n");
        while (flash_buffer < flash_buffer_end) {
            if (!write_flash(flash_buffer++, ROM_address++)) break;
        }
    }
    
    // Exit Program Mode
    switch (manuf_code) {
    case ATMEL_MANUF:
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_START_CMD1;
        FLASH[ATMEL_SEQ_ADD2] = ATMEL_START_CMD2;
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_STOP_CMD;
        break;
    case INTEL_MANUF:
        FLASH[0] = INTEL_STOP_CMD;
        break;
    }
    diag_printf("All done!\n");
    cyg_test_exit();
}
예제 #2
0
int
main( int argc, char *argv[] )
{
    int i;

    diag_printf("FLASH here!\n");
    while (identify_FLASH() == 0) {
        diag_printf("... Please change FLASH jumper\n");
        cyg_thread_delay(5*100);
    }
    diag_printf("About to program FLASH using data at %x..%x\n", flash_buffer, flash_buffer_end);
    diag_printf("*** Press RESET now to abort!\n");
    cyg_thread_delay(5*100);
    diag_printf("\n");
    diag_printf("...Programming FLASH\n");

    i = 0;
    while (flash_buffer < flash_buffer_end) {
        write_sector(i++, flash_buffer);
        flash_buffer += 256;
    }
    diag_printf("All done!\n");
    while (1) ;
}