This is an automated email from Gerrit. Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/5359
-- gerrit commit 8a945a3e2a316a03686edc945ff21b4e827e6cab Author: Tomas Vanek <[email protected]> Date: Sat Dec 14 16:08:32 2019 +0100 flash/nor/stm32l4x: use flash infrastructure to align write The original code paded the write chunk with random bytes by overrunning the buffer. An user can easily regard the random bytes to be a programming error. Change-Id: Ib0f47b5bc406bc6a7c32f3d929bf324a17c7c1e1 Signed-off-by: Tomas Vanek <[email protected]> diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index 2244de7..19475c3 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -283,6 +283,10 @@ FLASH_BANK_COMMAND_HANDLER(stm32l4_flash_bank_command) return ERROR_FAIL; /* Checkme: What better error to use?*/ bank->driver_priv = stm32l4_info; + /* The flash write must be aligned to a double word (8-bytes) boundary. + * Ask the flash infrastructure to ensure required alignment */ + bank->write_start_alignment = bank->write_end_alignment = 8; + stm32l4_info->probed = 0; stm32l4_info->user_bank_size = bank->size; @@ -688,30 +692,15 @@ static int stm32l4_write(struct flash_bank *bank, const uint8_t *buffer, return ERROR_TARGET_NOT_HALTED; } - if (offset & 0x7) { - LOG_WARNING("offset 0x%" PRIx32 " breaks required 8-byte alignment", - offset); - return ERROR_FLASH_DST_BREAKS_ALIGNMENT; - } - - if (count & 0x7) { - LOG_WARNING("Padding %d bytes to keep 8-byte write size", - count & 7); - count = (count + 7) & ~7; - /* This pads the write chunk with random bytes by overrunning the - * write buffer. Padding with the erased pattern 0xff is purely - * cosmetical, as 8-byte flash words are ECC secured and the first - * write will program the ECC bits. A second write would need - * to reprogramm these ECC bits. - * But this can only be done after erase! - */ - } + /* The flash write must be aligned to a double word (8-bytes) boundary. + * The flash infrastructure ensures it, do just a security check */ + assert(offset % 8 == 0); + assert(count % 8 == 0); retval = stm32l4_unlock_reg(bank); if (retval != ERROR_OK) return retval; - /* Only full double words (8-byte) can be programmed*/ retval = stm32l4_write_block(bank, buffer, offset, count / 2); if (retval != ERROR_OK) { LOG_WARNING("block write failed"); -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
