From: <ml...@ma...> - 2009-04-14 19:17:41
|
Author: mlu Date: 2009-04-14 19:17:38 +0200 (Tue, 14 Apr 2009) New Revision: 1456 Modified: trunk/src/flash/stm32x.c Log: Improved (for humans) error reporting for flash programming errors. Modified: trunk/src/flash/stm32x.c =================================================================== --- trunk/src/flash/stm32x.c 2009-04-14 16:33:52 UTC (rev 1455) +++ trunk/src/flash/stm32x.c 2009-04-14 17:17:38 UTC (rev 1456) @@ -565,12 +565,20 @@ 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; + } + buffer += thisrun_count * 2; address += thisrun_count * 2; count -= thisrun_count; @@ -647,9 +655,15 @@ 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 @@ 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); |