Firmware main branch @ bbf76e0 (Jan 31 2025 15:45:37)
RP2040 with 264KB RAM, 128Mbit FLASH
I’m trying to work my way through the startup sequence for an SD card using SPI. It’s working admirably well, but I’m curious about the output of the BP commands: they seem to have an extra 0xFF byte before the expected data. Eg: 0xFF 0x01. Is that normal? So, for a command that’s supposed to return Format R1, of 8 bits, is it supposed to be 16 bits, instead? How do I interpret this output, even though it otherwise looks correct? In my microcontroller, I can easily read an extra byte before the “real” data, but am I misunderstanding something?
Can you describe what you are attempting to do and what the expected response would be?
I looked through the SD card command set and I don’t see anything as high as 0x40, 0x48, 0x77, 0x69, etc. The common commands are CMD0-CMD25ish. I also strongly suspect that CS should go high/low between each bus transaction, but do not know for sure.
Thanks, Ian - I have the same doc open. The commands are or’d with 0x40, so command 0x00 would actually be 0x40, etc.
I’ve verified that the startup sequence actually works with a couple of different cards, so I’m going to wire it up to the µcontroller, and do some debugging, there, to see if that first 0xff output byte actually exists in the stream. I’ll post back after, just for completeness.
I spent all day on the µcontroller, and I’m seeing some fundamental issues - which aren’t your problem, but I’d appreciate some insight, nonetheless.
In the image I shared, above, MISO is at 3.3v idle, while MOSI is 0v. Is that “normal”? I mean, the SD card works, but it’s different from what I see on the scope from my µcontroller, a FRDM-KL25Z. On the KL25Z, it looks like both lines ride at 3.3v idle. On a different project that I can verify works, using a Sony Spresense, the SPI lines are like the BP’s: MISO idles high, and MOSI idles low. So it looks like those line levels are “normal.”
I’d appreciate some insight on this aspect from someone who knows more than me.
MISO idle depends on the card, and unless you have the Bus Pirate pull-ups enabled I believe it is actually the card outputting high or has a pull-up of its own.
MOSI idle, I believe, is chip dependent. That would be in the RP2040 datasheet. We also have a 1M Ohm pull-down on all pins.
If the resting state of a pin is an issue, another post reminded me that 3Wire mode is the same as API but with granular control of individual pins with _-/\·! Syntax commands.