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

What is the right way to use MEMMAP ?

Hello,
I am programming, via a bootloader, interrupt driven application code on a LPC2468. I certainly need to remap the interrupt vectors. What is a 100% clear to me is when the re-mapping needs to occur: Assuming IAP was successful, the bootloader, when starting up and before jumping to the application, would copy the first 32 bytes from internal flash to internal RAM (for example) and then set MEMMAP, while the bootloader is still running? Is this the right way to do it? Can you advise me of other issues that need to be dealt with, if any?

Parents
  • I meant that it is not a 100% clear, of course.

    I habe another question. Here is a part of my map file:

    RESET                                    0x00004000   Section      800  lpc2400.o(RESET)
        Undef_Handler                            0x00004040   ARM Code       4  lpc2400.o(RESET)
        SWI_Handler                              0x00004044   ARM Code       4  lpc2400.o(RESET)
        PAbt_Handler                             0x00004048   ARM Code       4  lpc2400.o(RESET)
        DAbt_Handler                             0x0000404c   ARM Code       4  lpc2400.o(RESET)
        IRQ_Handler                              0x00004050   ARM Code       4  lpc2400.o(RESET)
        FIQ_Handler                              0x00004054   ARM Code       4  lpc2400.o(RESET)
        $$startup$$                              0x00004320   Section       12  entry.o($$startup$$)
        .emb_text                                0x0000432c   Section        2  init.o(.emb_text)
        Inline ARM to Thumb Veneer to toggle_cpu_LED 0x00004330   ARM Code       8  main.o(.text)
        .text                                    0x00004338   Section      196  main.o(.text)
        toggle_cpu_LED                           0x000043cb   Thumb Code    18  main.o(.text)
        .text                                    0x000043fc   Section       72  main.o(.text)
        .text                                    0x0000444c   Section       40  init.o(.text)
        .text                                    0x00004474   Section       16  callvia.o(.text)
        i.__scatterload_copy                     0x00004484   Section       24  handlers.o(i.__scatterload_copy)
        i.__scatterload_null                     0x0000449c   Section        4  handlers.o(i.__scatterload_null)
        i.__scatterload_zeroinit                 0x000044a0   Section       24  handlers.o(i.__scatterload_zeroinit)
        STACK                                    0x40000000   Section     4352  lpc2400.o(STACK)
        Stack_Top                                0x40001100   Number         0  lpc2400.o(STACK)
    

    the reset vector seems to be enlarged (and split? its size is 800 bytes but the next vector starts only 64 bytes later!) due to the usage of the EMC. So how much do I hqve to copy to external RAM? It seems that I need to code quiet some data.

Reply
  • I meant that it is not a 100% clear, of course.

    I habe another question. Here is a part of my map file:

    RESET                                    0x00004000   Section      800  lpc2400.o(RESET)
        Undef_Handler                            0x00004040   ARM Code       4  lpc2400.o(RESET)
        SWI_Handler                              0x00004044   ARM Code       4  lpc2400.o(RESET)
        PAbt_Handler                             0x00004048   ARM Code       4  lpc2400.o(RESET)
        DAbt_Handler                             0x0000404c   ARM Code       4  lpc2400.o(RESET)
        IRQ_Handler                              0x00004050   ARM Code       4  lpc2400.o(RESET)
        FIQ_Handler                              0x00004054   ARM Code       4  lpc2400.o(RESET)
        $$startup$$                              0x00004320   Section       12  entry.o($$startup$$)
        .emb_text                                0x0000432c   Section        2  init.o(.emb_text)
        Inline ARM to Thumb Veneer to toggle_cpu_LED 0x00004330   ARM Code       8  main.o(.text)
        .text                                    0x00004338   Section      196  main.o(.text)
        toggle_cpu_LED                           0x000043cb   Thumb Code    18  main.o(.text)
        .text                                    0x000043fc   Section       72  main.o(.text)
        .text                                    0x0000444c   Section       40  init.o(.text)
        .text                                    0x00004474   Section       16  callvia.o(.text)
        i.__scatterload_copy                     0x00004484   Section       24  handlers.o(i.__scatterload_copy)
        i.__scatterload_null                     0x0000449c   Section        4  handlers.o(i.__scatterload_null)
        i.__scatterload_zeroinit                 0x000044a0   Section       24  handlers.o(i.__scatterload_zeroinit)
        STACK                                    0x40000000   Section     4352  lpc2400.o(STACK)
        Stack_Top                                0x40001100   Number         0  lpc2400.o(STACK)
    

    the reset vector seems to be enlarged (and split? its size is 800 bytes but the next vector starts only 64 bytes later!) due to the usage of the EMC. So how much do I hqve to copy to external RAM? It seems that I need to code quiet some data.

Children
  • I have one more question: when I start my target debugger the vector table is located at 0x0, 0x4 etc. just as documented. did I miss some memory mapping thing happening somewhere?

  • Marius,
    It is you application that must remap the interrupt vectors - not the boot code!
    create a buffer 32 bytes long in internal RAM where the contents of the start of your program will be copied with interrupts disabled, and set the flags REMAP & RAM_MODE in the ASM dialog. then enable interrupt.

  • No, I think it is perfectly fine for the boot loader to do the copy. At least it works for me with LPC23xx :)

    But the boot loader has to make sure that it has disabled all interrupt sources it has been playing with before doing the remapping and jumping to the application.

  • Per,
    As far as I understand/have done, unless the startup file of the application is prepared for it, MEMMAP settings of the bootloader are overwritten. But maybe it is the exact startup file flavor.

  • Can you perhaps tell me what is wrong here?

    I am using the following code to install an IRQ:

    unsigned char install_irq( unsigned long IntNumber, void *HandlerAddr, unsigned long Priority )
    {
        unsigned long *vect_addr;
        unsigned long *vect_prio;
    
        VICIntEnClr = 1 << IntNumber; /* Disable Interrupt */
        if ( IntNumber >= VIC_SIZE )
        {
                    return 0 ;
        }
        else
        {
                    /* find first un-assigned VIC address for the handler */
                    vect_addr = (unsigned long *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + IntNumber*4);
                    vect_prio = (unsigned long *)(VIC_BASE_ADDR + VECT_PRIO_INDEX + IntNumber*4);
                    *vect_addr = (unsigned long)HandlerAddr;        /* set interrupt vector */
                    *vect_prio = Priority;
                    VICIntEnable = 1 << IntNumber;    /* Enable Interrupt */
                    return 1 ;
        }
    }
    

    the handler is called without a problem, but the IRQ entry at 0x18 in the startup file is not (I varified that using a breakpoint). why is that?

  • Can you be more specific about what you mean by "the handler is called without a problem, but the IRQ entry at 0x18 in the startup file is not"?

  • thanks for your reply - false alarm, all is fine!