Thanks for the feedback. Since the post I have been able to initialize the external ram using an init binary flashed by a jlink script. See below. It seems to be mostly stable but now and then we get some issues mainly that the MPU seems not to be configured correctly. Running the init.bin from ram would probably be faster but have not tried it yet and a break point instead of a delay might be a more elegant solution. Any feedback to this solution?
Thanks again
/Björn
int ResetTarget()
{
JLINK_SYS_Report("Init...");
JLINK_TIF_ActivateTargetReset();
JLINK_TIF_ReleaseTargetReset();
JLINK_ExecCommand("erase");
JLINK_ExecCommand("loadbin /.../init.bin, 0x0");
JLINK_ExecCommand("r");
JLINK_ExecCommand("g");
JLINK_SYS_Sleep(500);
JLINK_ExecCommand("h");
// Allow execution form sdram
JLINK_MEM_WriteU32(0xE000ED98, 0); // MPU_RNR
JLINK_MEM_WriteU32(0xE000ED9C, 0xa0000000); // MPU_RBAR
JLINK_MEM_WriteU32(0xE000EDA0, 0x3000027); // MPU_RASR
JLINK_MEM_WriteU32(0xE000ED94, 5); // MPU_CTRL
JLINK_SYS_Report("Init done");
}