This is the typical result of a stack overflow, you’ve to reserve more memory for the task which accesses the SD Card.
Examples, how to do this, can be found in the mios32_config.h and task.c resp. app.c of applications like MIDIbox SEQ, MIDIbox NG, MIDIO128.
MIDIO128 has probably the most simple solution in app.c, it just reserves twice the memory of standard tasks for the 1mS_LP and 1mS_SD task:
xTaskCreate(TASK_Period_1mS, (signed portCHAR *)"1mS", configMINIMAL_STACK_SIZE, NULL, PRIORITY_TASK_PERIOD_1mS, NULL);
xTaskCreate(TASK_Period_1mS_LP, (signed portCHAR *)"1mS_LP", 2*configMINIMAL_STACK_SIZE, NULL, PRIORITY_TASK_PERIOD_1mS_LP, NULL);
xTaskCreate(TASK_Period_1mS_SD, (signed portCHAR *)"1mS_SD", 2*configMINIMAL_STACK_SIZE, NULL, PRIORITY_TASK_PERIOD_1mS_SD, NULL);
and it reserves more heap memory:
// reserved memory for FreeRTOS pvPortMalloc function
#define MIOS32_HEAP_SIZE 14*1024
configMINIMAL_STACK_SIZE is declared in programming_models/traditional/FreeRTOSConfig.h
If you need more memory for all tasks, then don’t change this define, but MIOS32_MINIMAL_STACK_SIZE in your mios32_config.h file.
The standard settings are:
#ifndef MIOS32_MINIMAL_STACK_SIZE
#define MIOS32_MINIMAL_STACK_SIZE 1024
#endif
#ifndef MIOS32_HEAP_SIZE
#define MIOS32_HEAP_SIZE 10*1024
#endif
How to find out the best stack size value?
Call:
umm_info( NULL, 1 );
e.g. from a terminal command after you application was running (and especially executed the most memory hungry functions)
It will dump all memory blocks.
Memory areas which haven’t been overwritten during runtime are marked with the value A5
Best Regards, Thorsten.