mirror of
https://github.com/eclipse-threadx/levelx.git
synced 2026-09-14 04:06:00 +08:00
Updated copyright headers and removed trailing whitespace
This commit is contained in:
@@ -64,7 +64,7 @@ INT CorrectPageECC(UCHAR *data, INT size, UCHAR *code);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
/* Enter the ThreadX kernel. */
|
||||
#ifndef LX_STANDALONE_ENABLE
|
||||
tx_kernel_enter();
|
||||
@@ -82,8 +82,8 @@ void tx_application_define(void *first_unused_memory)
|
||||
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
}
|
||||
#endif
|
||||
@@ -109,10 +109,10 @@ UINT status;
|
||||
ULONG *word_ptr;
|
||||
UCHAR *byte_ptr;
|
||||
|
||||
|
||||
|
||||
/* Erase the simulated NOR flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
|
||||
/* Initialize LevelX. */
|
||||
_lx_nand_flash_initialize();
|
||||
|
||||
@@ -145,15 +145,15 @@ UCHAR *byte_ptr;
|
||||
#ifdef EXTENDED_CACHE
|
||||
lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
/* Write 520 sectors.... */
|
||||
for (i = 0; i < 520; i++)
|
||||
{
|
||||
for (j = 0; j < 512; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_write(&nand_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -165,7 +165,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Close and reopen the flash. */
|
||||
lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
@@ -187,9 +187,9 @@ UCHAR *byte_ptr;
|
||||
/* Read back 520 sectors... */
|
||||
for (i = 0; i < 520; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
#ifdef BATCH_TEST
|
||||
@@ -200,10 +200,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -222,11 +222,11 @@ UCHAR *byte_ptr;
|
||||
|
||||
/* Test 2: Write same sector 320 times. */
|
||||
printf("Test 2: Write same sector 320 times.............");
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
/* Reinitialize... */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
|
||||
|
||||
|
||||
lx_nand_flash_initialize();
|
||||
|
||||
status = lx_nand_flash_format(&nand_sim_flash, "sim nand flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
@@ -236,20 +236,20 @@ UCHAR *byte_ptr;
|
||||
#ifdef EXTENDED_CACHE
|
||||
lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
for (j = 0; j < 512; j++)
|
||||
buffer[j] = 0xFFFFFFFF;
|
||||
|
||||
|
||||
/* Write same sector 320 sectors.... */
|
||||
for (i = 0; i < 320; i++)
|
||||
{
|
||||
for (j = 0; j < 512; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
if (i == 319)
|
||||
buffer[j-1]--;
|
||||
status = lx_nand_flash_sector_write(&nand_sim_flash, 7, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -260,9 +260,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, 7, readbuffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -273,10 +273,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != readbuffer[j])
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -288,7 +288,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write other sectors just to have additional sectors to manage. */
|
||||
if (i == 1)
|
||||
lx_nand_flash_sector_write(&nand_sim_flash, 1, buffer);
|
||||
@@ -310,7 +310,7 @@ UCHAR *byte_ptr;
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -502,7 +502,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_NOT_SUPPORTED)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -513,9 +513,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -527,7 +527,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
|
||||
printf("Test 3: Page copy test..........................");
|
||||
|
||||
/* Reinitialize... */
|
||||
@@ -612,9 +612,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -760,7 +760,7 @@ UCHAR *byte_ptr;
|
||||
|
||||
while (sector_count--)
|
||||
{
|
||||
|
||||
|
||||
#ifdef FULL_SECTOR_DATA_VERIFY
|
||||
LX_MEMSET((local_data_buffer + sector_number * SECTOR_SIZE), data_byte, SECTOR_SIZE);
|
||||
#else
|
||||
@@ -816,25 +816,25 @@ UCHAR *byte_ptr;
|
||||
#if 0
|
||||
/* Point at the simulated NOR flash memory. */
|
||||
word_ptr = nand_flash_memory;
|
||||
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, but before the erase count is setup. */
|
||||
printf("Test 3: Block erase-initialize interrupted......");
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
word_ptr[3] = 0x00000000; /* This simulates a non-erased block. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 111) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -843,9 +843,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -857,22 +857,22 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption after erase of block 0,
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption after erase of block 0,
|
||||
but before erase count is setup. */
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 111) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -883,7 +883,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -899,23 +899,23 @@ UCHAR *byte_ptr;
|
||||
|
||||
/* Test 4: simulate a power interruption while a new page is being setup. */
|
||||
printf("Test 4: Power interrupted new page setup........");
|
||||
|
||||
|
||||
/* Partially setup new page. */
|
||||
byte_ptr = (UCHAR *) word_ptr;
|
||||
byte_ptr[2053] = 0xBF; /* Set block 0/page 0 extra bytes to indicate block not empty. */
|
||||
word_ptr[528] = 0x60;
|
||||
|
||||
/* Open the flash and see if we recover properly. We should mark this page as obsolete. */
|
||||
/* Open the flash and see if we recover properly. We should mark this page as obsolete. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 110) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -924,9 +924,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -942,28 +942,28 @@ UCHAR *byte_ptr;
|
||||
/* Simulate a power interruption after a new sector is allocated, after data
|
||||
had been copied, and the superceeded bit is clear, but before the new entry can be
|
||||
setup. */
|
||||
|
||||
|
||||
/* Copy data block and reset spare. */
|
||||
byte_ptr[2053] = 0xBF; /* Set block 0/page 0 extra bytes to indicate block not empty. */
|
||||
for (i = 1; i < 512; i++) /* Fill block 0, page 1 data */
|
||||
word_ptr[i+528] = 0x60;
|
||||
word_ptr[i+528] = 0x60;
|
||||
word_ptr[i+528] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
word_ptr[i+529] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
|
||||
word_ptr[i+529] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
|
||||
/* Set the superceded bit in block 1/page 1. */
|
||||
byte_ptr[37957] = 0x80;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 110) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -980,10 +980,10 @@ UCHAR *byte_ptr;
|
||||
has not been invalidated. */
|
||||
byte_ptr[2053] = 0xBF; /* Set block 0/page 0 extra bytes to indicate block not empty. */
|
||||
for (i = 1; i < 512; i++) /* Fill block 0, page 1 data */
|
||||
word_ptr[i+528] = 0x60;
|
||||
word_ptr[i+528] = 0x60;
|
||||
word_ptr[i+528] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
word_ptr[i+529] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
|
||||
|
||||
byte_ptr = (UCHAR *) word_ptr;
|
||||
|
||||
/* set the spare info in the new page. */
|
||||
@@ -995,17 +995,17 @@ UCHAR *byte_ptr;
|
||||
/* Set the superceded bit in block 1/page 1. */
|
||||
byte_ptr[37957] = 0x80;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 110) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1206,7 +1206,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_NOT_SUPPORTED)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1217,10 +1217,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_NOT_SUPPORTED)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1231,7 +1231,7 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1612,7 +1612,7 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_release(&nand_sim_flash, 7);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1635,9 +1635,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1661,7 +1661,7 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("SUCCESS!\n");
|
||||
#endif
|
||||
#if 0
|
||||
@@ -1670,15 +1670,15 @@ UCHAR *byte_ptr;
|
||||
/* Erase the simulated NOR flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1687,15 +1687,15 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 512; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_write(&nand_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1707,13 +1707,13 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1724,10 +1724,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 512; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1740,18 +1740,18 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now, perform 1000 sector writes to randomly selected sectors, each time
|
||||
reading first to make sure the previous contents are valid. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Pickup random sector. */
|
||||
sector = (rand() % 100);
|
||||
|
||||
/* Read that sector. */
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, sector, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1762,10 +1762,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 512; j++)
|
||||
{
|
||||
|
||||
|
||||
if ((buffer[j] & 0x0000FFFF) != sector)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1781,10 +1781,10 @@ UCHAR *byte_ptr;
|
||||
/* Include the itteraction in the buffer to generate a new write. */
|
||||
for (j = 0; j < 512; j++)
|
||||
{
|
||||
|
||||
|
||||
buffer[j] = (buffer[j] & 0x0000FFFF) | (i << 16);
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_write(&nand_sim_flash, sector, buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
@@ -1798,9 +1798,9 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1813,22 +1813,22 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Setup buffer. */
|
||||
for (j = 0; j < 2048; j++)
|
||||
byte_buffer[j] = (UCHAR) (rand() % 256);
|
||||
|
||||
|
||||
/* Call the ECC calculate routine. */
|
||||
ComputePageECC(byte_buffer, 2048, ecc_bytes);
|
||||
status = (UINT) CorrectPageECC(byte_buffer, 2048, ecc_bytes);
|
||||
if (status != 0)
|
||||
{
|
||||
|
||||
|
||||
/* Check for corrected return value. */
|
||||
if (status != 1)
|
||||
{
|
||||
@@ -1837,7 +1837,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Call LevelX ECC routines to do the same thing. */
|
||||
status = lx_nand_flash_page_ecc_compute(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
@@ -1851,17 +1851,17 @@ UCHAR *byte_ptr;
|
||||
|
||||
// ComputePageECC(byte_buffer, 2048, ecc_bytes);
|
||||
|
||||
|
||||
|
||||
/* Determine if there is any difference between the original and the new ECC routine. */
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
(ecc_bytes[1] != lx_ecc_buffer[1]) ||
|
||||
(ecc_bytes[2] != lx_ecc_buffer[2]) ||
|
||||
(ecc_bytes[3] != lx_ecc_buffer[3]) ||
|
||||
(ecc_bytes[4] != lx_ecc_buffer[4]) ||
|
||||
(ecc_bytes[5] != lx_ecc_buffer[5]) ||
|
||||
(ecc_bytes[6] != lx_ecc_buffer[6]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[9] != lx_ecc_buffer[9]) ||
|
||||
(ecc_bytes[10] != lx_ecc_buffer[10]) ||
|
||||
(ecc_bytes[11] != lx_ecc_buffer[11]))
|
||||
@@ -1875,7 +1875,7 @@ UCHAR *byte_ptr;
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Is it the corrected status? */
|
||||
if (status != LX_NAND_ERROR_CORRECTED)
|
||||
{
|
||||
@@ -1888,23 +1888,23 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 0
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Setup buffer. */
|
||||
for (j = 0; j < 2048; j++)
|
||||
byte_buffer[j] = (UCHAR) (rand() % 256);
|
||||
|
||||
|
||||
/* Call the ECC calculate routine. */
|
||||
ComputePageECC(byte_buffer, 2048, ecc_bytes);
|
||||
|
||||
|
||||
/* Corrupt a bit in each 256 byte page. */
|
||||
if (byte_buffer[7] & 1)
|
||||
byte_buffer[7] = byte_buffer[7] & 0xFE;
|
||||
else
|
||||
byte_buffer[7] = byte_buffer[7] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[277] & 1)
|
||||
byte_buffer[277] = byte_buffer[277] & 0xFE;
|
||||
else
|
||||
@@ -1914,12 +1914,12 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[577] = byte_buffer[577] & 0xFE;
|
||||
else
|
||||
byte_buffer[577] = byte_buffer[577] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[777] & 1)
|
||||
byte_buffer[777] = byte_buffer[777] & 0xFE;
|
||||
else
|
||||
byte_buffer[777] = byte_buffer[777] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[1077] & 1)
|
||||
byte_buffer[1077] = byte_buffer[1077] & 0xFE;
|
||||
else
|
||||
@@ -1929,7 +1929,7 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[1297] = byte_buffer[1297] & 0xFE;
|
||||
else
|
||||
byte_buffer[1297] = byte_buffer[1297] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[1636] & 1)
|
||||
byte_buffer[1636] = byte_buffer[1636] & 0xFE;
|
||||
else
|
||||
@@ -1939,12 +1939,12 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[1892] = byte_buffer[1892] & 0xFE;
|
||||
else
|
||||
byte_buffer[1892] = byte_buffer[1892] | 1;
|
||||
|
||||
|
||||
|
||||
|
||||
status = (UINT) CorrectPageECC(byte_buffer, 2048, ecc_bytes);
|
||||
if (status != 0)
|
||||
{
|
||||
|
||||
|
||||
/* Check for corrected return value. */
|
||||
if (status != 1)
|
||||
{
|
||||
@@ -1953,7 +1953,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Call LevelX ECC routines to do the same thing. */
|
||||
status = lx_nand_flash_page_ecc_compute(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
@@ -1966,17 +1966,17 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Determine if there is any difference between the original and the new ECC routine. */
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
(ecc_bytes[1] != lx_ecc_buffer[1]) ||
|
||||
(ecc_bytes[2] != lx_ecc_buffer[2]) ||
|
||||
(ecc_bytes[3] != lx_ecc_buffer[3]) ||
|
||||
(ecc_bytes[4] != lx_ecc_buffer[4]) ||
|
||||
(ecc_bytes[5] != lx_ecc_buffer[5]) ||
|
||||
(ecc_bytes[6] != lx_ecc_buffer[6]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[9] != lx_ecc_buffer[9]) ||
|
||||
(ecc_bytes[10] != lx_ecc_buffer[10]) ||
|
||||
(ecc_bytes[11] != lx_ecc_buffer[11]))
|
||||
@@ -1991,7 +1991,7 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[7] = byte_buffer[7] & 0xFE;
|
||||
else
|
||||
byte_buffer[7] = byte_buffer[7] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[277] & 1)
|
||||
byte_buffer[277] = byte_buffer[277] & 0xFE;
|
||||
else
|
||||
@@ -2001,12 +2001,12 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[577] = byte_buffer[577] & 0xFE;
|
||||
else
|
||||
byte_buffer[577] = byte_buffer[577] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[777] & 1)
|
||||
byte_buffer[777] = byte_buffer[777] & 0xFE;
|
||||
else
|
||||
byte_buffer[777] = byte_buffer[777] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[1077] & 1)
|
||||
byte_buffer[1077] = byte_buffer[1077] & 0xFE;
|
||||
else
|
||||
@@ -2016,7 +2016,7 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[1297] = byte_buffer[1297] & 0xFE;
|
||||
else
|
||||
byte_buffer[1297] = byte_buffer[1297] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[1636] & 1)
|
||||
byte_buffer[1636] = byte_buffer[1636] & 0xFE;
|
||||
else
|
||||
@@ -2026,12 +2026,12 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[1892] = byte_buffer[1892] & 0xFE;
|
||||
else
|
||||
byte_buffer[1892] = byte_buffer[1892] | 1;
|
||||
|
||||
|
||||
status = lx_nand_flash_page_ecc_check(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Is it the corrected status? */
|
||||
if (status != LX_NAND_ERROR_CORRECTED)
|
||||
{
|
||||
@@ -2064,22 +2064,22 @@ UCHAR *byte_ptr;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
#if 0
|
||||
|
||||
/* Corrupting ECC code is detected and returns a failure... this test is not valid! */
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Setup buffer. */
|
||||
for (j = 0; j < 2048; j++)
|
||||
byte_buffer[j] = (UCHAR) (rand() % 256);
|
||||
|
||||
|
||||
/* Call the ECC calculate routine. */
|
||||
ComputePageECC(byte_buffer, 2048, ecc_bytes);
|
||||
|
||||
|
||||
|
||||
|
||||
/* Call LevelX ECC routines to do the same thing. */
|
||||
status = lx_nand_flash_page_ecc_compute(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
@@ -2092,15 +2092,15 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
/* Determine if there is any difference between the original and the new ECC routine. */
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
(ecc_bytes[1] != lx_ecc_buffer[1]) ||
|
||||
(ecc_bytes[2] != lx_ecc_buffer[2]) ||
|
||||
(ecc_bytes[3] != lx_ecc_buffer[3]) ||
|
||||
(ecc_bytes[4] != lx_ecc_buffer[4]) ||
|
||||
(ecc_bytes[5] != lx_ecc_buffer[5]) ||
|
||||
(ecc_bytes[6] != lx_ecc_buffer[6]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[9] != lx_ecc_buffer[9]) ||
|
||||
(ecc_bytes[10] != lx_ecc_buffer[10]) ||
|
||||
(ecc_bytes[11] != lx_ecc_buffer[11]))
|
||||
@@ -2115,7 +2115,7 @@ UCHAR *byte_ptr;
|
||||
ecc_bytes[1] = ecc_bytes[1] & 0xFE;
|
||||
else
|
||||
ecc_bytes[1] = ecc_bytes[1] | 1;
|
||||
|
||||
|
||||
if (ecc_bytes[4] & 1)
|
||||
ecc_bytes[4] = ecc_bytes[4] & 0xFE;
|
||||
else
|
||||
@@ -2125,12 +2125,12 @@ UCHAR *byte_ptr;
|
||||
ecc_bytes[7] = ecc_bytes[7] & 0xFE;
|
||||
else
|
||||
ecc_bytes[7] = ecc_bytes[7] | 1;
|
||||
|
||||
|
||||
if (ecc_bytes[10] & 1)
|
||||
ecc_bytes[10] = ecc_bytes[10] & 0xFE;
|
||||
else
|
||||
ecc_bytes[10] = ecc_bytes[10] | 1;
|
||||
|
||||
|
||||
if (ecc_bytes[13] & 1)
|
||||
ecc_bytes[13] = ecc_bytes[13] & 0xFE;
|
||||
else
|
||||
@@ -2140,7 +2140,7 @@ UCHAR *byte_ptr;
|
||||
ecc_bytes[16] = ecc_bytes[16] & 0xFE;
|
||||
else
|
||||
ecc_bytes[16] = ecc_bytes[16] | 1;
|
||||
|
||||
|
||||
if (ecc_bytes[19] & 1)
|
||||
ecc_bytes[19] = ecc_bytes[19] & 0xFE;
|
||||
else
|
||||
@@ -2150,12 +2150,12 @@ UCHAR *byte_ptr;
|
||||
ecc_bytes[22] = ecc_bytes[22] & 0xFE;
|
||||
else
|
||||
ecc_bytes[22] = ecc_bytes[22] | 1;
|
||||
|
||||
|
||||
|
||||
|
||||
status = (UINT) CorrectPageECC(byte_buffer, 2048, ecc_bytes);
|
||||
if (status != 0)
|
||||
{
|
||||
|
||||
|
||||
/* Check for corrected return value. */
|
||||
if (status != 1)
|
||||
{
|
||||
@@ -2170,7 +2170,7 @@ UCHAR *byte_ptr;
|
||||
lx_ecc_buffer[1] = lx_ecc_buffer[1] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[1] = lx_ecc_buffer[1] | 1;
|
||||
|
||||
|
||||
if (lx_ecc_buffer[4] & 1)
|
||||
lx_ecc_buffer[4] = lx_ecc_buffer[4] & 0xFE;
|
||||
else
|
||||
@@ -2180,12 +2180,12 @@ UCHAR *byte_ptr;
|
||||
lx_ecc_buffer[7] = lx_ecc_buffer[7] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[7] = lx_ecc_buffer[7] | 1;
|
||||
|
||||
|
||||
if (lx_ecc_buffer[10] & 1)
|
||||
lx_ecc_buffer[10] = lx_ecc_buffer[10] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[10] = lx_ecc_buffer[10] | 1;
|
||||
|
||||
|
||||
if (lx_ecc_buffer[13] & 1)
|
||||
lx_ecc_buffer[13] = lx_ecc_buffer[13] & 0xFE;
|
||||
else
|
||||
@@ -2195,7 +2195,7 @@ UCHAR *byte_ptr;
|
||||
lx_ecc_buffer[16] = lx_ecc_buffer[16] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[16] = lx_ecc_buffer[16] | 1;
|
||||
|
||||
|
||||
if (lx_ecc_buffer[19] & 1)
|
||||
lx_ecc_buffer[19] = lx_ecc_buffer[19] & 0xFE;
|
||||
else
|
||||
@@ -2205,14 +2205,14 @@ UCHAR *byte_ptr;
|
||||
lx_ecc_buffer[22] = lx_ecc_buffer[22] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[22] = lx_ecc_buffer[22] | 1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nand_flash_page_ecc_check(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Is it the corrected status? */
|
||||
if (status != LX_NAND_ERROR_CORRECTED)
|
||||
{
|
||||
@@ -2245,24 +2245,24 @@ UCHAR *byte_ptr;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
/* TEST FileX packing routines. */
|
||||
|
||||
/* Erase the simulated NAND flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize);
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
while(1)
|
||||
{
|
||||
@@ -2294,7 +2294,7 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
_fx_nand_flash_read_sectors(i, 1, (UCHAR *) &test_read[i].words[0]);
|
||||
}
|
||||
|
||||
|
||||
/* Setup the read buffer. */
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
@@ -2315,9 +2315,9 @@ UCHAR *byte_ptr;
|
||||
|
||||
_fx_nand_flash_read_sectors(0, 8, (UCHAR *) &test_read[0].words[0]);
|
||||
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -2329,15 +2329,15 @@ UCHAR *byte_ptr;
|
||||
/* Erase the simulated NAND flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize);
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
while(1)
|
||||
{
|
||||
@@ -2360,7 +2360,7 @@ UCHAR *byte_ptr;
|
||||
_fx_nand_flash_read_sectors(3, 5, (UCHAR *) &test_read[3].words[0]);
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -2369,9 +2369,9 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* End */
|
||||
#endif
|
||||
|
||||
/* End */
|
||||
#endif
|
||||
|
||||
#ifdef BATCH_TEST
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ void thread_0_entry(ULONG thread_input);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
/* Enter the ThreadX kernel. */
|
||||
#ifndef LX_STANDALONE_ENABLE
|
||||
tx_kernel_enter();
|
||||
@@ -52,8 +52,8 @@ void tx_application_define(void *first_unused_memory)
|
||||
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
}
|
||||
#endif
|
||||
@@ -68,27 +68,27 @@ UINT status;
|
||||
|
||||
ULONG *word_ptr;
|
||||
|
||||
|
||||
|
||||
/* format the simulated NOR flash. */
|
||||
|
||||
|
||||
/* Initialize LevelX. */
|
||||
_lx_nor_flash_initialize();
|
||||
|
||||
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
|
||||
/* Test 1: Simple write 100 sectors and read 100 sectors. */
|
||||
printf("Test 1: Simple write-read 100 sectors...........");
|
||||
|
||||
|
||||
lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -100,13 +100,13 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -117,10 +117,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -139,9 +139,9 @@ ULONG *word_ptr;
|
||||
|
||||
/* Test 2: Write same sector 120 times. */
|
||||
printf("Test 2: Write same sector 120 times.............");
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
lx_nor_flash_initialize();
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
|
||||
@@ -149,15 +149,15 @@ ULONG *word_ptr;
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = 0xFFFFFFFF;
|
||||
|
||||
|
||||
/* Write same sector 120 sectors.... */
|
||||
for (i = 0; i < 120; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, 7, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -168,9 +168,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -181,10 +181,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != readbuffer[j])
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -196,7 +196,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write other sectors just to have additional sectors to manage. */
|
||||
if (i == 1)
|
||||
lx_nor_flash_sector_write(&nor_sim_flash, 1, buffer);
|
||||
@@ -218,7 +218,7 @@ ULONG *word_ptr;
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -410,7 +410,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -421,13 +421,13 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Point at the simulated NOR flash memory. */
|
||||
word_ptr = nor_sim_flash.lx_nor_flash_base_address;
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -439,21 +439,21 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, but before the free bit map and erase count is setup. */
|
||||
printf("Test 3: Block erase-initialize interrupted......");
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
word_ptr[3] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -462,9 +462,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -475,19 +475,19 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, and after the free bit map setup, but before erase count is setup. */
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -498,7 +498,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -516,14 +516,14 @@ ULONG *word_ptr;
|
||||
printf("Test 4: Power interrupted new block allocation..");
|
||||
word_ptr[3] = word_ptr[3] & ~((ULONG) 1);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 110) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -532,9 +532,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -550,14 +550,14 @@ ULONG *word_ptr;
|
||||
anything else can be done. */
|
||||
word_ptr[(16*128)+3] = 0x7C00;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 109) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -568,7 +568,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -585,15 +585,15 @@ ULONG *word_ptr;
|
||||
setup. */
|
||||
word_ptr[3] = 0x7FFC;
|
||||
word_ptr[(16*128)+6] = word_ptr[(16*128)+6] & ~((ULONG) 0x40000000);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 108) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -604,7 +604,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
/* Simulate a power interruption after a new sector is allocated, after data
|
||||
had been copied, and the superceeded bit is clear, the new entry is setup, but the old entry
|
||||
has not been invalidated. */
|
||||
@@ -614,15 +614,15 @@ ULONG *word_ptr;
|
||||
{
|
||||
word_ptr[(3*128)+i] = 0x70;
|
||||
}
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 107) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -823,7 +823,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -834,10 +834,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -848,7 +848,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1229,7 +1229,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_release(&nor_sim_flash, 7);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1252,9 +1252,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1278,7 +1278,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
printf("Test 5: Randow write/read sector................");
|
||||
@@ -1286,12 +1286,12 @@ ULONG *word_ptr;
|
||||
/* format the simulated NOR flash. */
|
||||
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1300,15 +1300,15 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1320,13 +1320,13 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1337,10 +1337,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1353,18 +1353,18 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now, perform 1000 sector writes to randomly selected sectors, each time
|
||||
reading first to make sure the previous contents are valid. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Pickup random sector. */
|
||||
sector = (rand() % 100);
|
||||
|
||||
/* Read that sector. */
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, sector, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1375,10 +1375,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if ((buffer[j] & 0x0000FFFF) != sector)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1394,10 +1394,10 @@ ULONG *word_ptr;
|
||||
/* Include the itteraction in the buffer to generate a new write. */
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
buffer[j] = (buffer[j] & 0x0000FFFF) | (i << 16);
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, sector, buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
@@ -1411,9 +1411,9 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
|
||||
@@ -38,7 +38,7 @@ void thread_0_entry(ULONG thread_input);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
/* Enter the ThreadX kernel. */
|
||||
#ifndef LX_STANDALONE_ENABLE
|
||||
tx_kernel_enter();
|
||||
@@ -56,8 +56,8 @@ void tx_application_define(void *first_unused_memory)
|
||||
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
}
|
||||
#endif
|
||||
@@ -72,13 +72,13 @@ UINT status;
|
||||
|
||||
ULONG *word_ptr;
|
||||
|
||||
|
||||
|
||||
/* Initialize LevelX. */
|
||||
_lx_nor_flash_initialize();
|
||||
|
||||
|
||||
/* Test 1: Simple write 100 sectors and read 100 sectors. */
|
||||
printf("Test 1: Simple write-read 100 sectors...........");
|
||||
|
||||
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
@@ -115,9 +115,9 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -129,13 +129,13 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -146,10 +146,10 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -198,9 +198,9 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
/* Release 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_release(&nor_sim_flash, i);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -262,9 +262,9 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
|
||||
/* Test 2: Write same sector 120 times. */
|
||||
printf("Test 2: Write same sector 120 times.............");
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
lx_nor_flash_initialize();
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
@@ -274,15 +274,15 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = 0xFFFFFFFF;
|
||||
|
||||
|
||||
/* Write same sector 120 sectors.... */
|
||||
for (i = 0; i < 120; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, 7, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -293,9 +293,9 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -306,10 +306,10 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != readbuffer[j])
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -321,7 +321,7 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write other sectors just to have additional sectors to manage. */
|
||||
if (i == 1)
|
||||
lx_nor_flash_sector_write(&nor_sim_flash, 1, buffer);
|
||||
@@ -343,7 +343,7 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -535,7 +535,7 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -546,13 +546,13 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Point at the simulated NOR flash memory. */
|
||||
word_ptr = nor_sim_flash.lx_nor_flash_base_address;
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -564,14 +564,14 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
}
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, but before the free bit map and erase count is setup. */
|
||||
printf("Test 3: Block erase-initialize interrupted......");
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
word_ptr[3] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -581,7 +581,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -590,9 +590,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -603,12 +603,12 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, and after the free bit map setup, but before erase count is setup. */
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -618,7 +618,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -629,7 +629,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -647,7 +647,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
printf("Test 4: Power interrupted new block allocation..");
|
||||
word_ptr[3] = word_ptr[3] & ~((ULONG) 1);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -657,7 +657,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 110) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -666,9 +666,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -684,7 +684,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
anything else can be done. */
|
||||
word_ptr[(16*128)+3] = 0x7C00;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -694,7 +694,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 109) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -705,7 +705,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -722,8 +722,8 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
setup. */
|
||||
word_ptr[3] = 0x7FFC;
|
||||
word_ptr[(16*128)+6] = word_ptr[(16*128)+6] & ~((ULONG) 0x40000000);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -733,7 +733,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 108) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -744,7 +744,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
|
||||
lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
/* Simulate a power interruption after a new sector is allocated, after data
|
||||
had been copied, and the superceeded bit is clear, the new entry is setup, but the old entry
|
||||
has not been invalidated. */
|
||||
@@ -754,8 +754,8 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
word_ptr[(3*128)+i] = 0x70;
|
||||
}
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -765,7 +765,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 107) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -966,7 +966,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -977,10 +977,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -991,7 +991,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1372,7 +1372,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_release(&nor_sim_flash, 7);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1395,9 +1395,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1421,24 +1421,24 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
printf("Test 5: Randow write/read sector................");
|
||||
|
||||
/*format the simulated NOR flash. */
|
||||
|
||||
|
||||
/* Open the flash. */
|
||||
|
||||
/* Open the flash. */
|
||||
status = lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1447,15 +1447,15 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1467,13 +1467,13 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1484,10 +1484,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1500,18 +1500,18 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now, perform 1000 sector writes to randomly selected sectors, each time
|
||||
reading first to make sure the previous contents are valid. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Pickup random sector. */
|
||||
sector = (rand() % 100);
|
||||
|
||||
/* Read that sector. */
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, sector, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1522,10 +1522,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if ((buffer[j] & 0x0000FFFF) != sector)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1541,10 +1541,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
/* Include the itteraction in the buffer to generate a new write. */
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
buffer[j] = (buffer[j] & 0x0000FFFF) | (i << 16);
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, sector, buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
@@ -1558,9 +1558,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1578,15 +1578,15 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
/* Format the simulated NOR flash. */
|
||||
status = lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2, sizeof(nor_cache_memory2));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1601,9 +1601,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1615,13 +1615,13 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1632,10 +1632,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1648,7 +1648,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef BATCH_TEST
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user