Zephyr sdmmc_spi.c driver is very disappointing, is there an alternative choice?

Hello,

I told my students to set up an SPI bus with several peripherals. We found nice development boards with a screen and a card reader sharing MISO,MOSI,CLK and one CS for each peripheral and drivers for both the screen and the SD cards in Zephyr. That sounded nice ...  but the disappointment was big:

It turns out that the SDMMC_SPI driver of Zephyr does not work according to spec on a bus shared with other peripherals:

(1) It keeps CS low, but does not keep the lock semaphore between transfers. So the first consequence is that there are concurrent accesses to the bus (that may actually equal short circuits on MISO, so this is not a harmless bug).

(2) So I tried to add an SPI_LOCK_ON option to the configuration so that the driver keeps the lock during his multi transfer transactions. It seems the right direction, but there seem to be deadlocks now. I still think that this is the best direction for repairing this driver.

(3) It uses a lot of single byte transfers in order to synchronize with the card. With the easydma architecture, this is of course highly inefficient, since there is one Zephyr interrupt for each byte transmitted and you see 60us pauses between two bytes, independent of the transmission speed.

So I wonder, does anyone know open source code for SDMMC that might be better suited for porting to Zephyr than actually repairing sdmmc_spi.c Is there an implementation in nRFSDK5 that is a good candidate?

Regards,

Peter Niebert

Related