AnsweredAssumed Answered

STM32F4 and FatFS. SD Card mounting issue.

Question asked by Oleg M on Oct 4, 2017
Latest reply on Oct 5, 2017 by Tilen MAJERLE

Simple issue description: f_mount function from FatFS causes stack problem .


More detailed description:

We have a project in which we use the processor STM32F407Z and we have to read files from an SD Card with using of FatFS. We have generated a test project by STM32CubeMX ( 4.21.0 ver ) and launched it on our plate with mentioned processor. The debugger which we use is SEGGER J-Link Base.

Problem description:

Right after f_mount function works out we get the following warning:

Mon Sep 25, 2017 11:47:03: The stack pointer for stack 'CSTACK' (currently 0x04F95E41) is outside the stack range (0x2000FBE0 to 0x2000FFE0)

If the program is just launched, inspite of the warning a SD Card will be mounted.
But if we debug the program step by step, we get the warning and then the program "gets stucked". SD Card will not be mounted in this case.

I attached the test project. Function f_mount is located at string 580 in the main.c file.



SD Card reading is initiated at string 1533 in function console_main in the main.c file. Later the function process_fs launches and calls f_mount function.

I suppose the problem doesn't break mount function itself, but it crashes something in parrallel tasks. Maybe incorrect pointer is generated somethere.