Replies: 1 comment
-
Actually, I made a longer recording with the logic analyzer. After about a minute something moves on the line. Immediately after that I see a 0xC0 on the MOSI. However, this last MOSI CMD is different. The SCK line does not look right (the clock is not regular). I noticed also another strange fact: the final error is different from the previous one. This time is:
I could think it is a cabling/disturbance problem...but then I don't understand why on the Arduino it works flawlessly |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am struggling to have a STM32F4 based board use a micro sdcard adapter over SPI.
I checked that the adapter and the sdcard are compatible and functional (with an arduino).
I started looking at the Disk Access documentation where there is an example of overlay to describe my setup. I took inspiration also looking at the fs_sample example.
My Setup
In my case, the relevant overlay is:
Basically, I set up the pins for the SPI, then I set up the spi interface following the stm32 bindings.
On the KConfig side, the relevant part is as follows:
The part of the code where I am trying to initialize the micro sdcard by calling
disk_access_ioctl
is stripped down to:Issue
My application does not pass that call and returns the -134 error. Enabling a more detailed debug I spotted:
<dbg> sd: sdmmc_read_scr: ACMD51 failed: -5
I attached a Logic Analyzer to the pins and I spotted a pattern that confirm that error.
The Master pulls down the CS and sends a
0xFF 0x40 0x00 0x00 0x00 0x00 0x95
The Slave replies with a
0x01
The Master pulls up and down the CS and sends a
0xFF 0x48 0x00 0x00 0x01 0xAA 0x87
The Slave replies with a
0x01 0x00 0x00 0x01 0xAA
These steps continue to repeat
until the errorabout 20 times. Reading a bit about the SDCards, those are the CMD0 and CMD8. Then, the MOSI continues to carry other commands until it reaches a 0x4A command, that should CMD10. The MISO replies with a 0x01 and then it gets stuck: The CS remains down, the SCK continue to switch, but both MOSI and MISO remain HIGH, until the error.I don't understand why the process gets stuck there. Is there somewhere a full working example I can look at?
Thanks in advance for your time ;-).
(edit: typos and update the complete sequence of commands before the freeze)
Beta Was this translation helpful? Give feedback.
All reactions