Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

External SRAM problem

Posted by pefo77 on March 2, 2014

Hello,

i have problem with running RTOS and external SRAM.

If i use only internal SRAM all works fine. When i configure external SRAM (i can send my ld file) then program don't work. I use Atmel Studio 6.1, ASF 3.14.0 and freertos 7.3.0, gcc 4.7.3

[sram.ld] /* Memory Spaces Definitions */ MEMORY { rom (rx) : ORIGIN = 0x00400000, LENGTH = 0x00100000 ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000 ram_ext (rwxa) : ORIGIN = 0x60000000, LENGTH = 0x00100000 }

/* The stack size used by the application. NOTE: you need to adjust according to your application. */ stack_size = DEFINED(stack_size) ? stack_size : 0x019000; ram_end = ORIGIN(ramext) + LENGTH(ramext) - 4;

SECTIONS { .text : { // deleted lines // same in SRAM config } > rom

PROVIDE_HIDDEN (__exidx_start = .);
.ARM.exidx :
{
  *(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > rom
PROVIDE_HIDDEN (__exidx_end = .);

. = ALIGN(4);
_etext = .;

/* stack section */
.stack (NOLOAD):
{
    . = ALIGN(8);
    _sstack = .;
    . = . + __stack_size__;
    . = ALIGN(8);
    _estack = .;
} > ram

/* free ram section (for dma buffers, etc) */
.free_ram ():
{
    . = ALIGN(4);
    _sfree_ram = .;
} > ram

.relocate : AT (_etext)
{
    . = ALIGN(4);
    _srelocate = .;
    *(.ramfunc .ramfunc.*);
    *(.data .data.*);
    . = ALIGN(4);
    _erelocate = .;
} > ram_ext

/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
    . = ALIGN(4);
    _sbss = . ;
    _szero = .;
    *(.bss .bss.*)
    *(COMMON)
    . = ALIGN(4);
    _ebss = . ;
    _ezero = .;
} > ram_ext

. = ALIGN(4);
_end = . ;

}


External SRAM problem

Posted by davedoors on March 2, 2014

What does "not work" mean? You can't program the chip, or main() is not called, or main() is called but the scheduler does not start, or the scheduler does start but context switches don't happen, or one of many other possibilities?


External SRAM problem

Posted by pefo77 on March 2, 2014

Hello,

scheduler start, but don't run any task. When i move xHeap (heap4.c) to internal SRAM, tasks is working.

same behavior is described here: http://www.freertos.org/FreeRTOSSupportForumArchive/May2012/freertosPutheapinexternalmemoryforSTM325243508.html

Peter.


External SRAM problem

Posted by rtel on March 2, 2014

Does the chip allow the stack to be allocated in external RAM?

If so, what happens if you allocate and use external SRAM before the scheduler is started? For example:


void main( void )
{
char *c;
long l, lError = pdFALSE;

    /* Allocate a buffer. */
    c = pvPortMalloc( 1000 );

    /* Fill the buffer with known values. */
    for( l = 0; l < 1000; l++ )
    {
        c[ l ] = ( char ) l;
    }

    /* Check the value was actually written. */
    for( l = 0; l < 1000; l++ )
    {
        if( c[ l ] != ( char ) l )
        {
            lError = pdTRUE;
        }
    }
}

External SRAM problem

Posted by pefo77 on March 2, 2014

Hi,

no error i make selft-test after initialization SRAM (2 passes),

sysclkgetmainhz: 240000000 sysclkgetcpuhz: 120000000 sysclkgetperipheralhz: 120000000 SystemCoreClock: 120000000 SRAM _sraminitstatusflag: 0 size of unsigned long: 4 size of double: 8 size of float: 4 size of int: 4 size of long: 4 size of ptrdifft: 4

lError: 0

If the xHeap is in ext SRAM , program hang up in HardFault_Handler - randomly (one or two task calls) - i think there is problem with timing SMC & EBI, and context switching. I have fully funcitonal program using ext. SRAM (without FreeRTOS).

Task: 1

Task: 2

Error: RTOS is down! <---- HardFault_Handler called here

Peter.


External SRAM problem

Posted by rtel on March 2, 2014

If the xHeap is in ext SRAM , program hang up in HardFault_Handler -

I'm afraid I don't know why that would be. It could be a timing issue. If the crash happens in the context switch code then it might be that some additional barrier instructions would fix it.

I have fully funcitonal program using ext. SRAM (without FreeRTOS).

Is that with the stack in SRAM too?

Regards.


External SRAM problem

Posted by pefo77 on March 2, 2014

Memory map is same, stack + some dma buffers is in internal sram. Relocation sector + heap is in ext. Sram.

Peter.


External SRAM problem

Posted by davedoors on March 2, 2014

stack + some dma buffers is in internal sram

The two cases are not the same then.

If you put the FreeRTOS heap in external RAM then the stacks used by the tasks will also be in external RAM.


External SRAM problem

Posted by pefo77 on March 2, 2014

It's true, because freertos have own stack in heap, but main stack is internal sram (see ld file). I must try to force freertos to use main stack in internal sram and heap in ext sram (for malloc and pvPortMalloc).

Peter


External SRAM problem

Posted by pefo77 on March 2, 2014

Some dmb, dsb and isb helps, but not solve it (task's is executed more times before hangs in HardFault), i going to try v8.0.0


External SRAM problem

Posted by pefo77 on March 2, 2014

After many tests i solved some hanging issue, i use 50ns ext. SRAM, timing waves is set precisly to fit it (measured), SRAM woking well without erros, but if i start use FreeRTOS with heap mapped to ext. SRAM, programs hangs in HardFaultHandler. When i set the SMCCYCLENWECYCLE, SMCCYCLENRD_CYCLE two ticks longer, then stuff start working in FreeRTOS, maybe MATRIX arbitration settings helps too.

Peter.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner