AnsweredAssumed Answered

KW21Z Flash Memory usage rules

Question asked by Neal Jackson on Jun 12, 2018
Latest reply on Jun 25, 2018 by Chris Brown

I'm trying to port the Openthread KW41Z 512/128 implementation to the KW21Z 256/64. Part of Openthread requires having a nonvolatile settings section. This section is 2 "pages" of 2KB each. The Openthread library uses the flash drivers provided in the SDK to read/write to this section. Here are links to an  example of the linker script, a config file that defines the flash region and base address for the settings section, as well as code that uses the flash SDK functions to manipulate flash. With the KW41Z, this section is at 0x4000. For the KW21Z 256/64, this location is out of bounds for the available flash storage, so I obviously needed to move it.


I've tried relocating this settings section to just before the end of flash at 0x3F000 (or even 0x3E000), which should provide enough room for the 4KB required. However, my application is hardfaulting when attempting to read/write to this section regardless of where I place it. It's not immediately clear to me why writing to this location in flash is causing a hard fault. Is there any information that exists during a hard fault that can help me debug this?


I can't find any mention of the flash page sizes on the KW21Z in the reference manual, and I've just assumed them to be 2KB. Is this correct? Additionally, are there constraints on page boundaries that make 0x3F000 invalid?