ResetISR copy .data section to RAM2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ResetISR copy .data section to RAM2

533 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jeshwanth on Tue Feb 10 23:16:24 MST 2015
Hello List,

I was analysing the ResetISR function in cr_startup_lpc175x_6x.c file. But I can see the copying of .data section is happening for First RAM i.e. RAM1. What if I have .data section in RAM2 ?

I am little confused with below code with respect to RAM2, please comment

ResetISR(void) {

    //
    // Copy the data sections from flash to SRAM.
    //
    unsigned int LoadAddr, ExeAddr, SectionLen;
    unsigned int *SectionTableAddr;

    // Load base address of Global Section Table
    SectionTableAddr = &__data_section_table;

    // Copy the data sections from flash to SRAM.
    while (SectionTableAddr < &__data_section_table_end) {
        LoadAddr = *SectionTableAddr++;
        ExeAddr = *SectionTableAddr++;
        SectionLen = *SectionTableAddr++;
        data_init(LoadAddr, ExeAddr, SectionLen);
    }
    // At this point, SectionTableAddr = &__bss_section_table;
    // Zero fill the bss segment
    while (SectionTableAddr < &__bss_section_table_end) {
        ExeAddr = *SectionTableAddr++;
        SectionLen = *SectionTableAddr++;
        bss_init(ExeAddr, SectionLen);
    }

#if defined (__USE_CMSIS) || defined (__USE_LPCOPEN)
    SystemInit();
#endif

#if defined (__cplusplus)
    //
    // Call C++ library initialisation
    //
    __libc_init_array();
#endif

#if defined (__REDLIB__)
    // Call the Redlib library, which in turn calls main()
    __main() ;
#else
    main();
#endif

    //
    // main() shouldn't return, but if it does, we'll just enter an infinite loop
    //
    while (1) {
        ;
    }
}


Thanks in Advance.
Labels (1)
0 Kudos
2 Replies

460 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jeshwanth on Wed Feb 11 01:45:42 MST 2015
Hi,

I just referred the Linker file, now understood about the data and bss section table :).

__data_section_table = .;
LONG(LOADADDR(.data));
LONG( ADDR(.data)) ;
LONG( SIZEOF(.data));
LONG(LOADADDR(.data_RAM2));
LONG( ADDR(.data_RAM2)) ;
LONG( SIZEOF(.data_RAM2));
__data_section_table_end = .;
__bss_section_table = .;
LONG( ADDR(.bss));
LONG( SIZEOF(.bss));
LONG( ADDR(.bss_RAM2));
LONG( SIZEOF(.bss_RAM2));
__bss_section_table_end = .


Thanks a lot
0 Kudos

460 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Wed Feb 11 00:36:24 MST 2015
If you read the code carefully, you will see it is initialising all of the data sections listed in a table (the data_section_table). This works in conjunction with the (Managed) Linker script, which creates an entry for each data section.

So, this code initialises all data sections.
0 Kudos