FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2014 Threads] External SRAM problemPosted 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 problemPosted 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 problemPosted 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 problemPosted 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 problemPosted 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 problemPosted 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 problemPosted 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 problemPosted 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 problemPosted 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 problemPosted 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 problemPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|