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

How to specify both image address and load address on armlink

Hello,

I want copy my RO-data and vector table to RAM, and run in RAM complete.
I have two question:

1.  In my.sct file
    I specify vector table(RESET AREA) image address at 0x20000000,
    How to specify vector table load address at 0x08000000?

2.  In boot.c file
    How to get vector table loadaddr and imageaddr?

my.sct:
    LR_IROM1 0x08000000 0x00010000 {
        ER_IROM1 0x08000000 0x00010000 {
            *(InRoot$$Sections)
            boot.o (+RO)
        }
        RW_IRAM1 0x20000000 0x00005000 {
            *.o (RESET, +First)
            .ANY (+RO)
            .ANY (+RW)
            .ANY (+ZI)
        }
    }

boot.c:
    static void init_ro_data() {
        unsigned int * from     = (unsigned int*)Load$$RW_IRAM1$$RO$$Base;
        unsigned int * to       = (unsigned int*)Image$$RW_IRAM1$$RO$$Base;
        unsigned int * to_stop  = (unsigned int*)Image$$RW_IRAM1$$RO$$Limit;
        while(to < to_stop) *to++ = *from++;
    }

    static void init_vector() {
        // TODO: copy vector table from flash to ram
        // TODO: SCB->VTOR = new_vector_table, should be 0x20000000
    }

    void Reset_Handler() {
        init_ro_data();     // copy code and const variables to ram
        init_vector();      // copy vecotr table to ram and set new vecotr pointer register
        SystemInit();       // call STM32 SystemInit
        __main();           // call libc runtime init
    }

app.c:
    int main(void) {
        printf("main at 0x%08x\n", main);
        while(1);
    }

  • Hello Xiaofan

    You do not need to manually copy vector table (or ro_data) to RAM, the init code (__main) will do this for you, based on the scatter description file. Is there a reason you are trying to do this?

    Which toolchain are you using? If you are using Keil MDK, there are a number of examples provided (via Pack Installer) that you can use as a basis of your project.