SD card Error #3081
Replies: 38 comments 24 replies
|
Today I connected another completely new Weact board, and it doesn’t reliably detect SD cards. In about 90 percent of cases, it doesn’t see the card, and only in 10 percent does it see it. |
|
Could you try this clock config (simply copy/paste it before setup()), note that it should also allows to use LPUART1 at 19200: |
|
I'm currently checking with a Kingston Industrial 32 GB SDCIT2/32GB SD card. |
|
This is on a different STM32H743VIT6 board with a different SD card (QUMO 16GB). |
|
Continuation... |
|
WOW!!! I’ll check it on another board now and get back to you. |
|
When the power is supplied, everything works perfectly, and the response is always “Micro SD card OK!” |
|
Debug mode: Registers before the command if (!SD.begin(SD_DETECT_PIN, HIGH)) { Registers after the command if (!SD.begin(SD_DETECT_PIN, HIGH)) SD OK Registers after the command if (!SD.begin(SD_DETECT_PIN, HIGH)) SD ERROR |
|
Hmm... |
|
To figure out the problem, I started doing step‑by‑step debugging. I’m adding debug information output to the monitor. In the command BSP_SD_Init() it returns either false or true. I will debug BSP_SD_Init() |
|
pinMode(SD_DETECT_PIN, INPUT_PULLUP) — this is indeed a solution for Weact Studio boards with an SD card connector. @fpistm — thank you very much for helping to figure out this complex problem! |
|
Hmmmmm... I'm shocked! |
|
I recorded the screen of my PC. The SD card is in the SD slot. How can this be understood???? Link to the video |
|
file bsp_sd.c I checked with an oscilloscope in the debugger, and these commands are indeed executed, and the level on PD4 becomes high. But if I don’t first execute the command pinMode(SD_DETECT_PIN, INPUT_PULLUP) in my code, the SD card is not detected!!! |
|
Tomorrow I’ll take a webcam with me and will simultaneously record video from the computer screen and video from the STM32 board. |
|
Hi,@fpistm ! Please watch this video https://drive.google.com/file/d/1t0Yj8fW4UO3FSSdlkzkXBHH1mUYdpkr-/view?usp=sharing |
|
Hi ! I checked your sketch. It always outputs 1. However, periodically the board stops performing the automatic software reboot. |
|
I recorded a short video. After the first load, the program executed once and stopped. After the second load, the program also executed once and stopped. After the third load, the program executed once again. Then I pressed the reset button on the board, and the program started running with automatic rebooting. https://drive.google.com/file/d/1iJZYKCMAE1jRL4wSjn8Pst9-g9Cyht6o/view?usp=sharing |
|
I brought another board. The same code without the pinMode(SD_DETECT_PIN, INPUT_PULLUP) command; the board behaves differently. It turns on more often when the power is turned off and on. It almost always turns on when the reset button is pressed. It’s very unstable. I recorded this video, please take a look at it. https://drive.google.com/file/d/15pW18G1pq2Fou9gESLzWyNzqTpUl2VeW/view?usp=sharing This is some kind of fantasy. I don’t understand how this is possible! |
|
Another very interesting video, please watch it in full. When I hold the board from the sides, it is more likely to display ‘OK’. When I hold the board diagonally, it is more likely to display ‘Error’. I don’t understand this at all ((( https://drive.google.com/file/d/1eW0K2YofE1U2rA2UFoJsXC-CGVSd6Ley/view?usp=sharing |
|
I made another interesting video. If there is a command pinMode(SD_DETECT_PIN, INPUT_PULLUP); and the SD card is inserted into the connector, it’s always OK! 100%! No matter how I hold the board — from the sides or diagonally — it always works! https://drive.google.com/file/d/13evTelOYNFQ-soQi8jg2RX6M5R3sr-90/view?usp=sharing |
|
Hi,@fpistm ! I decided to take another look at what’s happening in the debugger in the bsp_sd.c file. Since it’s not possible to set a breakpoint on sd_state = MSD_ERROR_SD_NOT_PRESENT; I temporarily added my own printf("SD Card initialized error!\r\n"); // **************************************************************************** and set a breakpoint on it and started looking at what was happening with the condition if (BSP_SD_IsDetected() != SD_PRESENT) { /* Check if SD card is present */ and found that both when there was an error in detection and when the card was detected correctly, BSP_SD_IsDetected() is always equal to 0x1 ! When there is no error in detecting the SD card, the code stops at line 320, but when, for some reason that is unclear to me, it fails to detect the SD card, the code stops at line 314. What does it mean? I recorded this video while debugging. https://drive.google.com/file/d/1ZzC6OrQAS14OycUN_21iPeJkRp7uuCbc/view?usp=sharing |
|
What I recorded in this video is impossible!!! In the debugger, this condition is met: if (BSP_SD_IsDetected() != SD_PRESENT), even though BSP_SD_IsDetected() = 0x1 and SD_PRESENT = 0x1!!! https://drive.google.com/file/d/1zo0-ZNFHDFIghnUtJi1Ql5tH1oH-B7jv/view?usp=sharing The file bsp_sd.c = 25121 bytes (STM32SD 1.5.0) |
|
Hi,@fpistm ! I cleared the cache and also checked the program compilation on another computer; the same situation occurs — after disconnecting and reconnecting the power, the card initialization is unstable. MCU What other data about the MCU is available, and where can it be viewed? All the boards (I bought more than 100 of them) are from the official store WeAct Studio on AliExpress. |
|
On Monday, I will install a completely new Windows 11 + Arduino system and will be ready to provide you with full remote access (for example, via AnyDesk). I will connect a video camera to the board so that you can connect and personally see what is happening. Will you have this opportunity? We will agree on a time that is convenient for you. |
|
I can also prepare all the Arduino IDE + STM32CubeProgrammer distributions, and we’ll do the initial installation and configuration together on a completely clean Windows system. I’m really asking for help to sort out this very complex problem — I have no other thoughts left. |
|
I also have a new board with an SD connector WeAct Studio STM32H562RGT6. Tomorrow I’ll solder on the programming connector and see how the SD card initialization works on this board. |
|
Today I had the opportunity to conduct additional tests as you advised. The command HAL_ICACHE_Disable() generates an error MicroSD_test_TFT.ino:56:3: error: 'HAL_ICACHE_Disable' was not declared in this scope; did you mean 'HAL_MPU_Disable'? AI Google suggested that for the H7 series, you need to apply SCB_DisableICache(); // Further code... SCB_EnableICache(); I’ve checked this several hundred times. Without the command pinMode(SD_DETECT_PIN, INPUT_PULLUP); or SCB_DisableICache(), many errors occur during SD card initialization. The command pinMode(SD_DETECT_PIN, INPUT_PULLUP); or SCB_DisableICache() has the same effect — the SD card is initialized 100 % successfully and no errors occur.
|
|
Hi ! I checked the WeAct Studio STM32H562RGT6 board, and the situation is the same. Sometimes the SD card is detected, sometimes it isn’t (((. I noticed that it also depends on how I hold the board with my hands. There’s some kind of pattern here. https://drive.google.com/file/d/1eflDdmv0Ecx7QlWu8LacbxHnkZQG4bYE/view?usp=sharing |
|
I looked at the DISCO board diagram again; all the signals for the SD card are pulled up to the power supply, and this works well for you! On Weact boards, there are no external signal pull‑ups, and that’s why it works very unstable! That’s my version. https://drive.google.com/file/d/1u0_eFct3KnojxK60SG6imtCWA_Qa2EEh/view?usp=sharing |

Uh oh!
There was an error while loading. Please reload this page.
Hi !
Arduino IDE 2.3.10 + Windows 11
Arduino Core for STM32 3.0.0
Lib STM32SD //github.com/stm32duino/STM32SD
board STM32H743VIT6 WeAct and STM32H723VGT6 WeAct
I tested this code on several new boards with different new Micro SD cards, and it always shows an initialization error (Micro SD card Error!).
I have an oscilloscope and a debugger.
Could you tell me how to find the problem?
In what order should I proceed?
I left the most minimal code.
All reactions