This is an automated email from the ASF dual-hosted git repository.
utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 2a02c4b hw: hal: flash: Add proper check for erase
new 6ba5b5a Merge pull request #2524 from utzig/flash-erase-error-check
2a02c4b is described below
commit 2a02c4b5df8185b37569a85789a1f125f00e23cb
Author: Fabio Utzig <[email protected]>
AuthorDate: Thu Mar 11 09:48:16 2021 -0300
hw: hal: flash: Add proper check for erase
When a flash erase failed the error was ignored. This doesn't usually
happen in the internal flash but can happen on external flash due to bus
related issues, etc. Add a proper check and return an error that can be
used for verification.
Signed-off-by: Fabio Utzig <[email protected]>
---
hw/hal/src/hal_flash.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/hal/src/hal_flash.c b/hw/hal/src/hal_flash.c
index 943423e..32aea9e 100644
--- a/hw/hal/src/hal_flash.c
+++ b/hw/hal/src/hal_flash.c
@@ -269,7 +269,9 @@ hal_flash_erase(uint8_t id, uint32_t address, uint32_t
num_bytes)
}
if (hf->hf_itf->hff_erase) {
- hf->hf_itf->hff_erase(hf, address, num_bytes);
+ if (hf->hf_itf->hff_erase(hf, address, num_bytes)) {
+ return SYS_EIO;
+ }
#if MYNEWT_VAL(HAL_FLASH_VERIFY_ERASES)
assert(hal_flash_isempty_no_buf(id, address, num_bytes) == 1);
#endif