We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi again
I am still struggling with debugging my code in DDR3 memory using the Keil uLink2. I have created a .ini file for the uLink2 to execute which initializes the DDR3 for use, load my code to DDR3, and attempts to change the pc and sp to that memory. The last thing is not working. the code definitely is in the DDR3 memory OK. Below is the the script function.
The code was linked to 0xA0000000
This is a microsemi cortex m3 FPGA arm.
Can anyone see a reason why this would not work? or why the uLink2 jumps away to undefined memory space? I assume people have debugged out of external RAM before
Thanks :-)
FUNC void SetupPC_SP (void) { // Stack pointer and vector table offset // registers are set to 0x00000000 // Setup Stack Pointer SP = _RDWORD(0xA0000000); // Setup Stack Pointer // Program Counter is set to (0x00000004 -1) PC = _RDWORD(0xA0000004-1); // Setup Program Counter // change vector table address to 0 _WDWORD(0xE000ED08, 0x0); // 0xE000ED08 SCB->VTOR = readonly_region_base; }
I finally believe I got DDR initialization, DDR remapping and the PC/SP working. I had to remove the FUNC's because the calls to them were getting errors that they did not exist. So I just have the entire startup.ini script execute from top to bottom and it works.
My DDR now shows up at address 0 which is pretty cool and the PC is getting the value I want.
But I am not out of the woods on this yet.
The last thing the script does is a LOAD command. The debugger does spend quite some time loading something big (big blue bar at bottom) but ends with a memory mismatch and exits.
What I found out is that the mismatch was between the value being loaded and what was in the DDR before remapping. The memory windows shows the proper value at address 0 but the LOAD command somehow match against the value address 0xA0000000 instead. That value should have been overwritten because it was remapped to address 0.
Its like the uLink2 was confused by the remap and wrote the code somewhere else but not at address 0.
Any ideas as to what might be going on with the LOAD command?
Hi
I have finally gotten to the point in my bootloader where I have loaded my code into the DDR from external Flash and need to remap and jump to the start address. Pre the Microsemi cortex M3 ARM app notes this is the order that the registers are to be set BUT once the remapping happens the two instructions to load the SP and PC registers cannot be executed because the memory is no longer there to fetch them. Its DDR.
Has anyone does this successfully somehow?
__asm void BootJump(INT32U firmwareStartAddress) { MOVS R1, #0x0 STR R1, [R0,#0x0] ; SYSREG->ESRAM_CR = 0u STR R1, [R0,#0x10] ; SYSREG->ENVM_REMAP_BASE_CR = 0u MOVS R2, #0x01 ; SYSREG->DDR_CR = 1u STR R2, [R0,#0x08] ; Remap DDR to address 0 LDR SP, [R1] ;Load new stack pointer address LDR PC, [R1, #4] ;Load new program counter address } void Jump_to_executable(void) { SCB->VTOR = 0x00000000; BootJump((INT32U)0x40038000); }
So is the boot loader in SRAM? Is it accessible from a shadow/normal address (0x20000000 ?) and is that currently mapped at ZERO? If it's at zero then you'd probably want to transfer control to the higher address code before you remap the memory underneath yourself.