diff options
author | mlu <mlu@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-04-14 17:17:38 +0000 |
---|---|---|
committer | mlu <mlu@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-04-14 17:17:38 +0000 |
commit | ba4e2c43fb05e1ee5fbf55181b4afafdefe987d3 (patch) | |
tree | a0e334abf2a26a21913bb8eeb9ff594875859596 /src | |
parent | 699d246b1c7880d6817f06f31561026f9322ce49 (diff) | |
download | openocd_libswd-ba4e2c43fb05e1ee5fbf55181b4afafdefe987d3.tar.gz openocd_libswd-ba4e2c43fb05e1ee5fbf55181b4afafdefe987d3.tar.bz2 openocd_libswd-ba4e2c43fb05e1ee5fbf55181b4afafdefe987d3.tar.xz openocd_libswd-ba4e2c43fb05e1ee5fbf55181b4afafdefe987d3.zip |
Improved (for humans) error reporting for flash programming errors.
git-svn-id: svn://svn.berlios.de/openocd/trunk@1456 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r-- | src/flash/stm32x.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index 5eeb03bb..68e9c259 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -565,8 +565,16 @@ int stm32x_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 co break; } - if (buf_get_u32(reg_params[3].value, 0, 32) & 0x14) + if (buf_get_u32(reg_params[3].value, 0, 32) & FLASH_PGERR) { + LOG_ERROR("flash memory not erased before writing"); + retval = ERROR_FLASH_OPERATION_FAILED; + break; + } + + if (buf_get_u32(reg_params[3].value, 0, 32) & FLASH_WRPRTERR) + { + LOG_ERROR("flash memory write protected"); retval = ERROR_FLASH_OPERATION_FAILED; break; } @@ -647,9 +655,15 @@ int stm32x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count) status = stm32x_wait_status_busy(bank, 5); if( status & FLASH_WRPRTERR ) + { + LOG_ERROR("flash memory not erased before writing"); return ERROR_FLASH_OPERATION_FAILED; + } if( status & FLASH_PGERR ) + { + LOG_ERROR("flash memory write protected"); return ERROR_FLASH_OPERATION_FAILED; + } bytes_written += 2; words_remaining--; @@ -674,9 +688,15 @@ int stm32x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count) status = stm32x_wait_status_busy(bank, 5); if( status & FLASH_WRPRTERR ) + { + LOG_ERROR("flash memory not erased before writing"); return ERROR_FLASH_OPERATION_FAILED; + } if( status & FLASH_PGERR ) + { + LOG_ERROR("flash memory write protected"); return ERROR_FLASH_OPERATION_FAILED; + } } target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); |