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

Memory remmaping and RL-ARM

I'm using a LPC2129, with Realview MDK-ARM 3.11 and RealView RL-ARM 3.10

I'm trying to run an application loaded by a user bootloader. So I have a bootloader code in 0x0000 0000 who uses a USB connection to load an application code in 0x0000 4000. The program runs fine. The problem is when I jump to the application code, when I have to remmap the interrupt vectors.

I've tried using REMAP RAM_MODE for Startup.s file in the application, but it seems that the interrupts still go to the Flash Vectors.

Besides, the SWI handler is configured by the OS (RL-ARM) and the Dabt handler by the Real Time Agent

I appreciate any help or useful link

Parents Reply Children
  • REMAP RAM_MODE set the MEMMAP to 2 in the Startup.s file.

    I almost get it...

    Here it is my Scatter-Loading File

    LR_IROM1 0x00004000 0x0003C000  {    ; load region size_region
      ER_IROM1 0x00004000 0x0003C000  {  ; load address = execution address
       *.o (RESET, +First)
       *(InRoot$$Sections)
       .ANY (+RO)
      }
      RW_IRAM1 0x40000050 0x00003FB0  {  ; RW data
       .ANY (+RW +ZI)
      }
      RW_IRAM2 0x40000000 0x00000050  {
        Vectors.o
      }
    }
    
    LR_IROM2 0x00000000 0x00004000  {
      ER_IROM2 0x00000000 0x00004000  {  ; load address = execution address
        CodeInit.o
      }
    }
    


    Explaining:
    I created 4 memory areas 2 ROM and 2 RAM
    I wrote the vector in the beggining of Statup.s file in an separate file (Vectors.s) and located it in the bottom of RAM space (IRAM2 in 0x40000000). The file CodeInit.s is placed in the bottom of Flash ROM space, just jump to the application at 0x4000 and it's just for testing, because this area is where the bootloader will be:

                    AREA    INIT, CODE, READONLY
                    ARM
    
    Init                    LDR     PC, =0x4000
    
                    END
    

    In the RESET Area I placed a jump to the Reset_Handler, in the place where "Vectors" label used to be.

    The application code starts at 0x4000

    The only thing that's boring me now is that before going to the main() Some spurious interrupt is triggered and my code get stucked in the IRQ_Handler.

    Just one doubt. Are the RAM vectors placed in programming or execution time? Because if it's in programing time I have to place this code in flash and copy it to RAM space after.

  • Because if it's in programing time I have to place this code in flash and copy it to RAM space after.
    I have not seen a Loading-File before, but I assume that it is a command file for a download tool. In this case I would say that it looks as if they were set at programming time.

    Why don't You put a part of C-Code behind Your startup like:

    copy all code from 0x4000 to 0x4040 into RAM;
    MEMMAP = 2;
    enable interrupts;
    


    In this case it would be enough to load the program code to flash. The copying is done at execution time and the download is much easier. Only the linker has to be set up correctly.

  • Finally it works!!!
    This line of code in the Startup.s is commented out:

    LDR     PC, IRQ_Addr
    


    And this one is used instead:

    LDR     PC, [PC, #-0x0FF0]     ; Vector from VicVectAddr
    


    Changing that the code run OK

    I didn't need to copy the RAM vectors in my code. It seems that the compiler assumes it as an initializated variable and copy its value in execution time, before going to main(). I've already converted the HEX code to binary, programmed using my user USB bootloader and jump to it...It's working fine.

    Thanks Christian for the help.

  • While shareing Your happiness about the working software I looked up what scatter files where and recognised I was wrong. Just for clarification: Are they doing the same as linker control files?

  • LR_IROM2 0x00000000 0x00004000  {
      ER_IROM2 0x00000000 0x00004000  {  ; load address = execution address
        CodeInit.o
      }
    }
    

    Does that mean that if I jump to address 0x00 from bootloader the code in CodeInit.c will automatically be executed?

  • the scatter-loading file

    LR_IROM1 0x00004000 0x0003C000  {    ; load region size_region
      ER_IROM1 0x00004000 0x0003C000  {  ; load address = execution address
       *.o (RESET, +First)
       *(InRoot$$Sections)
       .ANY (+RO)
      }
      RW_IRAM1 0x40000050 0x00003FB0  {  ; RW data
       .ANY (+RW +ZI)
      }
      RW_IRAM2 0x40000000 0x00000050  {
        Vectors.o
      }
    }
    
    LR_IROM2 0x00000000 0x00004000  {
      ER_IROM2 0x00000000 0x00004000  {  ; load address = execution address
        CodeInit.o
      }
    }
    

    is it for the bootloader or the application ?

  • Ok I guess the scatter file is for the application
    actually you are loading only the application in your target and you start with a jump to address 0x4000 in CodeInit.s which simulate the bootloader

    can you please show us the files
    Startup.s
    Vectors.s

    because it doesnot work for me ?
    did you use REMAP RAM_MODE ?

    thank you

  • The Vectors.s is part of the original Startup.s which is separated to run on RAM

    ; Area Definition and Entry Point
    ;  Startup Code must be linked first at Address at which it expects to run.
    
                                    AREA    RAMVECT, CODE, READONLY
    ; Exception Vectors
    ;  Mapped to Address 0.
    ;  Absolute addressing mode must be used.
    ;  Dummy Handlers are implemented as infinite loops which can be modified.
    
    Vectors         LDR     PC, Reset_Addr
                    LDR     PC, Undef_Addr
                    LDR     PC, SWI_Addr
                    LDR     PC, PAbt_Addr
                    LDR     PC, DAbt_Addr
                    NOP                            ; Reserved Vector
                    ;LDR     PC, IRQ_Addr
                    LDR     PC, [PC, #-0x0FF0]     ; Vector from VicVectAddr
                    LDR     PC, FIQ_Addr
    
    
    Reset_Addr      DCD     Reset_Handler
    Undef_Addr      DCD     Undef_Handler
    SWI_Addr        DCD     SWI_Handler
    PAbt_Addr       DCD     PAbt_Handler
    DAbt_Addr       DCD     DAbt_Handler
                    DCD     0                      ; Reserved Address
    IRQ_Addr        DCD     IRQ_Handler
    FIQ_Addr        DCD     FIQ_Handler
    
                                    IMPORT SWI_Handler
                                    IMPORT DAbt_Handler
                                    IMPORT Reset_Handler
                                    IMPORT Undef_Handler
                                    IMPORT PAbt_Handler
                                    IMPORT IRQ_Handler
                                    IMPORT FIQ_Handler
                                    END
    


    The startup is almost the same, just without this part of the code.

    To use the Scatter-File you have to deselect "Use Memory Layout from Target Dialog" from Linker options