Exemplo n.º 1
0
Uint8 self_check(){
    
    if(check_code()!=E_OK)
        return E_ERR;
    if(check_rom()!=E_OK)
        return E_ERR;
    if(check_ram()!=E_OK)
        return E_ERR;
    if(check_eeprom()!=E_OK)
        return E_ERR;
    if(check_ad()!=E_OK)
        return E_ERR;
    return E_OK;
}
Exemplo n.º 2
0
/*****************************************************************************
*
* flash_test - System Flash ROM diagnostics
*
* A destructive Flash ROM Read/Write test.  Note that the area of Flash
* which is tested changes based on whether the diagnostic is being invoked
* from the System code or from the Factory code (can't write over MON960).
*
* This test basically does a Longword Address test to the Flash area.
*
*/
void flash_test(MENU_ARG arg)
{

    ADDR start_addr = (ADDR)FLASH_ADDR;	/* Original */

    int i;
    unsigned long *f_ptr = (unsigned long *)FLASH_ADDR;
    int bytes_written = 0;
    unsigned long flash_data;
    char answer[20];

/* 10/31/00 */
    int status;

    init_eeprom();

    printf("***********************************\n");
    printf("***           WARNING           ***\n");
    printf("*** This test is destructive to ***\n");
    printf("*** all contents of the FLASH!  ***\n");
    printf("***********************************\n");

    printf("\nDo you wish to continue? (y/n)\n");
    sgets(answer);
    printf("\n\n");
    if ((answer[0] != 'y') && (answer[0] != 'Y'))
	return; 

    printf ("FLASH begins at 0x%X\n", FLASH_ADDR);
    printf ("Total FLASH size = 0x%X\n\n", eeprom_size);
    printf ("Checking FLASH ...\n");
    if (check_eeprom(NO_ADDR, 0) == OK)
        printf("FLASH is erased\n\n");
    else
        printf("FLASH is programmed between 0x%X and 0x%X\n\n",
                eeprom_prog_first, eeprom_prog_last);

    printf ("\nClearing Block Lock Bits... \n");
    if(clear_all_lock_bits(NO_ADDR)==OK)
        printf("Done!\n\n");
    else
        printf("Error!\n\n");
	
    printf ("Erasing FLASH...\n");
    if (erase_eeprom(NO_ADDR, 0) != OK)
        printf("Error on erase_eeprom()\n\n");
    else
        printf("Done Erasing FLASH!\n\n");
 
    (ADDR)start_addr = (ADDR)FLASH_BLK4_BASE_ADDR;

    printf ("Writing Longword Data to FLASH...\n");
 
    /* write to all of available Flash ROM.  Don't do this thousands of times
       since the Flash has only 100,000 write cycles in its lifespan */

    while (bytes_written < (eeprom_size - RESERVED_AREA_SIZE)) {
	flash_data = (unsigned long)start_addr;
    	for (i=0; i<TEST_BUF_LONGS; i++) {
            flash_buffer[i] = flash_data;	/* put address in buffer */
	    flash_data += 4;			/* increment address     */
	}
        if (write_eeprom (start_addr, (void *)flash_buffer, TEST_BUF_CHARS) != OK) {
            printf("Error on write_eeprom()\n");
            goto finish;
        }
        start_addr = (unsigned long)start_addr + TEST_BUF_CHARS;
        bytes_written += TEST_BUF_CHARS;
    }

    printf ("Write Complete, Verifying Data...\n");
    bytes_written = 0;
 
    f_ptr = (unsigned long *)FLASH_BLK4_BASE_ADDR;
    
    while (bytes_written < (eeprom_size - RESERVED_AREA_SIZE)) {
        if (*f_ptr != (unsigned long)f_ptr) {
            printf ("Data verification error at 0x%X\n", (unsigned long)f_ptr);
            printf ("Expected 0x%X Got 0x%X\n", (unsigned long)f_ptr, *f_ptr);
            goto finish;
        }
        f_ptr++;
        bytes_written += 4;
    }
    printf ("Done Verifying Longword Data!\n\n");

    printf ("Checking FLASH...\n");
    if (check_eeprom(NO_ADDR, 0) == OK)
        printf("FLASH is erased\n\n");
    else
        printf("FLASH is programmed between 0x%X and 0x%X\n\n",
                eeprom_prog_first, eeprom_prog_last);

    printf ("Erasing FLASH...\n");
    if (erase_eeprom(NO_ADDR, 0) != OK)
        printf("Error on erase_eeprom()\n\n");
    else
        printf("Done Erasing FLASH!\n\n");

    printf ("Checking FLASH...\n");
    if (check_eeprom(NO_ADDR, 0) == OK)
        printf("FLASH is erased\n\n");
    else
        printf("FLASH is programmed between 0x%X and 0x%X\n\n",
	       eeprom_prog_first, eeprom_prog_last);

    /* reinitialize variables */
    bytes_written = 0;
 
    start_addr = (ADDR)FLASH_BLK4_BASE_ADDR;
    f_ptr = (unsigned long *)FLASH_BLK4_BASE_ADDR;

    printf ("Writing Inverted Longword Data to FLASH...\n");
 
    /* write to all of available Flash ROM.  Don't do this thousands of times
       since the Flash has only 100,000 write cycles in its lifespan */

    while (bytes_written < (eeprom_size - RESERVED_AREA_SIZE)) {
	flash_data = (unsigned long)start_addr;
    	for (i=0; i<TEST_BUF_LONGS; i++) {
            flash_buffer[i] = ~flash_data;	/* put address BAR in buffer */
	    flash_data += 4;			/* increment address     */
	}
        if (write_eeprom (start_addr, (void *)flash_buffer, TEST_BUF_CHARS) != OK) {
            printf("Error on write_eeprom()\n");
            goto finish;
        }
        start_addr = (unsigned long)start_addr + TEST_BUF_CHARS;
        bytes_written += TEST_BUF_CHARS;
    }
 
    printf ("Write Complete, Verifying Data...\n");
    bytes_written = 0;
 
    while (bytes_written < (eeprom_size - RESERVED_AREA_SIZE)) {
        if (*f_ptr != (~(unsigned long)f_ptr)) {
            printf ("Data verification error at 0x%X\n", (unsigned long)f_ptr);
            printf ("Expected 0x%X Got 0x%X\n", (~(unsigned long)f_ptr), *f_ptr);
            goto finish;
        }
        f_ptr++;
        bytes_written += 4;
    }
    printf ("Done Verifying Inverted Longword Data!\n\n");


    printf ("Checking FLASH...\n");
    if (check_eeprom(NO_ADDR, 0) == OK)
        printf("FLASH is erased\n\n");
    else {
        printf("FLASH is programmed between 0x%X and 0x%X\n\n",
	       eeprom_prog_first, eeprom_prog_last);
    }

    printf ("Erasing FLASH...\n");
    if (erase_eeprom(NO_ADDR, 0) != OK)
        printf("Error on erase_eeprom()\n\n");
    else
        printf("Done Erasing FLASH!\n\n");

    printf ("Checking FLASH...\n");
    if (check_eeprom(NO_ADDR, 0) == OK)
        printf("FLASH is erased\n\n");
    else
        printf("FLASH is programmed between 0x%X and 0x%X\n\n",
	       eeprom_prog_first, eeprom_prog_last);

/* 11/02/00 */
    printf ("Setting Lock Bits for Blocks 0-3... \n");
    if( (status = set_all_lock_bits() ) == OK )
        printf("Done!\n");
    else
        printf("Error! status =0x%x\n", status);

finish:
    _flushICache();

    printf ("\nHit <CR> to Continue...\n");
    (void)hexIn();
    return;
}