if (strcmp(args[0], nand_flash_controllers[i]->name) == 0)
{
/* register flash specific commands */
- if (nand_flash_controllers[i]->register_commands(cmd_ctx) != ERROR_OK)
+ if ((retval = nand_flash_controllers[i]->register_commands(cmd_ctx)) != ERROR_OK)
{
LOG_ERROR("couldn't register '%s' commands", args[0]);
- exit(-1);
+ return retval;
}
c = malloc(sizeof(nand_device_t));
register_command(cmd_ctx, nand_cmd, "dump", handle_nand_dump_command, COMMAND_EXEC,
"dump from NAND flash device <num> <filename> <offset> <size> [options]");
register_command(cmd_ctx, nand_cmd, "write", handle_nand_write_command, COMMAND_EXEC,
- "write to NAND flash device <num> <filename> <offset> [options]");
+ "write to NAND flash device <num> <filename> <offset> [oob_raw|oob_only]");
register_command(cmd_ctx, nand_cmd, "raw_access", handle_nand_raw_access_command, COMMAND_EXEC,
"raw access to NAND flash device <num> ['enable'|'disable']");
}
int nand_probe(struct nand_device_s *device)
{
u8 manufacturer_id, device_id;
- u8 id_buff[5];
+ u8 id_buff[6];
int retval;
int i;
device->address_cycles = 5;
else
{
- LOG_ERROR("BUG: small page NAND device with more than 32 GiB encountered");
+ LOG_ERROR("BUG: large page NAND device with more than 32 GiB encountered");
device->address_cycles = 6;
}
}
* or 2048 for the beginning of OOB area)
*/
device->controller->address(device, 0x0);
- device->controller->address(device, 0x8);
+ if (data)
+ device->controller->address(device, 0x0);
+ else
+ device->controller->address(device, 0x8);
/* row */
device->controller->address(device, page & 0xff);
u8 *oob = NULL;
u32 oob_size = 0;
- duration_start_measure(&duration);
offset = strtoul(args[2], NULL, 0);
if (argc > 3)
else
{
command_print(cmd_ctx, "unknown option: %s", args[i]);
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
}
}
+ duration_start_measure(&duration);
+
if (fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY) != ERROR_OK)
{
return ERROR_OK;
oob = NULL;
page = NULL;
duration_stop_measure(&duration, &duration_text);
- command_print(cmd_ctx, "wrote file %s to NAND flash %s at offset 0x%8.8x in %s",
+ command_print(cmd_ctx, "wrote file %s to NAND flash %s up to offset 0x%8.8x in %s",
args[1], args[0], offset, duration_text);
free(duration_text);
duration_text = NULL;
return ERROR_OK;
}
-