littlefs2 icon indicating copy to clipboard operation
littlefs2 copied to clipboard

requires std?

Open gauteh opened this issue 3 years ago • 6 comments

Hi, just discovered this lib. Seems like something very useful for storing data on an sd card on a microcontroller. When I try to add this library to a no_std binary I get errors with memchr, does it require std with an allocator?

gauteh avatar Sep 25 '21 14:09 gauteh

   Compiling memchr v2.4.1
   Compiling generic-array v0.14.4
   Compiling regex v1.5.4
   Compiling delog v0.1.2
   Compiling serde_derive v1.0.130
   Compiling bare-metal v0.2.5
   Compiling cortex-m-rt v0.7.0
   Compiling cortex-m v0.7.3
error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7em-none-eabi` target may not support the standard library
  = note: `std` is required by `memchr` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `memchr` due to previous error
[package]
name = "sby-buoy"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
littlefs2 = "0.3.1"
panic-halt = "0.2.0"

gauteh avatar Sep 26 '21 06:09 gauteh

Hey, thanks for your interest. You don't need no_std (cf. https://docs.rs/memchr/2.4.1/memchr/#crate-features), we use this in https://github.com/solokeys/solo2/tree/main/runners/lpc55. I think if you link to https://github.com/solokeys/solo2/tree/main/components/c-stubs in your dependencies it might just work, if not let me know and I can try to reconstruct what exactly the dependencies are.

nickray avatar Sep 26 '21 14:09 nickray

I remembered... In this commit: https://github.com/nickray/littlefs2/commit/cdcb99fea7a53f59e582d0b3702c5bae432a8db3 I removed a workaround for fact that the bindgen build dependency (of littlefs2-sys) triggers the std feature of memchr. However, with a new cargo you can simply add a line resolver = "2" under [package] in your consuming crate.

The link to a c-stubs is necessary at build time, otherwise you'll get a linker error then.

I'll try and improve the docs on this.

nickray avatar Sep 26 '21 15:09 nickray

Thanks. I'll experiment a bit more when I get a bit further on the project

gauteh avatar Sep 29 '21 06:09 gauteh

I released 0.3.2: https://docs.rs/littlefs2/0.3.2/littlefs2/#no_std

nickray avatar Sep 29 '21 21:09 nickray

Great! That is a nice way to solve it.

On Wed, Sep 29, 2021 at 11:01 PM Nicolas Stalder @.***> wrote:

I release 0.3.2: https://docs.rs/littlefs2/0.3.2/littlefs2/#no_std

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nickray/littlefs2/issues/14#issuecomment-930539943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN365LSNBL5UMLFNBRIDDUEN5CNANCNFSM5EXUU4VA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

gauteh avatar Sep 30 '21 06:09 gauteh