index fde9899183ffe76923a69745eb0741f7bbcdf10a..f1baba6c6d070100f12f40a873bad7a427af9963 100755 (executable)
#include "types.h"
/* NAND writer utility version */
-char version[] = "01.00.00.03";
+char version[] = "01.00.00.04";
/* The input file name is hard coded */
char *input_file = "nand_writer_input.txt";
#define FILE_NAME "file_name"
#define START_ADDR "start_addr"
#define RBL_ECC "rbl_ecc"
+#define SKIP_BAD "skip_bad"
/* Memory address to store the write data */
#define WRITE_DATA_ADDRESS 0x80000000
uint32_t startAddr; /* Start address to write */
uint32_t writeBytes; /* Number of bytes to be written into the device */
uint8_t flags; /* Flag used for EVMK2H for multiple ECC formats */
+ uint8_t skip_bad_blks; /* Flag used to skip bad blocks */
uint8_t *writeData; /* Address to store the write data */
uint8_t *readData; /* Address to store the read data */
uint32_t wPos, wLen;
uint32_t block, start_block;
uint8_t *scrach_block;
+ uint32_t num_blks;
+ uint32_t bad_block_found;
if (swap_byte)
{
start_block = nandWriterInfo.startAddr / nandWriterInfo.blockSizeBytes;
+ /* skip the bad blocks if the flag is set */
+ if (nandWriterInfo.skip_bad_blks)
+ {
+ num_blks = nandWriterInfo.writeBytes / nandWriterInfo.blockSizeBytes;
+ if ((nandWriterInfo.writeBytes - nandWriterInfo.blockSizeBytes * num_blks) > 0)
+ num_blks++;
+
+ while (TRUE)
+ {
+ bad_block_found = FALSE;
+ for (block = start_block; block < start_block + num_blks; block++)
+ {
+ if (checkBadBlockMark(p_device, block))
+ {
+ start_block = block + 1;
+ bad_block_found = TRUE;
+ break;
+ }
+ }
+ if (bad_block_found == FALSE)
+ break;
+ }
+ }
+
/* Program the NAND */
for (block = start_block, wPos = 0; wPos < nandWriterInfo.writeBytes; block++, wPos += nandWriterInfo.blockSizeBytes)
{
nandWriterInfo.flags = 0;
}
+ /* Scan skip bad block input parameter */
+ fgets(line, MAX_LINE_LENGTH, fp);
+ key = (char *)strtok(line, tokens);
+ data = (char *)strtok(NULL, tokens);
+
+ if(strlen(data) != 0 && (strcmp(key, SKIP_BAD) == 0))
+ {
+ nandWriterInfo.skip_bad_blks = (uint8_t)atoi(data);
+ }
+ else
+ {
+ nandWriterInfo.skip_bad_blks = 0;
+ }
+
return TRUE;
}
memset(&init_flags, 1, sizeof(platform_init_flags));
init_flags.pll = 0;
init_flags.ddr = 0;
+ init_flags.phy =0;
if (platform_init(&init_flags, &init_config) != Platform_EOK)
{
printf ("Platform init failed!\n");
print_platform_errno();
return;
}
-#if (defined(_EVMC6657L_) || defined(DEVICE_K2H) || defined(DEVICE_K2K))
- p_device = platform_device_open(PLATFORM_DEVID_MT29F1G08ABCHC, nandWriterInfo.flags);
+#if (defined(_EVMC6657L_) || defined(DEVICE_K2H))
+ p_device = platform_device_open(PLATFORM_DEVID_MT29F1G08ABCHC, nandWriterInfo.flags);
+#elif defined(DEVICE_K2E)
+ p_device = platform_device_open(PLATFORM_DEVID_MT29F4G08ABADA, nandWriterInfo.flags);
+#elif defined(DEVICE_K2L)
+ p_device = platform_device_open(PLATFORM_DEVID_MT29F16G08ADBCAH4C, nandWriterInfo.flags);
#else
p_device = platform_device_open(PLATFORM_DEVID_NAND512R3A2D, 0);
#endif