SAMD21 (MKR Zero) SPI and SD library

Hi All I'm having difficulty using the Arduino SD library with the SAMD21 based MKR Zero clone. The SAMD21 devices include two SPI interfaces, PA16, PA17 and PA19 (sercom1) or PA12, PA13 and PA15 (sercom4). Normally when using SPI the first SPI interface (PA16, 17 and 19) becomes active. However for unknown reasons the SD library uses the second interface on PA12, 13 and 14 for its SPI communication. Well, maybe it's not an unknown reason why they've done this as the standard MKR Zero board does have the SD card on PA12, 13 and 14. But my version does not.

I've worked through the SD library as far as I can and confirm that I it is using hardware SPI with call

SDCARD_SPI.begin();

The code up to this point within SD seems relatively straightforward and I don't notice anything that would be changing the SERCOM. Ideally I'd like to override whatever portion of the SD library is using sercom4 to put it back to sercom1. Perhaps it's in the Sd2PinMap.h file?

Stephen

Adafruit has a Tutorial on configuring the SAMD21 Sercom ports. It might be helpful.

Where did you get the MKR Zero clone? I’ve been quite surprised to not see any action on the MKR line from the clone/derivative/shield manufacturers.

The clones are made by me, The SAMD21 is a great MCU for imbedded systems, 32 bit with USB built in and easy boot loader programming thanks to Adafruit https://learn.adafruit.com/programming-an-m0-using-an-arduino/overview

I haven't needed to use SD cards in many applications, but a recent one involved me placing the SD card on the "wrong" SPI interface, as described above, so it's presently unusable. Both SPI interfaces work, but I can't make the SD library work with sercom4

I've worked through the link provided to configure the Sercom ports but am not smart enough to find the corresponding code in the SD library :/

Ah, that makes sense. Thanks! Also good to know that Adafruit_DAP library works for you. I gave it a try a while back and couldn't get it to work, so I moved on to a different programmer for my SAMD boards, but I think being able to convert an Arduino board into a programmer is the ideal solution for the average Arduino user.