gpb01
May 13, 2021, 7:53pm
1
On my MKR Zero, I would like to be able to use an external SD card reader connected to the SPI bus but ... it seems that the SD library does not allow me to not use the native SD (which is on a dedicated SPI bus ).
Is there any parameter, or a simple detour, to be able to tell the library NOT to use the native SD and to use the standard SPI bus (and the CS pin supplied ) for the external SD?
Thank you in advance
Guglielmo
Juraj
May 13, 2021, 8:03pm
2
mkrzero
SD library
*/
#ifndef SDCARD_SS_PIN
/** The default chip select pin for the SD card is SS. */
uint8_t const SD_CHIP_SELECT_PIN = SS;
#else
uint8_t const SD_CHIP_SELECT_PIN = SDCARD_SS_PIN;
#endif
// The following three pins must not be redefined for hardware SPI,
// so ensure that they are taken from pins_arduino.h or variant.h, depending on architecture.
#ifndef SDCARD_MOSI_PIN
/** SPI Master Out Slave In pin */
uint8_t const SPI_MOSI_PIN = MOSI;
/** SPI Master In Slave Out pin */
uint8_t const SPI_MISO_PIN = MISO;
/** SPI Clock pin */
uint8_t const SPI_SCK_PIN = SCK;
#else
uint8_t const SPI_MOSI_PIN = SDCARD_MOSI_PIN;
uint8_t const SPI_MISO_PIN = SDCARD_MISO_PIN;
uint8_t const SPI_SCK_PIN = SDCARD_SCK_PIN;
I would define my own SAMD variant in my_boards to suppress the on-board SD
Arduino IDE and Arduino builder support custom board definitions from [hardware subfolder](https://arduino.github.io/arduino-cli/platform-specification/) of your sketches folder. These definitions can use core classes and tools from installed board packages.
This GitHub repository contains my settings for boards I use for my project and to develop Arduino libraries. You can use it as starting point for your boards specialties.

All boards in this repo are only additions to installed 'official' board packages. My files contain only definition of the board in boards.txt, the folder in variants and platform.txt file contains only additional entries. The file programmers.txt contains sample definitions of 'programmer' entries for OTA upload without the IDE detecting the network port.
## Boards
### AVR architecture
Boards defined here use build of [Optiboot bootloader with `copy_flash_pages` function](https://github.com/Optiboot/optiboot/pull/269) (for ArduinoOTA library). platform.txt contains entries for sketch upload over network to ArduinoOTA library. All boards refer official Arduino AVR core and tools.
The official Arduino Mega doesn't use Optiboot bootloader. It has a 4 kB bootloader. The board definition here is changed to respect 1 kB Optiboot bootloader. The AVR package can use arduino:mega as variant reference to official package, so the variants folder doesn't need to be copied here.
I have [a small series ATmega1284p board](https://github.com/budvar10/Arduino-ATmega1284P) by budvar10. It has perfect Uno pins compatibility. The pin mapping in variants is copied from budvar10's repo.
### SAMD architecture
This file has been truncated. show original
1 Like
gpb01
May 13, 2021, 8:06pm
3
Very elegant solution, thank you very much!
Guglielmo
1 Like
If the reason for not using onboard card reader is because you need to move it away from the board, you can buy card reader extension, that plugs into the card slot and has female connector on the other end
gpb01
May 23, 2021, 5:34am
5
True, good idea , but ... at the moment I solved it by simply creating a new "board " with a new "variant "
In any case, thank you very much for the tip!
Guglielmo
system
Closed
September 20, 2021, 5:34am
6
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.