I am working on a bootloader for DEVKIT-MPC5748G,
and have successfully implemented flash memory erase and program operations,
as well as starting the application firmware.
Now I would like to utilize flash memory remap options
in order to be able to have two memory "slots" for application firmware.
That way I can swap between them when I need to update and run new firmware.
I couldn't find any code examples for this, so I wrote it on my own
by looking at the Flash Memory Controller (PFLASH) section in the MCU's reference manual.
However, I can't seem to get the memory remap to work.
I tried to remap 2MB of memory at logical address 0x01000000 to physical address 0x01200000.
I also tried it with 256KB with the same addresses, which didn't work either.
Here's my source code:
// Initializes the flash remap.
static void bootFlashRemapInit()
// Setup the remap logic and physical addresses,
// per-master enable, and region size.
PFLASH.PFCRD.Word0.R = 0x01200000;
PFLASH.PFCRD.Word1.R = 0x01000000;
PFLASH.PFCRD.Word2.R = 0xffff0015;
// Enable remap descriptor 0.
PFLASH.PFCRDE.R = 0xffff0000;
// Enable instruction remap.
PFLASH.PFCRCR.B.IRMEN = 1;
// Enables the flash remap.
static void bootFlashRemapEnable()
PFLASH.PFCRCR.B.GRMEN = 1;
// Disables the flash remap.
static void bootFlashRemapDisable()
PFLASH.PFCRCR.B.GRMEN = 0;
Obviously, I call bootFlashRemapInit to initialize the remap, and bootFlashRemapEnable to enable it.
I found out in the errata for my chip mask (https://www.nxp.com/docs/en/errata/MPC5748G_0N78S.pdf)
that this chip has a known problem when trying to remap flash memory in address range 0x00F90000-0x00FBFFFF.
This is not the address range I am working with,
but it got me thinking that there might be problems with the flash addresses I am working with as well.
Does anybody have an idea of what the problem might be?
Are there errors in my source code, or could the chip itself have an error?
Thanks in advance!