From: OpenOCD-Gerrit <ope...@us...> - 2020-02-23 12:39:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via a6dacdff58ef36fcdac00c53ec27f19de1fbce0d (commit) from 2a60ae7fee192db54240e5929d6434c0eb3e190d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a6dacdff58ef36fcdac00c53ec27f19de1fbce0d Author: Christopher Head <ch...@za...> Date: Fri Jan 3 14:49:16 2020 -0800 flash/stm32h7x: use alignment infrastructure Report the 32-byte alignemnt requirement via the bank structure rather than enforcing it ad-hoc in the write routine. This allows people to do non-32-byte-aligned writes if they want, with the infrastructure fixing up the addresses passed to the low-level driver. Change-Id: I2c4f532f2000435954a900224dbc9f2c30d1cc94 Signed-off-by: Christopher Head <ch...@za...> Reviewed-on: http://openocd.zylin.com/5388 Reviewed-by: Tarek BOCHKATI <tar...@gm...> Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/flash/nor/stm32h7x.c b/src/flash/nor/stm32h7x.c index 152a154bd..bf003684c 100644 --- a/src/flash/nor/stm32h7x.c +++ b/src/flash/nor/stm32h7x.c @@ -170,6 +170,9 @@ FLASH_BANK_COMMAND_HANDLER(stm32x_flash_bank_command) stm32x_info->probed = 0; stm32x_info->user_bank_size = bank->size; + bank->write_start_alignment = FLASH_BLOCK_SIZE; + bank->write_end_alignment = FLASH_BLOCK_SIZE; + return ERROR_OK; } @@ -610,17 +613,17 @@ static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer, return ERROR_TARGET_NOT_HALTED; } - if (offset % FLASH_BLOCK_SIZE) { - LOG_WARNING("offset 0x%" PRIx32 " breaks required 32-byte alignment", offset); - return ERROR_FLASH_DST_BREAKS_ALIGNMENT; - } + /* should be enforced via bank->write_start_alignment */ + assert(!(offset % FLASH_BLOCK_SIZE)); + + /* should be enforced via bank->write_end_alignment */ + assert(!(count % FLASH_BLOCK_SIZE)); retval = stm32x_unlock_reg(bank); if (retval != ERROR_OK) goto flash_lock; uint32_t blocks_remaining = count / FLASH_BLOCK_SIZE; - uint32_t bytes_remaining = count % FLASH_BLOCK_SIZE; /* multiple words (32-bytes) to be programmed in block */ if (blocks_remaining) { @@ -667,25 +670,6 @@ static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer, blocks_remaining--; } - if (bytes_remaining) { - retval = stm32x_write_flash_reg(bank, FLASH_CR, FLASH_PG | FLASH_PSIZE_64); - if (retval != ERROR_OK) - goto flash_lock; - - retval = target_write_buffer(target, address, bytes_remaining, buffer); - if (retval != ERROR_OK) - goto flash_lock; - - /* Force Write buffer of FLASH_BLOCK_SIZE = 32 bytes */ - retval = stm32x_write_flash_reg(bank, FLASH_CR, FLASH_PG | FLASH_PSIZE_64 | FLASH_FW); - if (retval != ERROR_OK) - goto flash_lock; - - retval = stm32x_wait_flash_op_queue(bank, FLASH_WRITE_TIMEOUT); - if (retval != ERROR_OK) - goto flash_lock; - } - flash_lock: retval2 = stm32x_lock_reg(bank); if (retval2 != ERROR_OK) ----------------------------------------------------------------------- Summary of changes: src/flash/nor/stm32h7x.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) hooks/post-receive -- Main OpenOCD repository |