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


/* Custom linker script for RAM-Boot (Non-XIP) configuration on i.MX RT1024 */
/* Standard Zephyr token compatibility version */

MEMORY
{
    /* Physical Flash memory region (FlexSPI) used strictly for LMA storage */
    NXP_FLASH_LMA (rx) : ORIGIN = 0x60000000, LENGTH = 4M
    
    /* We name this region FLASH because Zephyr's internal preprocessor requires it.
       But we set its ORIGIN to 0x80000000 (SDRAM) for VMA code execution. */
    FLASH (rx)         : ORIGIN = 0x80000000, LENGTH = 16M
    
    /* Standard RAM region for data, variables and stacks in SDRAM */
    RAM   (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 (VMA -> FLASH, LMA -> FLASH_LMA) */
    /* ================================================================= */

    /* CRITICAL STEP: We explicitly map VMA to FLASH (0x80...) and LMA to 
       NXP_FLASH_LMA (0x60...) for the very first section. 
       This establishes a fixed LMA-to-VMA delta (-0x20000000) for GNU LD. */
    .rom_start : ALIGN(4)
    {
        #include <snippets-rom-start.ld>
    } > FLASH AT> NXP_FLASH_LMA

    /* --- AUTOMATIC LMA PROPAGATION FOR INTERNAL SECTIONS --- */
    /* Because .rom_start established the LMA offset, GNU LD will now
       automatically propagate this delta to all subsequent sections using '> FLASH'.
       They will all get VMA=0x80... and LMA=0x60... seamlessly! */

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

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

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

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


    /* ================================================================= */
    /* GROUP 2: INITIALIZED DATA & KERNEL OBJECTS (VMA -> RAM, LMA -> FLASH) */
    /* ================================================================= */

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

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

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

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

    /* Includes hidden sections: device_states, log_dynamic_area, k_mutex_area, etc.
       Since .datas had an explicit AT> token, these internal 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 = .;
    } > RAM

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


    /* ================================================================= */
    /* 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 & SYSTEM ATTRIBUTES                    */
    /* ================================================================= */
    
    /* Explicitly place ARM attributes section to prevent linker orphan warnings */
    .ARM.attributes 0 : { KEEP(*(.ARM.attributes)) KEEP(*(.gnu.attributes)) }

    #include <zephyr/linker/debug-sections.ld>
}