Never attempt to write partial words. The hardware only allows writing entire words ... so don't guess about what users want to do with the other bytes. Require them to say explicitly what data they want written. --- Similar in concept to the NOR patch I sent for comment.
I sure hope we don't have a lot of upper-level code that is so sloppy about flash handling that it requires writing random garbage ... src/flash/nor/stellaris.c | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) --- a/src/flash/nor/stellaris.c +++ b/src/flash/nor/stellaris.c @@ -927,8 +927,6 @@ static int stellaris_write(struct flash_ uint32_t address = offset; uint32_t flash_cris, flash_fmc; uint32_t words_remaining = (count / 4); - uint32_t bytes_remaining = (count & 0x00000003); - uint32_t bytes_written = 0; int retval; if (bank->target->state != TARGET_HALTED) @@ -943,9 +941,9 @@ static int stellaris_write(struct flash_ if (stellaris_info->did1 == 0) return ERROR_FLASH_BANK_NOT_PROBED; - if (offset & 0x3) + if ((offset & 0x3) || (count & 0x3)) { - LOG_WARNING("offset size must be word aligned"); + LOG_WARNING("Only word-aligned data may be written to flash."); return ERROR_FLASH_DST_BREAKS_ALIGNMENT; } @@ -1014,33 +1012,6 @@ static int stellaris_write(struct flash_ words_remaining--; } - if (bytes_remaining) - { - uint8_t last_word[4] = {0xff, 0xff, 0xff, 0xff}; - int i = 0; - - while (bytes_remaining > 0) - { - last_word[i++] = *(buffer + bytes_written); - bytes_remaining--; - bytes_written++; - } - - if (!(address & 0xff)) - LOG_DEBUG("0x%" PRIx32 "", address); - - /* Program one word */ - target_write_u32(target, FLASH_FMA, address); - target_write_buffer(target, FLASH_FMD, 4, last_word); - target_write_u32(target, FLASH_FMC, FMC_WRKEY | FMC_WRITE); - /* LOG_DEBUG("0x%x 0x%x 0x%x",address,buf_get_u32(buffer, 0, 32),FMC_WRKEY | FMC_WRITE); */ - /* Wait until write complete */ - do - { - target_read_u32(target, FLASH_FMC, &flash_fmc); - } while (flash_fmc & FMC_WRITE); - } - /* Check access violations */ target_read_u32(target, FLASH_CRIS, &flash_cris); if (flash_cris & (AMASK)) _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development