- added str912/str710_program.script
[openocd.git] / src / flash / str9xpec.c
index 7a8fb2fec4ef51a6dfb0901b02fc64463e39a3c5..4a24d85d1117ff82ec39bdf4c043ce12d72e818b 100644 (file)
@@ -87,6 +87,7 @@ flash_driver_t str9xpec_flash =
        .protect = str9xpec_protect,
        .write = str9xpec_write,
        .probe = str9xpec_probe,
+       .auto_probe = str9xpec_probe,
        .erase_check = str9xpec_erase_check,
        .protect_check = str9xpec_protect_check,
        .info = str9xpec_info
@@ -125,6 +126,12 @@ int str9xpec_register_commands(struct command_context_s *cmd_ctx)
 int str9xpec_set_instr(int chain_pos, u32 new_instr, enum tap_state end_state)
 {
        jtag_device_t *device = jtag_get_device(chain_pos);
+       
+       if (device == NULL)
+       {
+               DEBUG("Invalid Target");
+               return ERROR_TARGET_INVALID;
+       }
                
        if (buf_get_u32(device->cur_instr, 0, device->ir_length) != new_instr)
        {
@@ -141,7 +148,7 @@ int str9xpec_set_instr(int chain_pos, u32 new_instr, enum tap_state end_state)
                field.in_handler = NULL;
                field.in_handler_priv = NULL;
                
-               jtag_add_ir_scan(1, &field, end_state, NULL);
+               jtag_add_ir_scan(1, &field, end_state);
                
                free(field.out_value);
        }
@@ -154,7 +161,8 @@ u8 str9xpec_isc_status(int chain_pos)
        scan_field_t field;
        u8 status;
        
-       str9xpec_set_instr(chain_pos, ISC_NOOP, TAP_PI);
+       if (str9xpec_set_instr(chain_pos, ISC_NOOP, TAP_PI) != ERROR_OK)
+               return ISC_STATUS_ERROR;
        
        field.device = chain_pos;
        field.num_bits = 8;
@@ -166,7 +174,7 @@ u8 str9xpec_isc_status(int chain_pos)
        field.in_handler = NULL;
        field.in_handler_priv = NULL;
        
-       jtag_add_dr_scan(1, &field, TAP_RTI, NULL);
+       jtag_add_dr_scan(1, &field, TAP_RTI);
        jtag_execute_queue();
        
        DEBUG("status: 0x%2.2x", status);
@@ -189,7 +197,8 @@ int str9xpec_isc_enable(struct flash_bank_s *bank)
                return ERROR_OK;
        
        /* enter isc mode */
-       str9xpec_set_instr(chain_pos, ISC_ENABLE, TAP_RTI);
+       if (str9xpec_set_instr(chain_pos, ISC_ENABLE, TAP_RTI) != ERROR_OK)
+               return ERROR_TARGET_INVALID;
        
        /* check ISC status */
        status = str9xpec_isc_status(chain_pos);
@@ -214,7 +223,8 @@ int str9xpec_isc_disable(struct flash_bank_s *bank)
        if (!str9xpec_info->isc_enable)
                return ERROR_OK;
        
-       str9xpec_set_instr(chain_pos, ISC_DISABLE, TAP_RTI);
+       if (str9xpec_set_instr(chain_pos, ISC_DISABLE, TAP_RTI) != ERROR_OK)
+               return ERROR_TARGET_INVALID;
        
        /* delay to handle aborts */
        jtag_add_sleep(50);
@@ -256,7 +266,7 @@ int str9xpec_read_config(struct flash_bank_s *bank)
        field.in_handler = NULL;
        field.in_handler_priv = NULL;
        
-       jtag_add_dr_scan(1, &field, TAP_RTI, NULL);
+       jtag_add_dr_scan(1, &field, TAP_RTI);
        jtag_execute_queue();
        
        status = str9xpec_isc_status(chain_pos);
@@ -273,10 +283,10 @@ int str9xpec_build_block_list(struct flash_bank_s *bank)
                
        switch (bank->size)
        {
-               case 256 * 1024:
+               case (256 * 1024):
                        b0_sectors = 4;
                        break;
-               case 512 * 1024:
+               case (512 * 1024):
                        b0_sectors = 8;
                        break;
                default:
@@ -284,7 +294,9 @@ int str9xpec_build_block_list(struct flash_bank_s *bank)
                        exit(-1);
        }
        
+       /* include bank 1 sectors */
        num_sectors = b0_sectors + 4;
+       bank->size += (32 * 1024);
        
        bank->num_sectors = num_sectors;
        bank->sectors = malloc(sizeof(flash_sector_t) * num_sectors);
@@ -397,7 +409,7 @@ int str9xpec_blank_check(struct flash_bank_s *bank, int first, int last)
        field.in_handler = NULL;
        field.in_handler_priv = NULL;
        
-       jtag_add_dr_scan(1, &field, TAP_RTI, NULL);
+       jtag_add_dr_scan(1, &field, TAP_RTI);
        jtag_add_sleep(40000);
        
        /* read blank check result */
@@ -411,7 +423,7 @@ int str9xpec_blank_check(struct flash_bank_s *bank, int first, int last)
        field.in_handler = NULL;
        field.in_handler_priv = NULL;
        
-       jtag_add_dr_scan(1, &field, TAP_PI, NULL);
+       jtag_add_dr_scan(1, &field, TAP_PI);
        jtag_execute_queue();
        
        status = str9xpec_isc_status(chain_pos);
@@ -513,7 +525,7 @@ int str9xpec_erase_area(struct flash_bank_s *bank, int first, int last)
        field.in_handler = NULL;
        field.in_handler_priv = NULL;
        
-       jtag_add_dr_scan(1, &field, TAP_RTI, NULL);
+       jtag_add_dr_scan(1, &field, TAP_RTI);
        jtag_execute_queue();
        
        jtag_add_sleep(10);
@@ -579,7 +591,7 @@ int str9xpec_lock_device(struct flash_bank_s *bank)
                field.in_handler = NULL;
                field.in_handler_priv = NULL;
                
-               jtag_add_dr_scan(1, &field, -1, NULL);
+               jtag_add_dr_scan(1, &field, -1);
                jtag_execute_queue();
                
        } while(!(status & ISC_STATUS_BUSY));
