Загрузка данных


/* Custom linker script for RAM-Boot (Non-XIP) configuration on i.MX RT1024 */
/* Leverages GNU LD's implicit LMA propagation to handle hidden kernel sections */

MEMORY
{
    /* Physical Flash memory region (FlexSPI) for LMA storage */
    NXP_FLASH_LMA (rx) : ORIGIN = 0x60000000, LENGTH = 4M
    
    /* Dedicated SDRAM region for Code execution (VMA) */
    SDRAM_CODE (rx)    : ORIGIN = 0x80000000, LENGTH = 16M
    
    /* Dedicated SDRAM region for Data and Stacks (VMA) */
    SDRAM_DATA (wx)    : ORIGIN = 0x81000000, LENGTH = 16M
    
    /* Fast Tightly Coupled Memory for data (Internal Core RAM) */
    DTCM  (wx)         : ORIGIN = 0x20000000, LENGTH = 128K
}

ENTRY(CONFIG_KERNEL_ENTRY)

SECTIONS
{
    /* ================================================================= */
    /* GROUP 1: CODE, CONSTANTS & SUBSYSTEMS                            */
    /* ================================================================= */

    /* CRITICAL STEP: We explicitly map VMA to SDRAM and LMA to Flash for the 
       very first section. This establishes a fixed offset (-0x20000000) 
       between VMA (0x80000000) and LMA (0x60000000). */
    .rom_start : ALIGN(4)
    {
        #include <snippets-rom-start.ld>
    } > SDRAM_CODE AT> NXP_FLASH_LMA

    /* --- AUTOMATIC LMA PROPAGATION FOR INTERNAL SECTIONS --- */
    /* We map the 'FLASH' token used by Zephyr internals to 'SDRAM_CODE'.
       Because .rom_start established the LMA-to-VMA delta, GNU LD will 
       automatically propagate this offset to .text, common-rom.ld, and .rodata! 
       They will all get VMA=0x80... and LMA=0x60... without manual AT> tokens. */
    FLASH = SDRAM_CODE;

    .text : ALIGN(16)
    {
        __text_region_start = .;
        *(.text)
        *(.text.*)
        *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
        . = ALIGN(4);
        __text_region_end = .;
    } > SDRAM_CODE

    .ARM.exidx : ALIGN(4)
    {
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > SDRAM_CODE

    /* Includes hidden *_area sections: initlevel, device_area, sw_isr_table, etc.
       They all output to 'FLASH' (SDRAM_CODE) and inherit LMA into Flash perfectly. */
    #include <zephyr/linker/common-rom.ld> 

    .rodata : ALIGN(8)
    {
        *(.rodata)
        *(.rodata.*)
    } > SDRAM_CODE


    /* ================================================================= */
    /* GROUP 2: INITIALIZED DATA & KERNEL OBJECTS                       */
    /* ================================================================= */

    /* For data sections running from a different RAM region (SDRAM_DATA), 
       we must manually enforce the AT> NXP_FLASH_LMA rule to keep packing 
       their initial values into the Flash image. */

    .nocache : ALIGN(2048)
    {
        *(.nocache)
        *(.nocache.*)
    } > SDRAM_DATA AT> NXP_FLASH_LMA

    .ramfunc : ALIGN(4)
    {
        *(.ramfunc)
        *(.ramfunc.*)
    } > SDRAM_DATA AT> NXP_FLASH_LMA

    .datas : ALIGN(8)
    {
        __data_ram_start = .;
        *(.data)
        *(.data.*)
        __data_ram_end = .;
    } > SDRAM_DATA AT> NXP_FLASH_LMA

    /* Redirecting RAM token for Zephyr's internal kernel object arrays */
    RAM = SDRAM_DATA;
    
    /* Includes hidden sections: device_states, log_dynamic_area, k_mutex_area, etc.
       Since the previous section (.datas) had an explicit AT> NXP_FLASH_LMA, 
       these hidden RAM sections will also correctly inherit LMA into Flash. */
    #include <zephyr/linker/common-ram.ld>


    /* ================================================================= */
    /* GROUP 3: UNINITIALIZED DATA (RAM ONLY, NO STORAGE IN FLASH)       */
    /* ================================================================= */

    .bss (NOLOAD) : ALIGN(8)
    {
        __bss_start = .;
        *(.bss)
        *(.bss.*)
        *(COMMON)
        __bss_end = .;
    } > SDRAM_DATA

    .noinit (NOLOAD) : ALIGN(128)
    {
        *(.noinit)
        *(.noinit.*)
    } > SDRAM_DATA


    /* ================================================================= */
    /* GROUP 4: TIGHTLY COUPLED MEMORY (DTCM ONLY, NO STORAGE IN FLASH)  */
    /* ================================================================= */

    .dtcm_bss (NOLOAD) : ALIGN(64)
    {
        *(.dtcm_bss)
        *(.dtcm_bss.*)
    } > DTCM

    .dtcm_noinit (NOLOAD) : ALIGN(64)
    {
        *(.dtcm_noinit)
        *(.dtcm_noinit.*)
    } > DTCM


    /* ================================================================= */
    /* GROUP 5: DEBUGGING SYMBOLS (HOST-PC ONLY)                         */
    /* ================================================================= */
    #include <zephyr/linker/debug-sections.ld>
}