arduino / arduino/ArduinoCore-mbed
RP2040 with SD error
- Dominant language
- C
- Stars
- 411
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
Hi I am trying to use a microSD with the RP2040, but when executing the following example I get the blinking pattern means that the RTOS has crashed
```
Checking the SD Card SUCCESS!
SD size: 3904897024
SD read size: 512
SD program size: 512
SD erase size: 512
Mounting...
```
```
#define SD_MISO (digitalPinToPinName(PIN_SPI_MISO))
#define SD_MOSI (digitalPinToPinName(PIN_SPI_MOSI))
#define SD_CLK (digitalPinToPinName(PIN_SPI_SCK))
#define SD_CS (digitalPinToPinName(PIN_SPI_SS))
#include
#include "COMPONENT_SD/include/SD/SDBlockDevice.h"
#include
using namespace mbed;
using namespace events;
using namespace rtos;
using namespace std::chrono_literals;
//#include "COMPONENT_SPI/include/SPI/SPIFBlockDevice.h"
void setup() {
Serial.begin(9600);
Serial.print("Example SD Card");
while(!Serial);
SDBlockDevice bd(SD_MOSI, SD_MISO, SD_CLK, SD_CS);
FATFileSystem fat("fat");
Serial.print("Checking the SD Card");
int err = bd.init();
if (err != 0) {
Serial.print(" FAIL!");
Serial.print("Please, check your SD Card.");
while(true);
}
Serial.println(" SUCCESS!");
Serial.print("SD size: ");
Serial.println(bd.size());
Serial.print("SD read size: ");
Serial.println(bd.get_read_size());
Serial.print("SD program size: ");
Serial.println(bd.get_program_size());
Serial.print("SD erase size: ");
Serial.println(bd.get_erase_size());
Serial.print("Mounting... ");
err = fat.mount(&bd);
Serial.println(err ? "Fail :(" : "OK");
if (err) {
//Error();
// Format and remount
Serial.println("No filesystem found, formatting...");
err = fat.reformat(&bd);
if (err) {
//Error();
while (1)
;
}
}
Serial.println("Hello, FAT!");
}
void loop() {
// put your main code here, to run repeatedly:
}
```
Thanks
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the inline RP2040 example in setup(), focusing on the transition from SDBlockDevice initialization to FATFileSystem::mount(). Read FATFileSystem.h and COMPONENT_SD/include/SD/SDBlockDevice.h, then compare the mounting result with the reported crash; done means identifying the cause and confirming the example mounts or reports the failure without the RTOS crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100