fix flash info - now reports erased state properly
git-svn-id: svn://svn.berlios.de/openocd/trunk@534 b42882b7-edfa-0310-969c-e2dbd0fdcd60__archive__
parent
2a2935573e
commit
6549d376e4
|
@ -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
|
||||
};
|
||||
|
@ -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;
|
||||
|
|
|
@ -334,7 +334,11 @@ int handle_flash_info_command(struct command_context_s *cmd_ctx, char *cmd, char
|
|||
char buf[1024];
|
||||
|
||||
/* attempt auto probe */
|
||||
p->driver->auto_probe(p);
|
||||
if ((retval = p->driver->auto_probe(p)) != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
if ((retval = p->driver->erase_check(p)) != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
command_print(cmd_ctx, "#%i: %s at 0x%8.8x, size 0x%8.8x, buswidth %i, chipwidth %i",
|
||||
i, p->driver->name, p->base, p->size, p->bus_width, p->chip_width);
|
||||
|
@ -1049,3 +1053,51 @@ int handle_flash_auto_erase_command(struct command_context_s *cmd_ctx, char *cmd
|
|||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
int default_flash_blank_check(struct flash_bank_s *bank)
|
||||
{
|
||||
target_t *target = bank->target;
|
||||
u8 buffer[1024];
|
||||
int buffer_size=sizeof(buffer);
|
||||
int i;
|
||||
int nBytes;
|
||||
|
||||
if (bank->target->state != TARGET_HALTED)
|
||||
{
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
{
|
||||
int j;
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
for (j=0; j<bank->sectors[i].size; j+=buffer_size)
|
||||
{
|
||||
int chunk;
|
||||
int retval;
|
||||
chunk=buffer_size;
|
||||
if (chunk>(j-bank->sectors[i].size))
|
||||
{
|
||||
chunk=(j-bank->sectors[i].size);
|
||||
}
|
||||
|
||||
retval=target->type->read_memory(target, bank->base + bank->sectors[i].offset, 4, chunk/4, buffer);
|
||||
if (retval!=ERROR_OK)
|
||||
return retval;
|
||||
|
||||
for (nBytes = 0; nBytes < chunk; nBytes++)
|
||||
{
|
||||
if (buffer[nBytes] != 0xFF)
|
||||
{
|
||||
bank->sectors[i].is_erased = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ extern int flash_erase_address_range(target_t *target, u32 addr, u32 length);
|
|||
extern int flash_write(target_t *target, image_t *image, u32 *written, int erase);
|
||||
extern void flash_set_dirty(void);
|
||||
extern int flash_get_bank_count();
|
||||
int default_flash_blank_check(struct flash_bank_s *bank);
|
||||
|
||||
extern flash_bank_t *get_flash_bank_by_num(int num);
|
||||
extern flash_bank_t *get_flash_bank_by_num_noprobe(int num);
|
||||
|
|
|
@ -56,7 +56,6 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
|
|||
int str7x_probe(struct flash_bank_s *bank);
|
||||
int str7x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
|
||||
int str7x_protect_check(struct flash_bank_s *bank);
|
||||
int str7x_erase_check(struct flash_bank_s *bank);
|
||||
int str7x_info(struct flash_bank_s *bank, char *buf, int buf_size);
|
||||
|
||||
int str7x_handle_disable_jtag_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
|
||||
|
@ -71,7 +70,7 @@ flash_driver_t str7x_flash =
|
|||
.write = str7x_write,
|
||||
.probe = str7x_probe,
|
||||
.auto_probe = str7x_probe,
|
||||
.erase_check = str7x_erase_check,
|
||||
.erase_check = default_flash_blank_check,
|
||||
.protect_check = str7x_protect_check,
|
||||
.info = str7x_info
|
||||
};
|
||||
|
@ -240,43 +239,6 @@ u32 str7x_result(struct flash_bank_s *bank)
|
|||
return retval;
|
||||
}
|
||||
|
||||
int str7x_blank_check(struct flash_bank_s *bank, int first, int last)
|
||||
{
|
||||
target_t *target = bank->target;
|
||||
u8 *buffer;
|
||||
int i;
|
||||
int nBytes;
|
||||
|
||||
if ((first < 0) || (last > bank->num_sectors))
|
||||
return ERROR_FLASH_SECTOR_INVALID;
|
||||
|
||||
if (bank->target->state != TARGET_HALTED)
|
||||
{
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
buffer = malloc(256);
|
||||
|
||||
for (i = first; i <= last; i++)
|
||||
{
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
target->type->read_memory(target, bank->base + bank->sectors[i].offset, 4, 256/4, buffer);
|
||||
|
||||
for (nBytes = 0; nBytes < 256; nBytes++)
|
||||
{
|
||||
if (buffer[nBytes] != 0xFF)
|
||||
{
|
||||
bank->sectors[i].is_erased = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int str7x_protect_check(struct flash_bank_s *bank)
|
||||
{
|
||||
|
@ -729,11 +691,6 @@ int str7x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, c
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int str7x_erase_check(struct flash_bank_s *bank)
|
||||
{
|
||||
return str7x_blank_check(bank, 0, bank->num_sectors - 1);
|
||||
}
|
||||
|
||||
int str7x_info(struct flash_bank_s *bank, char *buf, int buf_size)
|
||||
{
|
||||
snprintf(buf, buf_size, "str7x flash driver info" );
|
||||
|
|
|
@ -64,7 +64,6 @@ int str9x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
|
|||
int str9x_probe(struct flash_bank_s *bank);
|
||||
int str9x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
|
||||
int str9x_protect_check(struct flash_bank_s *bank);
|
||||
int str9x_erase_check(struct flash_bank_s *bank);
|
||||
int str9x_info(struct flash_bank_s *bank, char *buf, int buf_size);
|
||||
|
||||
int str9x_handle_flash_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
|
||||
|
@ -79,7 +78,7 @@ flash_driver_t str9x_flash =
|
|||
.write = str9x_write,
|
||||
.probe = str9x_probe,
|
||||
.auto_probe = str9x_probe,
|
||||
.erase_check = str9x_erase_check,
|
||||
.erase_check = default_flash_blank_check,
|
||||
.protect_check = str9x_protect_check,
|
||||
.info = str9x_info
|
||||
};
|
||||
|
@ -170,44 +169,6 @@ int str9x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int str9x_blank_check(struct flash_bank_s *bank, int first, int last)
|
||||
{
|
||||
target_t *target = bank->target;
|
||||
u8 *buffer;
|
||||
int i;
|
||||
int nBytes;
|
||||
|
||||
if ((first < 0) || (last > bank->num_sectors))
|
||||
return ERROR_FLASH_SECTOR_INVALID;
|
||||
|
||||
if (bank->target->state != TARGET_HALTED)
|
||||
{
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
buffer = malloc(256);
|
||||
|
||||
for (i = first; i <= last; i++)
|
||||
{
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
target->type->read_memory(target, bank->base + bank->sectors[i].offset, 4, 256/4, buffer);
|
||||
|
||||
for (nBytes = 0; nBytes < 256; nBytes++)
|
||||
{
|
||||
if (buffer[nBytes] != 0xFF)
|
||||
{
|
||||
bank->sectors[i].is_erased = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int str9x_protect_check(struct flash_bank_s *bank)
|
||||
{
|
||||
str9x_flash_bank_t *str9x_info = bank->driver_priv;
|
||||
|
@ -581,11 +542,6 @@ int str9x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, c
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int str9x_erase_check(struct flash_bank_s *bank)
|
||||
{
|
||||
return str9x_blank_check(bank, 0, bank->num_sectors - 1);
|
||||
}
|
||||
|
||||
int str9x_info(struct flash_bank_s *bank, char *buf, int buf_size)
|
||||
{
|
||||
snprintf(buf, buf_size, "str9x flash driver info" );
|
||||
|
|
Loading…
Reference in New Issue