# How to measure SD card data timing vs. clock

I'm doing EVT testing of our product and I want to measure the SD card data vs. clock timing to make sure we're inside the specs. We're using LS1043A that boots Linux (via U-Boot) from an SD card using SDIO mode - not SPI.

I want to measure the timings on both sides: at CPU (SD → CPU) and at SD (CPU → SD), but I don't know the direction of data on the four data pins. E.g., when taking measurements at the SD side I have no idea whether I'm seeing data out (CPU reading) or data in (CPU writing) on the scope and I need to know because there are different setup and hold times for both. The CPU output also needs to be measured against the clock's falling edge according to the LS1043 datasheet.

See an example taken in U-Boot (green - clock, yellow - data2):

Another taken when already in Linux (green - clock, yellow - data2, blue - data3):

So how do I know the direction of data? Is there a command I can use to explicitly read/write from/to SD card? I found mmc write, would that work?

• Sounds you do not know how EVT is performed, and do not know the protocol. For protocol you can refer to the specification; for how EVT is done you refer to developers of the device and to your boss (professor) how they see your job to be done. – Anonymous Oct 25 '18 at 11:41
• Pretty much all operations regardless of the direction of stored data are going to involve both writing and reading in the electrical sense. If it's actually correct that you need to check different timings in each case, then yes, you'd need awareness of the protocol. Perhaps you can capture an entire (brief) operation and zoom in to the part of interest. If memory depth is a problem you may be able to do a delayed capture around the part of interest, once you identify it. You'll probably want figure out how to do a single low level operation or modify the driver to pulse a GPIO as trigger. – Chris Stratton Oct 25 '18 at 14:06
• SDIO mode uses more signals. You really need to use a Protocol/Logic Analyzer, then you can capture data & control lines, and readily tell from the control lines whether a read or write is occurring, and what the data is. Look at www.Saleae.com for their 100 MHz or 500 MHz, 8-channel unit, that would do nicely. I use their older, 24 MHz unit to captue 8 MHz SPI data and it worked quite well to capture a long burst of data to see what was occurring and to make speed measurements. Some 'scopes have add-on modules to act a Logic analyzer. The Saleae unit can breakdown different protocols. – CrossRoads Oct 25 '18 at 14:58