2023-05-03 04:57 AM
So, I am working on a program that is supposed to create a log file on an SD card as part of a bigger system. For this I am working with FreeRTOS, using the actual FreeRTOS commands, not the CMSIS counterparts, I am also using the FatFS API, I am also using SPI for the data transfer. And while the code worked fine a few hours ago, just running a single task that created a file on the root of the SD card and wrote a string into that file. After this I tried to create a task that would update the file with an appended string, and with this I created a mutex to make sure that the tasks ran sequentially, however after this the program is not working when debugging, and no files are created.
When I run the debugger the LD1 flashes as one would expect, however after switching to the debug window in the IDE, and it switching to run the main function, the LD1 stops flashing, and nothing is happening when the debug is resumed, nothing is printed to the serial monitor (using Tera Term), and as said no files are created. When I terminate the debugging, the LD1 goes back to shining the default red. I have tried to create a new project, as well as using a different STM32L432KC and the same keeps happening.
The actual program I am running is taken from ControllersTech on YouTube dealing with saving data to an SD card, and while the original program is meant for C, and executes just fine for me, the adapted version in FreeRTOS using the same program copy pasted into the task does not. I have attached the project; including what is printed to the debug console, as well as the ControllersTech project. I have not been able to find anything that deals with similar issues, so I was wondering if anyone might be able to see what is going wrong. I am currently a uni student, and this semester is the first time I am working with STM32's and FreeRTOS, so sorry in advance if I am not quick to understand.
STMicroelectronics ST-LINK GDB server. Version 7.3.0
Copyright (c) 2023, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
LogFile Name : C:\Users\Jonas Pedesk\STM32CubeIDE\workspace_1.12.0\SD_in_FreeRTOS\Debug\st-link_gdbserver_log.txt
Logging Level : 31
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Enabled
SWD Debug : Enabled
InitWhile : Enabled
COM frequency = 4000 kHz
Target connection mode: Under reset
Reading ROM table for AP 0 @0xe00fffd0
Hardware watchpoint supported by the target
ST-LINK Firmware version : V2J41M27
Device ID: 0x435
PC: 0x8000bb4
ST-LINK device status: HALT_MODE
ST-LINK detects target voltage = 3.29 V
ST-LINK device status: HALT_MODE
ST-LINK device initialization OK
Stm32Device, pollAndNotify running...
SwvSrv state change: 0 -> 1
Waiting for connection on port 61235...
Waiting for debugger connection...
Waiting for connection on port 61234...
Accepted connection on port 61234...
Debugger connected
Waiting for debugger connection...
Waiting for connection on port 61234...
GDB session thread running
GdbSessionManager, session started: 1
Accepted connection on port 61234...
Debugger connected
Waiting for debugger connection...
Waiting for connection on port 61234...
GDB session thread running
GdbSessionManager, session started: 2
Accepted connection on port 61235...
SWV collect poll delay set to 3413µs for baudrate 2000000Hz (buffer size 2048b)
SwvSrv state change: 1 -> 2
Stm32Device, closeDevice() entry
SwvSrv state change: 2 -> 4
GDB session, device event: 5
GDB session, device event: 5
Stm32Device, pollAndNotify stopped
Stm32Device, closeDevice() exit
------ Switching to STM32CubeProgrammer -----
-------------------------------------------------------------------
STM32CubeProgrammer v2.13.0
-------------------------------------------------------------------
Log output file: C:\Users\JONASP~1\AppData\Local\Temp\STM32CubeProgrammer_a26488.log
ST-LINK SN : 066AFF525171494867251231
ST-LINK FW : V2J41M27
Board : NUCLEO-L432KC
Voltage : 3.29V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x435
Revision ID : Rev Z
Device name : STM32L43xxx/STM32L44xxx
Flash size : 256 KBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0x91
Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a26488.srec
File : ST-LINK_GDB_server_a26488.srec
Size : 42.16 KB
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 21]
Download in Progress:
�������������������������������������������������� 0%
�������������������������������������������������� 100%
File download complete
Time elapsed during download operation: 00:00:01.585
Verifying ...
Read progress:
�������������������������������������������������� 50%
�������������������������������������������������� 100%
Download verified successfully
------ Switching context -----
COM frequency = 4000 kHz
Target connection mode: Under reset
Reading ROM table for AP 0 @0xe00fffd0
Hardware watchpoint supported by the target
ST-LINK Firmware version : V2J41M27
Device ID: 0x435
PC: 0x80015e8
ST-LINK detects target voltage = 3.29 V
ST-LINK device status: HALT_MODE
Stm32Device, pollAndNotify running...
SWV collect poll delay set to 3413µs for baudrate 2000000Hz (buffer size 2048b)
SwvSrv state change: 4 -> 2
GDB session, device event: 6
GDB session, device event: 6
SwvSrv state change: 2 -> 3
GDB session, device event: 3
GDB session, device event: 3
GDB session, device event: 1
GDB session, device event: 1
SwvSrv state change: 3 -> 2
GDB session, device event: 0
GDB session, device event: 0
NVIC_DFSR_REG = 0x0000000A
GDB session terminated: Client connection lost
GdbSessionManager, session terminated: 1
Cleanup session: 1
GDB session disposed: 1
GDB session terminated: Client connection lost
GdbSessionManager, session terminated: 2
GdbSrv, last session terminated, signal dispose
Stopping port 61234
SwvSrv state change: 2 -> 1
SwvSrv session thread disposed
Waiting for connection on port 61235...
Cleanup session: 2
GDB session disposed: 2
Received stop for port 61234, not accepting new connections.
GdbSrv, deInit entry.
Shutting down...
GdbSessionManager, deInit entry.
Stopping port 61234
GdbSessionManager, deInit exit
SwvSrv deInit entry
Stopping port 61235
Received stop for port 61235, not accepting new connections.
SwvSrv deInit exit
Stm32Device, closeDevice() entry
Stm32Device, pollAndNotify stopped
Stm32Device, closeDevice() exit
Stm32Device, deInit success
GdbSrv, deInit exit.
Exit.
2023-05-03 05:35 AM
Here is the ControllersTech video, was not able to include it in the post. https://www.youtube.com/watch?v=spVIZO-jbxE&t=1s
2023-10-06 05:45 AM
Hi,
are you able to solve this? I am working with STM32l432KC with sd card using SPI but it doesnt workout for me. can you help if sd card interfacing is working for you?