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

发布于 2025-01-16 22:10:35 字数 1370 浏览 5 评论 0原文

我和我的同事在尝试让 Sparkfun SD 卡分线板正常运行时遇到了困难。

我们得到了 SDBlockDevice 示例代码来“运行”,但是在运行时它会破坏所使用的 sd 卡的 FAT32 文件系统?如果将卡放回 Windows,则需要重新格式化才能使用,并在 fdisk 中显示为“RAW”。

我们还尝试使用 SDFileSystem,尽管它已被弃用。 使用 SDFileSystem 库时: 警告:L3912W:选项“legacyalign”已弃用。

运行时-time 我收到此错误

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

当我导入SDFileSystem_HelloWorld 的示例文件我收到错误“错误:目标“DISCO_L475VG_IOT01A”不被认可”。我相信这可能是因为代码适用于 mbed OS 2。

我们使用的是 DISCO L475VG IOT01A 板。

如果我们要继续使用 SDBlockDevice,是否有办法配置它如何处理 SD 卡的格式化?另外,此 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"
    }
  }
}

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.

At run-time I get this error

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"
    }
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧瑾黎汐 2025-01-23 22:10:35

SDBlockDevice 不是文件系统。它是一个块设备驱动程序,用于允许软件堆栈中的更高层文件系统访问 SD/MMC 卡。

SDBlockDevice 处的示例代码仅演示了文件系统必须使用的块设备 API。它通过将 ASCII 字符串写入 FAT 格式的 SD 卡上的引导扇区来实现此目的。因此,它会破坏此类卡的格式。

重点是您不使用 SDBlockDevice 来访问 SD 卡(除非您正在实现自己的文件系统)。相反,您应包含 Mbed FATFileSystem 组件在您的构建中,使用 POSIX 和标准库文件 I/O API 来挂载和访问文件系统。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文