Skip to content

Commit 13d2c63

Browse files
committed
M2354: Get around LDRB last byte of flash in non-secure
On test chip, byte-read (LDRB) last byte of flash in non-secure world always gets 0xFF. Get around it. Recover back on MP chips.
1 parent 604f3d9 commit 13d2c63

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

targets/TARGET_NUVOTON/TARGET_M2354/flash_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,19 @@ void flash_set_target_config(flash_t *obj)
116116
}
117117

118118
#endif // #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
119+
120+
int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size)
121+
{
122+
memcpy(data, (const void *)address, size);
123+
/* In test chip, byte-read (LDRB) last byte of flash in non-secure world
124+
* always gets 0xFF. Get around it.
125+
*
126+
* Remove the flash_read(...) override in MP chip. */
127+
if (size && (address + size) == 0x10100000) {
128+
volatile uint32_t *last_word = (volatile uint32_t *) 0x100FFFFC;
129+
data[size - 1] = (uint8_t) ((*last_word & 0xFF000000) >> 24);
130+
}
131+
return 0;
132+
}
133+
119134
#endif // #if DEVICE_FLASH

0 commit comments

Comments
 (0)