简体   繁体   English

mbed OS 5/6 的 SD 卡读卡器问题

[英]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.我和我的同事在尝试将Sparkfun SD 卡分线板连接到 function 时遇到了困难。

We got the SDBlockDevice example code to 'function', but upon runtime it would ruin the FAT32 filesystem of the sd card used?我们让 SDBlockDevice 示例代码“运行”,但在运行时它会破坏所用 SD 卡的 FAT32 文件系统? If the card was put back into Windows, it would require a reformat to use, and shows up in fdisk as 'RAW'.如果该卡被放回 Windows,则需要重新格式化才能使用,并在 fdisk 中显示为“RAW”。

We also tried using SDFileSystem, although it is deprecated.我们还尝试使用 SDFileSystem,尽管它已被弃用。 When using SDFileSystem library: Warning: L3912W: Option 'legacyalign' is deprecated.使用 SDFileSystem 库时:警告:L3912W:不推荐使用“legacyalign”选项。

在运行时我得到这个错误

See: https://armmbed.github.io/mbedos-error/?error=0x80FF0100&tgt=DISCO_L475VG_IOT01A参见: 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".当我导入SDFileSystem_HelloWorld的示例文件时,出现错误“错误:无法识别目标“DISCO_L475VG_IOT01A””。 I believe this may bebecause of the code being intended for mbed OS 2.我相信这可能是因为代码是为 mbed OS 2 而设计的。

We are using the DISCO L475VG IOT01A board.我们使用的是 DISCO L475VG IOT01A 板。

If we are to continue with SDBlockDevice, is there a way to configure how it addresses formatting of the SD card?如果我们要继续使用 SDBlockDevice,有没有办法配置它如何处理 SD 卡的格式化? Also, is this mbed_app.json configuration correct:另外,这个 mbed_app.json 配置是否正确:

    {
    "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. SDBlockDevice不是文件系统。 It is a block device driver used to allow a higher layer filesystem in the software stack to access an SD/MMC card.它是一个块设备驱动程序,用于允许软件堆栈中的更高层文件系统访问 SD/MMC 卡。

The example code at SDBlockDevice only demonstrates the block-device API that must be used by a file system. SDBlockDevice中的示例代码仅演示了文件系统必须使用的块设备 API。 It does so by writing an ASCII string to what would be the boot-sector on a FAT formatted SD card.它通过将 ASCII 字符串写入 FAT 格式的 SD 卡上的引导扇区来实现。 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).关键是您不使用 SDBlockDevice 访问 SD 卡(除非您正在实现自己的文件系统)。 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.相反,您在构建中包含 Mbed FATFileSystem组件,并使用 POSIX 和标准库文件 I/O API 来挂载和访问文件系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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