简体   繁体   中英

SD Card Reader issues with mbed OS 5/6

My coworker and I are having a rough time trying to get a Sparkfun SD card breakout board to function.

We got the SDBlockDevice example code to 'function', but upon runtime it would ruin the FAT32 filesystem of the sd card used? If the card was put back into Windows, it would require a reformat to use, and shows up in fdisk as 'RAW'.

We also tried using SDFileSystem, although it is deprecated. When using SDFileSystem library: Warning: L3912W: Option 'legacyalign' is deprecated.

在运行时我得到这个错误

See: https://armmbed.github.io/mbedos-error/?error=0x80FF0100&tgt=DISCO_L475VG_IOT01A

When I import the example file for SDFileSystem_HelloWorld I get the error "Error: Target "DISCO_L475VG_IOT01A" is not recognized". I believe this may bebecause of the code being intended for mbed OS 2.

We are using the DISCO L475VG IOT01A board.

If we are to continue with SDBlockDevice, is there a way to configure how it addresses formatting of the SD card? Also, is this mbed_app.json configuration correct:

    {
    "target_overrides": {
        "*": {
                "target.components_add" : ["SD"],
                "target.features_add": ["STORAGE"],
                "sd.SPI_MOSI" : "PA_7",
                "sd.SPI_MISO" : "PA_6",
                "sd.SPI_CLK"  : "PA_5",
                "sd.SPI_CS"   : "PA_15"
    }
  }
}

SDBlockDevice is not a filesystem. It is a block device driver used to allow a higher layer filesystem in the software stack to access an SD/MMC card.

The example code at SDBlockDevice only demonstrates the block-device API that must be used by a file system. It does so by writing an ASCII string to what would be the boot-sector on a FAT formatted SD card. Consequently it corrupts the formatting of such a card.

The point is that you do not use the SDBlockDevice to access teh SD card (unless you are implementing your own file system). Rather, you include the Mbed FATFileSystem component in your build and use the POSIX and standard library file I/O APIs to mount and access the file system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM