Looks like maybe I partially answered my question as I found there is an API call in LPC5536.h
/*! REMAPEN - AHB Bus Address Remap Enable
* 0b0..HADDR REMAP Disabled
* 0b1..HADDR REMAP Enabled
*/
#define FLEXSPI_HADDRSTART_REMAPEN(x) (((uint32_t)(((uint32_t)(x)) << FLEXSPI_HADDRSTART_REMAPEN_SHIFT)) & FLEXSPI_HADDRSTART_REMAPEN_MASK)
However, before trying to access Flash 0x0 from a 0x20000 offset is still reading location 0x20000. What else might I be missing?
#define IMAGE_0_ADDRESS 0x00000
#define IMAGE_1_ADDRESS 0x20000
int compareVersions(void)
{
status_t status;
uint32_t lowerVersion = 0;
uint32_t upperVersion = 0;
uint8_t readPage[512];
// Disable offset to ensure image 0 can be read
FLEXSPI_HADDRSTART_REMAPEN(0) ;
status = FLASH_VerifyErase(&s_flashDriver, IMAGE_0_ADDRESS, 512);
if(status == kStatus_Success)
{
LOG_INFO("\r\nThere is no app installed at location %X\r\n", IMAGE_0_ADDRESS);
}
else
{
memcpy(readPage, (uint32_t *)IMAGE_0_ADDRESS, 512);
lowerVersion = readPage[4+0x20] + (readPage[5+0x20] << + (readPage[6+0x20] << 16);
LOG_INFO("\r\nApp version %X is installed at location %X\r\n", lowerVersion, IMAGE_0_ADDRESS);
}
status = FLASH_VerifyErase(&s_flashDriver, IMAGE_1_ADDRESS, 512);
if(status == kStatus_Success)
{
LOG_INFO("\r\nThere is no app installed at location %X\r\n", IMAGE_1_ADDRESS);
}
else
{
memcpy(readPage, (uint32_t *)IMAGE_1_ADDRESS, 512);
upperVersion = readPage[4+0x20] + (readPage[5+0x20] << + (readPage[6+0x20] << 16);
LOG_INFO("\r\nApp version %X is installed at location %X\r\n", upperVersion, IMAGE_1_ADDRESS);
}
// Reenable offset
FLEXSPI_HADDRSTART_REMAPEN(1) ;
return (lowerVersion > upperVersion);
}
Output:
App version 30400 is installed at location 0
App version 30400 is installed at location 20000