I'm working on S12G128 bootloader, it is based on AN4258.
Some certain chars have been written to P-Flash global address 0x2FE00, so after reset, bootloader will read address 0x2FE00 and decide how to go. A far pointer Upg_Cmd defined for this operation. See below code for more details.
#define Upg_Cmd_Addr 0x2FE00 //Global address 0x2FE00, store the chars
UINT8 * far Upg_Cmd;
#define GlobalToLocal(Address) (((Address) & 0x3FFFU) | (((Address) & 0x003FC000UL) << 2U) | 0x8000U)
UINT8 const far upg_cmd_array @0x0BBE00 = "54600856"; //For debugging, test if bootloader can read these chars.
In main program, I'm using Upg_Cmd pointer to get the content in 0x2FE00 (Local paged address 0xBBE00) but always get 0xFF. I checked in BDM debugger interface and the actual content of 0x2FE00 (Local paged address 0xBBE00) is correct and not corrupted, also, Upg_Cmd can be correctly assigned 0xBBE00.
Upg_Cmd= (UINT8 * far) GlobalToLocal(Upg_Cmd_Addr);
When code executed, cc is 0xFF which suppose to be '5'.
Any hints are apppreciated.