diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-04-03 14:00:17 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-04-03 14:00:17 +0000 |
commit | d3f0549f08d8aac36143bca9e7f7e1308383b7c2 (patch) | |
tree | b1057d6e4ebd1e1dbe560bac2f2330f11d47827b /src/flash/stm32x.c | |
parent | 349f62f74fdc1278efd00a0e6301e1a0199cc128 (diff) | |
download | riscv-openocd-d3f0549f08d8aac36143bca9e7f7e1308383b7c2.zip riscv-openocd-d3f0549f08d8aac36143bca9e7f7e1308383b7c2.tar.gz riscv-openocd-d3f0549f08d8aac36143bca9e7f7e1308383b7c2.tar.bz2 |
- Work on fixing erase check. Many implementations are plain broken.
Wrote a default flash erase check fn which uses CFI's target algorithm
w/fallback to memory reads.
- "flash info" no longer prints erase status as it is stale.
- "flash erase_check" now prints erase status. erase check can take a
*long* time. Work in progress
- arm7/9 with seperate srst & trst now supports reset init/halt
after a power outage. arm7/9 no longer makes any assumptions
about state of target when reset is asserted.
- fixes for srst & trst capable arm7/9 with reset init/halt
- prepare_reset_halt retired. This code needs to be inside
assert_reset anyway
- haven't been able to get stm32 write algorithm to work. Fallback
flash write does work. Haven't found a version of openocd trunk
where this works.
- added target_free_all_working_areas_restore() which can
let be of restoring backups. This is needed when asserting
reset as the target must be assumed to be an unknown state.
Added some comments to working areas API
- str9 reset script fixes
- some guidelines
- fixed dangling callbacks upon reset timeout
git-svn-id: svn://svn.berlios.de/openocd/trunk@536 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/stm32x.c')
-rw-r--r-- | src/flash/stm32x.c | 51 |
1 files changed, 5 insertions, 46 deletions
diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index 7e26ece..e981310 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -43,7 +43,6 @@ int stm32x_probe(struct flash_bank_s *bank); int stm32x_auto_probe(struct flash_bank_s *bank); int stm32x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int stm32x_protect_check(struct flash_bank_s *bank); -int stm32x_erase_check(struct flash_bank_s *bank); int stm32x_info(struct flash_bank_s *bank, char *buf, int buf_size); int stm32x_handle_lock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); @@ -62,7 +61,7 @@ flash_driver_t stm32x_flash = .write = stm32x_write, .probe = stm32x_probe, .auto_probe = stm32x_auto_probe, - .erase_check = stm32x_erase_check, + .erase_check = default_flash_blank_check, .protect_check = stm32x_protect_check, .info = stm32x_info }; @@ -278,43 +277,6 @@ int stm32x_write_options(struct flash_bank_s *bank) return ERROR_OK; } -int stm32x_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 (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 stm32x_protect_check(struct flash_bank_s *bank) { @@ -477,7 +439,8 @@ int stm32x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 co return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; }; - target_write_buffer(target, stm32x_info->write_algorithm->address, sizeof(stm32x_flash_write_code), stm32x_flash_write_code); + if ((retval=target_write_buffer(target, stm32x_info->write_algorithm->address, sizeof(stm32x_flash_write_code), stm32x_flash_write_code))!=ERROR_OK) + return retval; /* memory buffer */ while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) @@ -507,7 +470,8 @@ int stm32x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 co { u32 thisrun_count = (count > (buffer_size / 2)) ? (buffer_size / 2) : count; - target_write_buffer(target, source->address, thisrun_count * 2, buffer); + if ((retval = target_write_buffer(target, source->address, thisrun_count * 2, buffer))!=ERROR_OK) + break; buf_set_u32(reg_params[0].value, 0, 32, source->address); buf_set_u32(reg_params[1].value, 0, 32, address); @@ -707,11 +671,6 @@ int stm32x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, return ERROR_OK; } -int stm32x_erase_check(struct flash_bank_s *bank) -{ - return stm32x_blank_check(bank, 0, bank->num_sectors - 1); -} - int stm32x_info(struct flash_bank_s *bank, char *buf, int buf_size) { snprintf(buf, buf_size, "stm32x flash driver info" ); |