void *NVMC_GetStatus(void) { if (isErased((uint8_t*)NVMC_STATUS_DATA_START_ADDR, NVMC_STATUS_DATA_SIZE)) { return NULL; } return (void*)NVMC_STATUS_DATA_START_ADDR; }
static void kill_block(EMCNANDDriver *emcnandp, uint32_t block){ size_t i = 0; size_t page = 0; uint8_t op_status; /* This test require good block.*/ osalDbgCheck(!emcnandIsBad(emcnandp, block)); while(true){ op_status = emcnandErase(&EMCNANDD1, block); if (0 != (op_status & 1)){ if(!isErased(emcnandp, block)) osalSysHalt("Block successfully killed"); } if(!isErased(emcnandp, block)) osalSysHalt("Block block not erased, but erase operation report success"); for (page=0; page<emcnandp->config->pages_per_block; page++){ memset(nand_buf, 0, NAND_PAGE_SIZE); op_status = emcnandWritePageWhole(emcnandp, block, page, nand_buf, NAND_PAGE_SIZE); if (0 != (op_status & 1)){ emcnandReadPageWhole(emcnandp, block, page, nand_buf, NAND_PAGE_SIZE); for (i=0; i<NAND_PAGE_SIZE; i++){ if (nand_buf[i] != 0) osalSysHalt("Block successfully killed"); } } emcnandReadPageWhole(emcnandp, block, page, nand_buf, NAND_PAGE_SIZE); for (i=0; i<NAND_PAGE_SIZE; i++){ if (nand_buf[i] != 0) osalSysHalt("Page write failed, but write operation report success"); } } KillCycle++; } }
static void general_test (EMCNANDDriver *emcnandp, size_t first, size_t last, size_t read_rounds){ size_t block, page, round; bool status; uint8_t op_status; uint32_t recc, wecc; red_led_on(); /* initialize time measurement units */ ////////////////////////////// FIXME ////////////////////////////// // tmObjectInit(&tmu_erase); // tmObjectInit(&tmu_write_data); // tmObjectInit(&tmu_write_spare); // tmObjectInit(&tmu_read_data); // tmObjectInit(&tmu_read_spare); /* perform basic checks */ for (block=first; block<last; block++){ if (!emcnandIsBad(emcnandp, block)){ if (!isErased(emcnandp, block)){ op_status = emcnandErase(emcnandp, block); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ } } } /* write block with pattern, read it back and compare */ for (block=first; block<last; block++){ if (!emcnandIsBad(emcnandp, block)){ for (page=0; page<emcnandp->config->pages_per_block; page++){ pattern_fill(); //tmStartMeasurement(&tmu_write_data); op_status = emcnandWritePageData(emcnandp, block, page, nand_buf, emcnandp->config->page_data_size, &wecc); //tmStopMeasurement(&tmu_write_data); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ //tmStartMeasurement(&tmu_write_spare); op_status = emcnandWritePageSpare(emcnandp, block, page, nand_buf + emcnandp->config->page_data_size, emcnandp->config->page_spare_size); //tmStopMeasurement(&tmu_write_spare); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ /* read back and compare */ for (round=0; round<read_rounds; round++){ memset(nand_buf, 0, NAND_PAGE_SIZE); //tmStartMeasurement(&tmu_read_data); emcnandReadPageData(emcnandp, block, page, nand_buf, emcnandp->config->page_data_size, &recc); //tmStopMeasurement(&tmu_read_data); osalDbgCheck(0 == (recc ^ wecc)); /* ECC error detected */ //tmStartMeasurement(&tmu_read_spare); emcnandReadPageSpare(emcnandp, block, page, nand_buf + emcnandp->config->page_data_size, emcnandp->config->page_spare_size); //tmStopMeasurement(&tmu_read_spare); osalDbgCheck(0 == memcmp(ref_buf, nand_buf, NAND_PAGE_SIZE)); /* Read back failed */ } } /* make clean */ //tmStartMeasurement(&tmu_erase); op_status = emcnandErase(emcnandp, block); //tmStopMeasurement(&tmu_erase); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ status = isErased(emcnandp, block); osalDbgCheck(true == status); /* blocks was not erased successfully */ }/* if (!emcnandIsBad(emcnandp, block)){ */ } red_led_off(); }
static void ecc_test(EMCNANDDriver *emcnandp, uint32_t block){ uint32_t corrupted; uint32_t byte, bit; const uint32_t ecclen = 28; uint32_t ecc_ref, ecc_broken; uint8_t op_status; ecc_result_t ecc_result = ECC_NO_ERROR; /* This test requires good block.*/ osalDbgCheck(!emcnandIsBad(emcnandp, block)); if (!isErased(emcnandp, block)) emcnandErase(&EMCNANDD1, block); pattern_fill(); /*** Correctable errors ***/ op_status = emcnandWritePageData(emcnandp, block, 0, nand_buf, emcnandp->config->page_data_size, &ecc_ref); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ emcnandReadPageData(emcnandp, block, 0, nand_buf, emcnandp->config->page_data_size, &ecc_broken); ecc_result = parse_ecc(ecclen, ecc_ref, ecc_broken, &corrupted); osalDbgCheck(ECC_NO_ERROR == ecc_result); /* unexpected error */ /**/ byte = 0; bit = 7; invert_bit(nand_buf, byte, bit); op_status = emcnandWritePageData(emcnandp, block, 1, nand_buf, emcnandp->config->page_data_size, &ecc_broken); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ invert_bit(nand_buf, byte, bit); ecc_result = parse_ecc(ecclen, ecc_ref, ecc_broken, &corrupted); osalDbgCheck(ECC_CORRECTABLE_ERROR == ecc_result); /* this error must be correctable */ osalDbgCheck(corrupted == (byte * 8 + bit)); /* wrong correction code */ /**/ byte = 2047; bit = 0; invert_bit(nand_buf, byte, bit); op_status = emcnandWritePageData(emcnandp, block, 2, nand_buf, emcnandp->config->page_data_size, &ecc_broken); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ invert_bit(nand_buf, byte, bit); ecc_result = parse_ecc(ecclen, ecc_ref, ecc_broken, &corrupted); osalDbgCheck(ECC_CORRECTABLE_ERROR == ecc_result); /* this error must be correctable */ osalDbgCheck(corrupted == (byte * 8 + bit)); /* wrong correction code */ /**/ byte = 1027; bit = 3; invert_bit(nand_buf, byte, bit); op_status = emcnandWritePageData(emcnandp, block, 3, nand_buf, emcnandp->config->page_data_size, &ecc_broken); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ invert_bit(nand_buf, byte, bit); ecc_result = parse_ecc(ecclen, ecc_ref, ecc_broken, &corrupted); osalDbgCheck(ECC_CORRECTABLE_ERROR == ecc_result); /* this error must be correctable */ osalDbgCheck(corrupted == (byte * 8 + bit)); /* wrong correction code */ /*** Uncorrectable error ***/ byte = 1027; invert_bit(nand_buf, byte, 3); invert_bit(nand_buf, byte, 4); op_status = emcnandWritePageData(emcnandp, block, 4, nand_buf, emcnandp->config->page_data_size, &ecc_broken); osalDbgCheck(0 == (op_status & 1)); /* operation failed */ invert_bit(nand_buf, byte, 3); invert_bit(nand_buf, byte, 4); ecc_result = parse_ecc(28, ecc_ref, ecc_broken, &corrupted); osalDbgCheck(ECC_UNCORRECTABLE_ERROR == ecc_result); /* This error must be NOT correctable */ /*** make clean ***/ emcnandErase(&EMCNANDD1, block); }
void *NVMC_GetReflectanceData(void) { if (isErased((uint8_t*)NVMC_REFLECTANCE_DATA_START_ADDR, NVMC_REFLECTANCE_DATA_SIZE)) { return NULL; } return (void*)NVMC_REFLECTANCE_DATA_START_ADDR; }