Nicolas Pitre nico at cam.org don't ignore bad options passed to the "nand write...
[openocd.git] / src / flash / nand.c
index a2d46cfdae3a358042d75c12b2501411c8631fd4..8708ef3c1b58a8d78f692784b6f235eaeb847af1 100644 (file)
@@ -204,10 +204,10 @@ int handle_nand_device_command(struct command_context_s *cmd_ctx, char *cmd, cha
                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));
@@ -287,7 +287,7 @@ int nand_init(struct command_context_s *cmd_ctx)
                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']");
        }
@@ -375,7 +375,7 @@ int nand_read_status(struct nand_device_s *device, u8 *status)
 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;
 
@@ -530,7 +530,7 @@ int nand_probe(struct nand_device_s *device)
                        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;
                }
        }
@@ -911,7 +911,10 @@ int nand_write_page_raw(struct nand_device_s *device, u32 page, u8 *data, u32 da
                 * 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);
@@ -1251,7 +1254,6 @@ int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cmd, char
                u8 *oob = NULL;
                u32 oob_size = 0;
                        
-               duration_start_measure(&duration);
                offset = strtoul(args[2], NULL, 0);
                
                if (argc > 3)
@@ -1266,10 +1268,13 @@ int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cmd, char
                                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;
@@ -1345,7 +1350,7 @@ int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cmd, char
                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;
@@ -1524,4 +1529,3 @@ int handle_nand_raw_access_command(struct command_context_s *cmd_ctx, char *cmd,
        
        return ERROR_OK;
 }
-

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)