whizzosoftware / SIO2Arduino

An Atari 8-bit device emulator for Arduino hardware
http://www.whizzosoftware.com/sio2arduino
Other
52 stars 38 forks source link

Sio2 Atari root error #13

Open diego76765 opened 4 years ago

diego76765 commented 4 years ago

Hello I make de Sio2 root error but i have instalded autorun.atr how is the problem thank you

whizzosoftware commented 4 years ago

I assume you mean that you have an LCD display connected and are seeing SD Root Error?

diego76765 commented 4 years ago

Yes i see meensage Sd Root Error in LCD display

whizzosoftware commented 4 years ago

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.

diego76765 commented 4 years ago

How version I have 1.1.4

whizzosoftware commented 4 years ago

Yes, that is the one I used as well.

diego76765 commented 4 years ago

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

whizzosoftware commented 4 years ago

Yes, I think it is probably a bug I introduced when updating the Sio2Arduino code to support SdFat 1.1.4.

diego76765 commented 4 years ago

And how i do

whizzosoftware commented 4 years ago

You would either have to wait for me to fix it or try to debug it yourself.

diego76765 commented 4 years ago

I give you the code or not

whizzosoftware commented 4 years ago

No need to. It is in Github.

diego76765 commented 4 years ago

Yes it is the same

diego76765 commented 4 years ago

hello where contributions are made

diego76765 commented 4 years ago

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

whizzosoftware commented 4 years ago

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.

diego76765 commented 4 years ago

Dont solved it thank you

voipsun commented 3 years ago

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;

ifdef SELECTOR_BUTTON

boolean isSwitchPressed = false; unsigned long lastSelectionPress; boolean isFileOpened=false;

endif

ifdef RESET_BUTTON

unsigned long lastResetPress;

endif

ifdef LCD_DISPLAY

LiquidCrystal lcd(PIN_LCD_RD,PIN_LCD_ENABLE,PIN_LCD_DB4,PIN_LCD_DB5,PIN_LCD_DB6,PIN_LCD_DB7);

endif

void setup() {

ifdef DEBUG

// set up logging serial port LOGGING_UART.begin(115200);

endif

// initialize serial port to Atari SIO_UART.begin(19200);

// set pin modes

ifdef SELECTOR_BUTTON

pinMode(PIN_SELECTOR, INPUT_PULLUP);

endif

ifdef RESET_BUTTON

pinMode(PIN_RESET, INPUT_PULLUP);

endif

ifdef LCD_DISPLAY

// set up LCD if appropriate lcd.begin(16, 2); lcd.print(F("SIO2Arduino")); lcd.setCursor(0,1);

endif

// 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."));

ifdef LCD_DISPLAY

  lcd.print(F("SD Init Error"));
#endif     
return;

}

if (!currDir.open("/")) { LOG_MSG_CR(F(" failed."));

ifdef LCD_DISPLAY

  lcd.print(F("SD Root Error"));
#endif     
return;

}

LOG_MSG_CR(F(" done."));

ifdef LCD_DISPLAY

lcd.print(F("READY"));
delay(3000);

endif

mountFilename(0, "AUTORUN.ATR"); }

void loop() { // let the SIO channel do its thing sioChannel.runCycle();

ifdef SELECTOR_BUTTON

// 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);

endif

ifdef RESET_BUTTON

// watch the reset button if (digitalRead(PIN_RESET) == LOW && millis() - lastResetPress > 250) { lastResetPress = millis(); mountFilename(0, "AUTORUN.ATR"); }

endif

ifdef ARDUINO_TEENSY

if (SIO_UART.available())
  SIO_CALLBACK();

endif

}

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')

ifdef PRO_IMAGES

      || (s[8] == 'P' && s[9] == 'R' && s[10] == 'O')

endif

ifdef ATX_IMAGES

      || (s[8] == 'A' && s[9] == 'T' && s[10] == 'X')

endif

ifdef XEX_IMAGES

      || (s[8] == 'X' && s[9] == 'E' && s[10] == 'X')

endif

      )
    );

}

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'; }

/**

/**

/**

/**