You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/03/04 17:42:11 UTC
[GitHub] [mynewt-core] ccollins476ad opened a new issue #2228: da1469x QSPI
driver corrupts source data on flash->flash write
ccollins476ad opened a new issue #2228: da1469x QSPI driver corrupts source data on flash->flash write
URL: https://github.com/apache/mynewt-core/issues/2228
I've noticed that mcuboot often fails to write the 16-byte magic number to an image trailer. Specifically, after the write occurs, I usually see a repeating (random) four-byte sequence rather than the actual magic number. When I then look at the source data in gdb (`boot_img_magic`), it has been corrupted with the same random pattern.
This change seems to fix the problem:
```
diff --git a/hw/mcu/dialog/da1469x/src/hal_flash.c b/hw/mcu/dialog/da1469x/src/hal_flash.c
index 65df0c0db..f65d87435 100644
--- a/hw/mcu/dialog/da1469x/src/hal_flash.c
+++ b/hw/mcu/dialog/da1469x/src/hal_flash.c
@@ -330,15 +330,6 @@ da1469x_hff_write(const struct hal_flash *dev, uint32_t address,
uint8_t buf[ MYNEWT_VAL(QSPI_FLASH_READ_BUFFER_SIZE) ];
uint32_t chunk_len;
- /*
- * We can write directly if 'src' is outside flash memory, otherwise we
- * need to read data to RAM first and then write to flash.
- */
- if (((uint32_t)src < MCU_MEM_QSPIF_M_START_ADDRESS) ||
- ((uint32_t)src >= MCU_MEM_QSPIF_M_END_ADDRESS)) {
- return da1469x_qspi_write(dev, address, src, num_bytes);
- }
-
while (num_bytes) {
if (num_bytes > MYNEWT_VAL(QSPI_FLASH_READ_BUFFER_SIZE)) {
chunk_len = MYNEWT_VAL(QSPI_FLASH_READ_BUFFER_SIZE);
```
In other words - always copy the source data to RAM before writing it to flash.
I believe the problem is that the source address is being compared to the wrong boundaries. `boot_img_magic` is in `.text`, and in my build it is at address 0x67c4. But the start / end constants are defined as follows:
```
#define MCU_MEM_QSPIF_M_START_ADDRESS (0x16000000)
#define MCU_MEM_QSPIF_M_END_ADDRESS (0x18000000)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [mynewt-core] ccollins476ad closed issue #2228: da1469x QSPI driver
corrupts source data on flash->flash write
Posted by GitBox <gi...@apache.org>.
ccollins476ad closed issue #2228: da1469x QSPI driver corrupts source data on flash->flash write
URL: https://github.com/apache/mynewt-core/issues/2228
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services