Open diego76765 opened 4 years ago
I assume you mean that you have an LCD display connected and are seeing SD Root Error?
Yes i see meensage Sd Root Error in LCD display
Ok, I don't have any hardware I can test with at the moment so it will be a little while before I can check it. It is probably related to the changes I made for the latest SdFat version.
How version I have 1.1.4
Yes, that is the one I used as well.
It seems to me that it is not the correct one or the code is wrong because I had to correct it so that the screen appears
Yes, I think it is probably a bug I introduced when updating the Sio2Arduino code to support SdFat 1.1.4.
And how i do
You would either have to wait for me to fix it or try to debug it yourself.
I give you the code or not
No need to. It is in Github.
Yes it is the same
hello where contributions are made
hello I formatted it in fat 16 with a 2 gb micro sd and it remains the same I do not see that it is ready I get the same error
Code contributions can be made via a pull request on Github. Monetary contributions are not accepted since I'm not really actively maintaining the project anymore.
Thanks for the additional SD card info you provided.
Dont solved it thank you
Hi, I had the same problem, so I decided to fix "SD Root Error" and checked SdFat library v1.1.4 examples to find what is changed.
You have to change in the SIO2Arduino.ino Sd2Card card; to SdFat card;
Here is the working code:
`/*
/**
/**
SdFat card; SdFile currDir; SdFile file; // TODO: make this unnecessary const uint8_t chipSelect = SS;
DiskDrive drive1;
boolean isSwitchPressed = false; unsigned long lastSelectionPress; boolean isFileOpened=false;
unsigned long lastResetPress;
LiquidCrystal lcd(PIN_LCD_RD,PIN_LCD_ENABLE,PIN_LCD_DB4,PIN_LCD_DB5,PIN_LCD_DB6,PIN_LCD_DB7);
void setup() {
// set up logging serial port LOGGING_UART.begin(115200);
// initialize serial port to Atari SIO_UART.begin(19200);
// set pin modes
pinMode(PIN_SELECTOR, INPUT_PULLUP);
pinMode(PIN_RESET, INPUT_PULLUP);
// set up LCD if appropriate lcd.begin(16, 2); lcd.print(F("SIO2Arduino")); lcd.setCursor(0,1);
// initialize SD card LOG_MSG(F("Initializing SD card...")); pinMode(PIN_SD_CS, OUTPUT);
if (!card.begin(PIN_SD_CS, SD_SCK_MHZ(50))) { LOG_MSG_CR(F(" failed."));
lcd.print(F("SD Init Error"));
#endif
return;
}
if (!currDir.open("/")) { LOG_MSG_CR(F(" failed."));
lcd.print(F("SD Root Error"));
#endif
return;
}
LOG_MSG_CR(F(" done."));
lcd.print(F("READY"));
delay(3000);
mountFilename(0, "AUTORUN.ATR"); }
void loop() { // let the SIO channel do its thing sioChannel.runCycle();
// watch the selector button (accounting for debounce) if (digitalRead(PIN_SELECTOR) == LOW && millis() - lastSelectionPress > 250 && isSwitchPressed==false) { lastSelectionPress = millis(); changeDisk(0); } else isSwitchPressed=(digitalRead(PIN_SELECTOR) == LOW);
// watch the reset button if (digitalRead(PIN_RESET) == LOW && millis() - lastResetPress > 250) { lastResetPress = millis(); mountFilename(0, "AUTORUN.ATR"); }
if (SIO_UART.available())
SIO_CALLBACK();
}
void SIO_CALLBACK() { // inform the SIO channel that an incoming byte is available sioChannel.processIncomingByte(); }
DriveStatus* getDeviceStatus(int deviceId) { return drive1.getStatus(); }
SectorDataInfo readSector(int deviceId, unsigned long sector, byte data) { if (drive1.hasImage()) { return drive1.getSectorData(sector, data); } else { return NULL; } }
boolean writeSector(int deviceId, unsigned long sector, byte* data, unsigned long length) { return (drive1.writeSectorData(sector, data, length) == length); }
boolean format(int deviceId, int density) { char name[13];
// get current filename file.getName(name, 13);
// close and delete the current file file.close(); file.remove();
LOG_MSG(F("Remove old file: ")); LOG_MSG_CR(name);
// open new file for writing file.open(&currDir, name, O_RDWR | O_SYNC | O_CREAT);
LOG_MSG(F("Created new file: ")); LOG_MSG_CR(name);
// allow the virtual drive to format the image (and possibly alter its size)
if (drive1.formatImage(&file, density)) {
// set the new image file for the drive
drive1.setImageFile(&file);
return true;
} else {
return false;
}
}
void changeDisk(int deviceId) { dir_t dir; char name[13]; boolean imageChanged = false;
while (!imageChanged) { // get next dir entry int8_t result = currDir.readDir((dir_t*)&dir);
// if we got back a 0, rewind the directory and get the first dir entry
if (!result) {
currDir.rewind();
result = currDir.readDir((dir_t*)&dir);
}
// if we have a valid file response code, open it
if (result > 0 && isValidFilename((char*)&dir.name)) {
createFilename(name, (char*)dir.name);
imageChanged = mountFilename(deviceId, name);
}
} }
boolean isValidFilename(char *s) { return ( s[0] != '.' && // ignore hidden files s[0] != '_' && ( // ignore bogus files created by OS X (s[8] == 'A' && s[9] == 'T' && s[10] == 'R') || (s[8] == 'X' && s[9] == 'F' && s[10] == 'D')
|| (s[8] == 'P' && s[9] == 'R' && s[10] == 'O')
|| (s[8] == 'A' && s[9] == 'T' && s[10] == 'X')
|| (s[8] == 'X' && s[9] == 'E' && s[10] == 'X')
)
);
}
void createFilename(char filename, char name) { for (int i=0; i < 8; i++) { if (name[i] != ' ') { (filename++) = name[i]; } } if (name[8] != ' ') { (filename++) = '.'; (filename++) = name[8]; (filename++) = name[9]; (filename++) = name[10]; } (filename++) = '\0'; }
/**
entries = a pointer to the a FileEntry array to hold the returned data / int getFileList(int startIndex, int count, FileEntry entries) { dir_t dir; int currentEntry = 0;
currDir.rewind();
int ix = 0; while (ix < count) { if (currDir.readDir((dir_t)&dir) < 1) { break; } if (isValidFilename((char)&dir.name) || (DIR_IS_SUBDIR(&dir) && dir.name[0] != '.')) { if (currentEntry >= startIndex) { memcpy(entries[ix].name, dir.name, 11); if (DIR_IS_SUBDIR(&dir)) { entries[ix].isDirectory = true; } else { entries[ix].isDirectory = false; } ix++; } currentEntry++; } }
return ix; }
/**
ix = index number (or -1 to go to parent directory) */ void changeDirectory(int ix) { FileEntry entries[1]; char name[13]; SdFile subDir;
if (ix > -1) {
getFileList(ix, 1, entries);
createFilename(name, entries[0].name);
if (subDir.open(&currDir, name, O_READ)) {
currDir = subDir;
}
} else {
if (subDir.open("/")) {
currDir = subDir;
}
}
}
/**
ix = the index of the file to mount */ void mountFileIndex(int deviceId, int ix) { FileEntry entries[1]; char name[13];
// figure out what filename is associated with the index getFileList(ix, 1, entries);
// build a full 8.3 filename createFilename(name, entries[0].name);
// mount the image mountFilename(deviceId, name); }
/**
name = the name of the file to mount / boolean mountFilename(int deviceId, char name) { // close previously open file if (file.isOpen()) { file.close(); }
if (file.open(&currDir, name, O_RDWR | O_SYNC) && drive1.setImageFile(&file)) { LOG_MSG_CR(name);
lcd.clear(); lcd.print(name); lcd.setCursor(0,1);
return true; }
return false; }`
Hello I make de Sio2 root error but i have instalded autorun.atr how is the problem thank you