]> git.sur5r.net Git - openocd/blobdiff - src/flash/ecos.c
More robust handling of unknown target state for step/continue packet.
[openocd] / src / flash / ecos.c
index 55e54e059f180bdb391c2c54c04092a6375815a0..b771d69480325096d89a8288556194c308cba5cc 100644 (file)
@@ -45,7 +45,6 @@ int ecosflash_erase(struct flash_bank_s *bank, int first, int last);
 int ecosflash_protect(struct flash_bank_s *bank, int set, int first, int last);
 int ecosflash_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
 int ecosflash_probe(struct flash_bank_s *bank);
-int ecosflash_erase_check(struct flash_bank_s *bank);
 int ecosflash_protect_check(struct flash_bank_s *bank);
 int ecosflash_info(struct flash_bank_s *bank, char *buf, int buf_size);
 
@@ -64,7 +63,7 @@ flash_driver_t ecosflash_flash =
        .write = ecosflash_write,
        .probe = ecosflash_probe,
        .auto_probe = ecosflash_probe,
-       .erase_check = ecosflash_erase_check,
+       .erase_check = default_flash_blank_check,
        .protect_check = ecosflash_protect_check,
        .info = ecosflash_info
 };
@@ -196,10 +195,11 @@ int loadDriver(ecosflash_flash_bank_t *info)
        image.base_address_set = 0;
        image.start_address_set = 0;
        target_t *target=info->target;
+       int retval;
        
-       if (image_open(&image, info->driverPath, NULL) != ERROR_OK)
+       if ((retval=image_open(&image, info->driverPath, NULL)) != ERROR_OK)
        {
-               return ERROR_FLASH_BANK_INVALID;
+               return retval;
        }
        
        info->start_address=image.start_address;
@@ -212,10 +212,9 @@ int loadDriver(ecosflash_flash_bank_t *info)
                int retval;
                if ((retval = image_read_section(&image, i, 0x0, image.sections[i].size, buffer, &buf_cnt)) != ERROR_OK)
                {
-                       LOG_ERROR("image_read_section failed with error code: %i", retval);
                        free(buffer);
                        image_close(&image);
-                       return ERROR_FLASH_BANK_INVALID;
+                       return retval;
                }
                target_write_buffer(target, image.sections[i].base_address, buf_cnt, buffer);
                image_size += buf_cnt;
@@ -304,7 +303,7 @@ int eCosBoard_erase(ecosflash_flash_bank_t *info, u32 address, u32 len)
        if (flashErr != 0x0)
        {
                LOG_ERROR("Flash erase failed with %d (%s)\n", flashErr, flash_errmsg(flashErr));
-               return ERROR_JTAG_DEVICE_ERROR;
+               return ERROR_FAIL;
        }
 
        return ERROR_OK;
@@ -363,7 +362,7 @@ int eCosBoard_flash(ecosflash_flash_bank_t *info, void *data, u32 address, u32 l
                if (flashErr != 0x0)
                {
                        LOG_ERROR("Flash prog failed with %d (%s)\n", flashErr, flash_errmsg(flashErr));
-                       return ERROR_JTAG_DEVICE_ERROR;
+                       return ERROR_FAIL;
                }
     }
        return ERROR_OK;
@@ -444,11 +443,6 @@ int ecosflash_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count
 }
 
 
-int ecosflash_erase_check(struct flash_bank_s *bank)
-{
-       return ERROR_OK;
-}
-
 int ecosflash_protect_check(struct flash_bank_s *bank)
 {
        return ERROR_OK;