@@ -665,7 +677,7 @@ int str9xpec_set_address(struct flash_bank_s *bank, u8 sector)
        field.in_handler = NULL;
        field.in_handler_priv = NULL;
        
-       jtag_add_dr_scan(1, &field, -1, NULL);
+       jtag_add_dr_scan(1, &field, -1);
                
        return ERROR_OK;
 }
@@ -754,7 +766,7 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                        field.in_handler = NULL;
                        field.in_handler_priv = NULL;
                        
-                       jtag_add_dr_scan(1, &field, TAP_RTI, NULL);
+                       jtag_add_dr_scan(1, &field, TAP_RTI);
                        
                        /* small delay before polling */
                        jtag_add_sleep(50);
@@ -772,7 +784,7 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                                field.in_handler = NULL;
                                field.in_handler_priv = NULL;
                                
-                               jtag_add_dr_scan(1, &field, -1, NULL);
+                               jtag_add_dr_scan(1, &field, -1);
                                jtag_execute_queue();
                                
                                status = buf_get_u32(scanbuf, 0, 8);
@@ -780,10 +792,10 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                        } while(!(status & ISC_STATUS_BUSY));
                        
                        if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
-                               return ERROR_FLASH_OPERATION_FAILED; 
+                               return ERROR_FLASH_OPERATION_FAILED;
                        
-                       //if ((status & ISC_STATUS_INT_ERROR) != STR9XPEC_ISC_INTFAIL)
-                       //      return ERROR_FLASH_OPERATION_FAILED; 
+                       /if ((status & ISC_STATUS_INT_ERROR) != STR9XPEC_ISC_INTFAIL)
+                               return ERROR_FLASH_OPERATION_FAILED; */
                
                        dwords_remaining--;
                        bytes_written += 8;
@@ -814,7 +826,7 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                field.in_handler = NULL;
                field.in_handler_priv = NULL;
                
-               jtag_add_dr_scan(1, &field, TAP_RTI, NULL);
+               jtag_add_dr_scan(1, &field, TAP_RTI);
                
                /* small delay before polling */
                jtag_add_sleep(50);
@@ -832,7 +844,7 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                        field.in_handler = NULL;
                        field.in_handler_priv = NULL;
                        
-                       jtag_add_dr_scan(1, &field, -1, NULL);
+                       jtag_add_dr_scan(1, &field, -1);
                        jtag_execute_queue();
                        
                        status = buf_get_u32(scanbuf, 0, 8);
@@ -842,8 +854,8 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
                        return ERROR_FLASH_OPERATION_FAILED;
                
-               //if ((status & ISC_STATUS_INT_ERROR) != STR9XPEC_ISC_INTFAIL)
-               //      return ERROR_FLASH_OPERATION_FAILED; 
+               /if ((status & ISC_STATUS_INT_ERROR) != STR9XPEC_ISC_INTFAIL)
+                       return ERROR_FLASH_OPERATION_FAILED; */
        }
 
        free(scanbuf);
@@ -869,8 +881,7 @@ int str9xpec_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd
 
        if (argc < 1)
        {
-               command_print(cmd_ctx, "usage: str9xpec part_id <num>");
-               return ERROR_OK;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
        
        bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
@@ -897,7 +908,7 @@ int str9xpec_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd
        field.in_handler = NULL;
        field.in_handler_priv = NULL;
        
-       jtag_add_dr_scan(1, &field, TAP_RTI, NULL);
+       jtag_add_dr_scan(1, &field, TAP_RTI);
        jtag_execute_queue();
        
        idcode = buf_get_u32(buffer, 0, 32);
@@ -990,7 +1001,10 @@ int str9xpec_write_options(struct flash_bank_s *bank)
        chain_pos = str9xpec_info->chain_pos;
        
        /* erase config options first */
-       str9xpec_erase_area( bank, 0xFE, 0xFE );
+       status = str9xpec_erase_area( bank, 0xFE, 0xFE );
+       
+       if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
+               return status; 
        
        if (!str9xpec_info->isc_enable) {
                str9xpec_isc_enable( bank );
@@ -1019,7 +1033,7 @@ int str9xpec_write_options(struct flash_bank_s *bank)
        field.in_handler = NULL;
        field.in_handler_priv = NULL;
        
-       jtag_add_dr_scan(1, &field, TAP_RTI, NULL);
+       jtag_add_dr_scan(1, &field, TAP_RTI);
        
        /* small delay before polling */
        jtag_add_sleep(50);
@@ -1037,7 +1051,7 @@ int str9xpec_write_options(struct flash_bank_s *bank)
                field.in_handler = NULL;
                field.in_handler_priv = NULL;
                
-               jtag_add_dr_scan(1, &field, -1, NULL);
+               jtag_add_dr_scan(1, &field, -1);
                jtag_execute_queue();
                
        } while(!(status & ISC_STATUS_BUSY));
@@ -1327,6 +1341,7 @@ int str9xpec_handle_flash_disable_turbo_command(struct command_context_s *cmd_ct
        if( str9xpec_info->devarm ) {
                dev0->next = str9xpec_info->devarm;
                jtag_num_devices++;
+               str9xpec_info->devarm = NULL;
        }
        
        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)