Ok, so I'm going to try to more clearly define what conditions are required to get my port to work.
I am using the linker script for the smaller memory KW21Z on the KW41Z, in order to artificially constrain memory sizes.
This defines sections as follows:
/* Specify the memory areas */
MEMORY
{
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000200
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0003FBF0
m_data (RW) : ORIGIN = 0x1FFFB000, LENGTH = 0x00010000
}
The only difference here is moving the ram section down to 0x1FFFB000 from the 0x1FFFC000 used by the smaller memory MCU.
I have defined the location to save Openthread settings (2 2kB pages) as 0x3F000.
When the KW21Z port is flashed to the KW41Z, and there is no delay in `flash_command_sequence`, the KW41Z hardfaults immediately. When I include the aforementioned delay, the port works flawlessly on the KW41Z. Additionally, if I select 0x40000 as the Openthread settings location, the port also works. I've also tried 0x30000, as the binary is under 0x30000 in size, but that hardfaults in the same manner as 0x3F000. While changing the settings location, I have also changed the size of the text section in the linker script to not overlap the settings.
When flashing the port to the KW21Z, I see similar behavior. Although not immediately, the application hardfaults eventually if there is no delay. When there is a delay, the port does not hardfault on flash access. The radio doesn't appear to function, but I would imagine that's a separate issue.
Any ideas as to why I can't write to flash below 0x40000 without a delay?