Hi. I make two partitions for an sd card (16 GB sd to two of 8 GB). I just can READ and WRITE on partition 1. How can I READ/WRITE on partition 2?
this code:
//#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(3)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
//////////////////////////////////////////////////////////
This is the Serial output of my sd card partitions and info: (sdfat-Adafruit Fork -> sdinfo)
///////////////////////////////////////////////////////////
Card type: SDHC
sdSpecVer: 5.00
HighSpeedMode: false
Manufacturer ID: 0X3
OEM ID: SD
Product: SC16G
Revision: 8.0
Serial number: 0X2D0F10FC
Manufacturing date: 11/2017
cardSize: 15931.54 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
dataAfterErase: zeros
OCR: 0XC0FF8000
SD Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0X20,0X21,0X0,0XC,0XFE,0XE9,0X95,2048,14745600
2,0X0,0XFE,0XEA,0X95,0XC,0XFE,0XFF,0XFF,14747648,16365568
3,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
4,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
Scanning FAT, please wait.
Volume is FAT32
sectorsPerCluster: 8
fatStartSector: 6078
dataStartSector: 34816
clusterCount: 1839104
freeClusterCount: 1839099