extern flash_driver_t stellaris_flash;
extern flash_driver_t str9xpec_flash;
extern flash_driver_t stm32x_flash;
+extern flash_driver_t tms470_flash;
flash_driver_t *flash_drivers[] =
{
&stellaris_flash,
&str9xpec_flash,
&stm32x_flash,
+ &tms470_flash,
NULL,
};
return ERROR_OK;
}
-int flash_init(struct command_context_s *cmd_ctx)
+int flash_init_drivers(struct command_context_s *cmd_ctx)
{
if (flash_banks)
{
return ERROR_INVALID_ARGUMENTS;
}
+ /* We can't know if we did a resume + halt, in which case we no longer know the erased state */
+ flash_set_dirty();
+
duration_start_measure(&duration);
- if ((retval = flash_erase(target, address, length)) != ERROR_OK)
+ if ((retval = flash_erase_address_range(target, address, length)) != ERROR_OK)
{
switch (retval)
{
return ERROR_OK;
}
+void flash_set_dirty(void)
+{
+ flash_bank_t *c;
+ int i;
+
+ /* set all flash to require erasing */
+ for (c = flash_banks; c; c = c->next)
+ {
+ for (i = 0; i < c->num_sectors; i++)
+ {
+ c->sectors[i].is_erased = 0;
+ }
+ }
+}
+
/* lookup flash bank by address */
flash_bank_t *get_flash_bank_by_addr(target_t *target, u32 addr)
{
}
/* erase given flash region, selects proper bank according to target and address */
-int flash_erase(target_t *target, u32 addr, u32 length)
+int flash_erase_address_range(target_t *target, u32 addr, u32 length)
{
flash_bank_t *c;
int first = -1;
{
/* assume all sectors need erasing - stops any problems
* when flash_write is called multiple times */
-
- for (c = flash_banks; c; c = c->next)
- {
- for (i = 0; i < c->num_sectors; i++)
- {
- c->sectors[i].is_erased = 0;
- }
- }
+
+ flash_set_dirty();
}
/* loop until we reach end of the image */
if (erase)
{
/* calculate and erase sectors */
- retval = flash_erase( target, run_address, run_size );
+ retval = flash_erase_address_range( target, run_address, run_size );
}
if (retval == ERROR_OK)