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
/* 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(ram_ext) + LENGTH(ram_ext) - 4;
SECTIONS
{
.text :
{
// deleted lines
// same in SRAM config
} > rom
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?
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;
}
}
}
no error i make selft-test after initialization SRAM (2 passes),
sysclk_get_main_hz: 240000000
sysclk_get_cpu_hz: 120000000
sysclk_get_peripheral_hz: 120000000
SystemCoreClock: 120000000
SRAM sram_init_status_flag: 0
size of unsigned long: 4
size of double: 8
size of float: 4
size of int: 4
size of long: 4
size of ptrdiff_t: 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
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).
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).
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 HardFault_Handler. When i set the SMC_CYCLE_NWE_CYCLE, SMC_CYCLE_NRD_CYCLE two ticks longer, then stuff start working in FreeRTOS, maybe MATRIX arbitration settings helps too.