This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

remapping of ddr

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;

}

Parents
  • 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);
    }
    
    

Reply
  • 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);
    }
    
    

Children