I hope it is - here's the code I currently use, copied it from somewhere else:
/* Initialize the SRAM after the RAM image */
lis r30, 0x0000
lis r31, 0x0000
lis r11, 0x4000
ori r11, r11, 0x1B00
sram_init:
stmw r30, 0(r11)
addi r11, r11, 8
andi. r12, r11, 0xFFFF
bne sram_init
lis r30, 0x0000
lis r31, 0x0000
lis r11, 0x4001
ori r11, r11, 0x0000
sram_init2:
stmw r30, 0(r11)
addi r11, r11, 8
andi. r12, r11, 0xFFFF
bne sram_init2
Edit: I also tried the code you suggested. Here's the memory layout:
MEMORY
{
init: org = 0x40000100, len = 0x00000400
exception_handlers_p0: org = 0x40000500, len = 0x00000300
exception_handlers_p1: org = 0x40000800, len = 0x00000300
pseudo_rom: org = 0x40000B00, len = 0x000001000
internal_ram: org = 0x40001B00, len = 0x00001000
heap : org = 0x40002B00, len = 0x00000400 /* Heap start location */
stack : org = 0x40002F00, len = 0x00000400 /* Start location for Stack */
heap_p1 : org = 0x40003300, len = 0x00000400 /* z0 Heap */
stack_p1 : org = 0x40003700, len = 0x00000400 /* z0 Stack */
}
And the RAM init function, with the RAM address adjusted to 0x40001B00, which is the space after the image:
/* MPC5646 B/C L2SRAM initialization code */
lis r11,0x4000
ori r11,r11,0x1B00
li r12,1994 /*Counter = ((256K - 0x1B00)/4) /32 */
mtctr r12
init_l2sram_loop:
stmw r0,0(r11) /* Write all 32 GPRs to L2SRAM */
addi r11,r11,128 /* Inc the ram ptr; 32 GPRs * 4 bytes = 128 */
bdnz init_l2sram_loop /* Loop for 256k of L2SRAM */
The result is the same again, if I try to boot directly into BAM, I can't load the code. Need to boot into Flash first.