Problem initializing Maixduino board SD card using SD.begin command

I’m stumped regarding why any of the SD example sketches (e.g. “ReadWrite”, “listfiles”, etc.) using the SD.begin command fail to initialize the SD card on a Maixduino board I just got. However, the example sketch “Cardinfo” initializes the SD card properly and displays all the right info (SD card type, size, FAT, and file name/ size/ date). “Cardinfo” does not use the SD.begin command, but uses commands from the SD library Utilities. Note I’ve tried 4 different SD cards and use the “SD Card Formatter” utility.

The test code below gives me a result of “init ok”.

#include <Arduino.h>
// include the SD library:
#include <SPI.h>
#include <SD.h>
// set up variables using the SD utility library functions:
//Sd2Card card; // use object SPI (use SPI1) by default,

  • // you can change it by:*
    SPIClass spi0(SPI0, 27, 26, 28, 29);
    Sd2Card card(spi0);
    SdVolume volume;
    SdFile root;

// pin 29 on Maix Go or Maix One Dock or Maix Bit
const int csPin = 29;

void setup() {

  • // Open serial communications and wait for port to open:*

  • Serial.begin(115200);*

  • while (!Serial) {*

  • ; // wait for serial port to connect. Needed for native USB port only*

  • }*

  • Serial.print(“Alternate Initializing SD card…”);*

  • // we’ll use the initialization code from the SD utility libraries*

  • if(root.isOpen()) root.close();*

  • if (!card.init(SPI_HALF_SPEED, csPin) &&*

  • volume.init(card) &&*

  • root.openRoot(volume)) {*

  • Serial.println(“init failed”);*

  • while (1);*

  • } else {*

  • Serial.println(“init ok”);*

  • }*
    }
    void loop() {

  • // nothing happens after setup finishes.*
    }

And the test code below using SD.begin gives me “initialization failed!”

#include <Arduino.h>
// include the SD library:
#include <SPI.h>
#include <SD.h>

// pin 29 on Maix Go or Maix One Dock or Maix Bit
const int csPin = 29;

void setup() {

  • // Open serial communications and wait for port to open:*
  • Serial.begin(115200);*
  • while (!Serial) {*
  • ; // wait for serial port to connect. Needed for native USB port only*
  • }*
    Serial.print(“Initializing SD card…”);
  • if (!SD.begin(csPin)) {*
  • Serial.println(“initialization failed!”);*
  • while (1);*
  • }*
  • Serial.println(“initialization done.”);*
    }
    void loop() {
  • // nothing happens after setup finishes.*
    }

Can anyone give me any clue why sketches using SD.begin won’t initialize the Maixduino SD card?

Thanks!

Problem was solved. The problem is that PlatformIO IDE pulls in the older 0.3.9 framework version - which has this problem. Had to modify it to pull in version 0.3.11 to get this to work.