2019-12-18 02:10 PM
I am completely baffled by an issue I’m having with the STM32H7 using the SDMMC and a micro SD card. I have the F7 working and two H7 platforms that both have the same data timeout problem.
The STM32F767ZI Nucleo board working OK with the SDMMC and a micro SD card connected to the Nucleo with a breakout board connected to the IO pins. I have run it successfully in the D0 pin and the D0-D3 pin configurations. I used the STM32F767ZI-Nucleo Project and the FatFs example that ST provides as part of the STM32CubeF7-master.
I am using STM32H743ZI Nucleo board with the firmware from the STM32CubeH7-master, for the NUCLEO-H743ZI. Since I am not using the Adafruit adapter for the SD card, I used the stm32h743i_eval_sd.c from the STM32H743I-EVAL project and set _USE_IOCTL to 0 since I am not using the SD Card IO level shifters. I changed the card detect to properly detect my card.
The SD card is connected directly to the same pins on both Nucleo cards, which is the STMMC1 controller on both the F7 and H7 processors.
The F7 board came right up and worked, while the H7 board device did not.
The H7 is initializing the SD card OK. I can see commands and responses going back and forth between the CPU and the SD card on the CMD line with a logic analyzer. It fails with a data timeout the first time the response from the SD Card is supposed to come back from the SD card on the D0 line. This happens in the HAL_SD_ReadBlocks routine.
At this point in the initialization the clock speed is only 400 KHz, and the timeout is waiting at >1 second for a response, which never comes.
I am sure the SD card adapter is working because I have successfully used the same adapter on the F7. I’ve checked connectivity between the pins on the adapter board to the Nucleo board with a DVM.
I believe the issue is somewhere in the initialization software. I say this because I have custom board with a STM32H743VIT6 (same part in a 100-pin package) with a SD card connected to the same logical pins and I am seeing the same exact problem with the data timeout in the same spot in the code.
I’ve been trying to debug this problem for a week and I am no closer to resolving it. I know people on this forum have been able to get the STM32H743ZI Nucleo board to work with a SD card. Since this fails on two different hardware platforms, I have to believe there is something is wrong in the firmware.
Here are more things that I’ve done in debugging:
· _USE_IOCTL = 0 to disable the code for the level shifter
· Read the Errata sheet for possible issues
· Ported the working F7 code to the H7 and replaced the specific H7 code. Ran into the same problem.
· Checked voltages and noise on the SD card. All looked OK.
· Tried faster and slower clock speeds to the SD card. This did not make any difference.
· Tried 1-bit vs 4-bit configuration. No difference.
· Rebuilt all of the code from the examples 2 more times in case I missed something – still the same issue.
Does anyone have any ideas what may be wrong?
I have seen where some people on the forum have this working on the H7. I would be extremely appreciative if someone could share the code they have working for SD Card if it uses the SDIO and not the SPI bus. I need to use SDIO since my board is already built.
Sorry for the long post. I wanted to provide all of the background information.
2019-12-18 02:27 PM
Standard SDMMC1 or 2 pins? GPIO for Card Detect? What about a workable UART?
IOCTL? You mean USE_TRANSCEIVER ?
2019-12-19 05:48 AM
I am using the standard SDMMC1 pins. I have the GPIO Card detect pin defined and working with a pullup resistor. It passes the card detect function. I have a UART working on my custom board that has the same issue, but not the Nucleo.
The diskio.h file line 13 has: #define _USE_IOCTL 0 /* 1: Enable disk_ioctl function */
I searched the file for USE_TRANSCEIVER, and it was not found.
I checked the master STM32CubeH7-master\Middlewares\Third_Party\FatFs\src\diskio.h file to make sure I was not using a modified version, and I am not. This is in the master file.
I am using the V1.5.0 / 28-June-2019 version of STM32CubeH7-master, which is the latest. I looked through the release notes and I don't see any reference to changing USE_TRANSCEIVER to _USE_IOCTL. I tried setting _USE_IOCTL to 1 and it didn't seem to make any difference with the data timeout I'm getting.
The Nucleo board I'm using is new. It is a Nucleo-H743ZI2. It does not have the break-off tab on the USB end, and does not seem to have the stubs referred to in an earlier post. I don't think this is the issue since I'm seeing the same problem on the Nucleo board and my custom board.
2019-12-19 06:08 AM
I'll have to dig out the NUCLEO-H7 demo and try it on the H743ZI2 board
2019-12-19 04:12 PM
I found the #define "USE_SD_TRANSCEIVER 1U" statement in the stm32h7xx_hal_conf.h file and set it to 0. That made no difference.
It is failing in HAL_SD_GetCardStatus --> SD_SendSDStatus which returns the data timeout error.
2019-12-19 05:12 PM
Ok, well ran on the ZI2 with no changes, need to perhaps change one of the LEDs, this was built out of V1.2.0 fork. Outputs to VCP at 115200 8N1
Nucleo H743ZI
Core=400000000, 400 MHz
CPUID 411FC271 DEVID 000 REVID 0000
Cortex M7 r1p1
Unknown STM32
C0000038 24013780 00000000
10110221 12000011 00000040
FPU-D Single-precision and Double-precision
HCLK=200000000
APB1=100000000
APB2=100000000
FatFs Testing (68300)
Mounting FatFs
BSP_SD_MspInit
CardInfo 15446016 512 512 ( 7.37 GB)
LIMIT 0000003F BPB 0000003F
READ 0 1
00000000 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000010 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000020 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000030 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000040 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000050 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000060 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000070 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000080 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000090 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000A0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000B0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000C0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000D0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000E0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000F0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000100 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000110 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000120 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000130 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000140 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000150 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000160 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000170 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000180 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000190 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001A0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001B0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 01 ................
000001C0 : 01 00 0C FE FF C1 3F 00-00 00 C1 AF EB 00 00 00 ......?.........
000001D0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001E0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001F0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 55 AA ..............U.
READ 63 1
00000000 : EB FE 90 4D 53 44 4F 53-35 2E 30 00 02 40 63 00 ...MSDOS5.0..@c.
00000010 : 01 00 00 00 00 F8 00 00-3F 00 FF 00 3F 00 00 00 ........?...?...
00000020 : C1 AF EB 00 5E 07 00 00-00 00 00 00 02 00 00 00 ....^...........
00000030 : 01 00 06 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000040 : 80 00 29 00 00 00 00 4E-4F 20 4E 41 4D 45 20 20 ..)....NO NAME
00000050 : 20 20 46 41 54 33 32 20-20 20 00 00 00 00 00 00 FAT32 ......
00000060 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000070 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000080 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000090 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000A0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000B0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000C0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000D0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000E0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000000F0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000100 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000110 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000120 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000130 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000140 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000150 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000160 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000170 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000180 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00000190 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001A0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001B0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001C0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001D0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001E0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
000001F0 : 00 00 00 00 00 00 00 00-00 00 00 00 00 00 55 AA ..............U.
FAT32
7.7 GB total drive space
218.5 MB available
7.5 GB used
Display Directory
---- 78 /STM32.TXT
D-SH 0 /System Volume Information
D--- 0 /RINEX
---- 32768000 /COUNTER.004
D--- 0 /TRILO
COUNTER.004
32768000 Bytes, 726129967 Cycles
18.05 MBps Read (FatFs)
1816 ms run time
18.04 MBps (Sanity Check)
32768000 Bytes, 726227365 Cycles
18.05 MBps Read (FatFs)
1816 ms run time
18.04 MBps (Sanity Check)
24000890 240008A0 16384
CRC32 13363AF4 PKZIP ECC9C50B /TRILO/TRILO.010
24000890 240008A0 30720
CRC32 13363AF4 PKZIP ECC9C50B /TRILO/TRILO.010
24000890 240008A0 32768
CRC32 13363AF4 PKZIP ECC9C50B /TRILO/TRILO.010
24000890 240008A0 65536
CRC32 13363AF4 PKZIP ECC9C50B /TRILO/TRILO.010
Done!
PLL1_Q_CK=200000000, 200.00 MHz
PLL2_R_CK=0, 0.00 MHz
SDMMC_CK 2, 50.00 MHz
Infinite loop...
2019-12-19 05:20 PM
2019-12-20 07:40 AM
Thank you! Interestingly, this has the same issue. It looks like it is hanging in the initialization.
Nucleo H743ZI
Core=400000000, 400 MHz
CPUID 411FC271 DEVID 450 REVID 2003
Cortex M7 r1p1
STM32H7xx
C0000038 24013780 00000000
10110221 12000011 00000040
FPU-D Single-precision and Double-precision
HCLK=200000000
APB1=100000000
APB2=100000000
FatFs Testing (68300)
Mounting FatFs
BSP_SD_MspInit
{ Hang }
From what I've seen before, it is waiting for the SD card to respond on the D0 line. The default data timeout is set to a very long value. There is no activity on D0.
This is very helpful. Even though the SD Card adapter works on the F7, the same adapter does not work on the H7. I see you are using an adapter board with no wires. The wire length on my board are about 3" long, and the clock speeds at this phase of initialization are < 1 MHz. Why it has the same issue on my H7 custom board is puzzling. The signal length is <1" from processor to SD adapter, and the board is 4 layers with layers 2 & 3 dedicated to power and ground.
If it is not a software or processor issue, that says it is a signal or power issue. I don't think there is anything else left.
Your adapter card looks like it has resistors. Are they series or pullup resistors? If pullup, do you know what value they are? I do not have the SD Card signals pulled up externally on either board. I'm using the pullups in the processor on all of the SD Card IO Pins pins. That could explain why the F7 works and the H7 does not.
2019-12-20 08:36 AM
I'll have to double check what got placed on the cards, but I spec'd 33K or 47K pull-ups
Also got equivalents to this constructed from 3" schmart-board jumper wires and SparkFun, WaveShare or ViewTool sockets, running on H7 boards.
https://schmartboard.com/jumper-wires/
On the eMMC cards we had 27R or 33R series resistors to limit the ringing.
Will need to double check the code build to see if I enabled STM32 side pull-ups, or not.
2019-12-20 09:53 AM
Success! After the clue that it may have something to do with the pullup in the processor, I ran the processor just to the point after the pullups are enabled. I pulled the SD card out and put it back in to reset it. Then, I ran the rest of the code. Initialization, read & write all worked, and is repeatable! I need to slow the SD clock down, because it is running at 25 MHz and passing. That is too fast for a jumper-wire board.
I think that when the processor is reset and the SD Card control signals are not initialized, the unknown state of the signals it is getting the SD card into a state where it responds to commands on the CMD bus, but won't send data on D0. This must be a difference between the F7 and H7, or just my configuration.
This is what the exchange should look like. The red arrow is where it was failing.
I suspect the value of the resistors you are using are around 50K. Next I'll install permanent resistors on my breakout board, then (try) to install them on my custom board.
Thank you for all of your help! Without the known-good software, I'm not sure I'd have gone back and looked at the hardware again.