Pregunta

Estoy trabajando en un chip Cortex-m3.El espacio de la pila se reservó en el código fuente con una matriz no inicializada en la sección bss.El script del enlazador que utilicé es el siguiente:

MEMORY
{
    FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256k
    SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64k
}

SECTIONS {
    .text : {
        KEEP(*(.isr_vector))
        *(.text*)
        *(.rodata*)
        __text_end = .;
    } >FLASH

    .data : {
        __data_start = .;
        *(.data*)
        __data_end = .;
    } >SRAM AT>FLASH

    .bss : {
        __bss_start = .;
        *(.bss*)
        __bss_end = .;
    } >SRAM
}

Estoy tratando de asignar una sección para la pila al comienzo de la región SRAM para poder detectar el desbordamiento de la pila con fallas de uso.

Agregué una sección llamada .stack:

SECTIONS {
    .text : {
        :
    } >FLASH

    .stack : {
        __stack_size = 4k;
        __stack_start = .;
        . = . + __stack_size;
        . = ALIGN(8);         /* cortex-m3 uses full-descending stack aligned with 8 bytes */
        __stack_end = .;
    } >SRAM

    .data : {
        :
    } >SRAM AT>FLASH

    .bss : {
        :
    } >SRAM
}

La vinculación se realiza sin ningún error o advertencia, pero el problema es que __stack_end no está en la región SRAM sino en la región FLASH.

¿Cómo puedo crear una sección vacía en la región SRAM?

¿Fue útil?

Solución

Simplemente divida el área de RAM en dos:

MEMORY
{
    FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256k
    SRAM_STACK (rwx) : ORIGIN = 0x20000000, LENGTH = 4k
    SRAM (rwx) : ORIGIN = 0x20001000, LENGTH = 60k
}
SECTIONS {
.text : {
    KEEP(*(.isr_vector))
    *(.text*)
    *(.rodata*)
    __text_end = .;
} >FLASH

.data : {
     __data_start = .;
    *(.data*)
    __data_end = .;
} >SRAM AT>FLASH

.bss : {
    __bss_start = .;
    *(.bss*)
    __bss_end = .;
} >SRAM

.stack : {
    __stack_size = 4k;
    __stack_start = .;
    . = . + __stack_size;
    . = ALIGN(8);         /* cortex-m3 uses full-descending stack aligned with 8 bytes */
    __stack_end = .;
} >SRAM_STACK

}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top