MabezDev / embedded-fatfs

34 stars 10 forks source link

rp2040 example outdated #40

Open DASPRiD opened 1 month ago

DASPRiD commented 1 month ago

I was trying to work from the rp2040 example, but it seems to be outdated. I tried to adjust it to make it work and adjusted the pins to my board layout, see my diff:

diff.txt

I have a fat32 formatted SD card in the reader (done via gparted). When trying to run the example, I get the following error:

❯ cargo run
    Finished `dev` profile [optimized + debuginfo] target(s) in 0.07s
     Running `probe-rs run --chip RP2040 target/thumbv6m-none-eabi/debug/embedded-fatfs-example`
      Erasing ✔ [00:00:00] [###########################################################################################################################] 88.00 KiB/88.00 KiB @ 93.02 KiB/s (eta 0s )
  Programming ✔ [00:00:01] [###########################################################################################################################] 88.00 KiB/88.00 KiB @ 46.90 KiB/s (eta 0s )    Finished in 2.856s
INFO  Hello World!
└─ embedded_fatfs_example::____embassy_main_task::{async_fn#0} @ src/main.rs:27  
DEBUG Found card with size: 7948206080bytes
└─ sdspi::{impl#1}::init::{async_fn#0}::{async_block#0} @ /home/dasprid/dev/embedded-fatfs/sdspi/src/fmt.rs:125 
INFO  Initialization complete!
└─ embedded_fatfs_example::____embassy_main_task::{async_fn#0} @ src/main.rs:72  
WARN  Unknown opcode fa in bootjmp boot sector field
└─ embedded_fatfs::boot_sector::{impl#1}::validate @ /home/dasprid/dev/embedded-fatfs/embedded-fatfs/src/fmt.rs:151 
ERROR invalid bytes_per_sector value in BPB: expected a power of two but got 36352
└─ embedded_fatfs::boot_sector::{impl#0}::validate_bytes_per_sector @ /home/dasprid/dev/embedded-fatfs/embedded-fatfs/src/fmt.rs:164 
ERROR panicked at src/main.rs:105:6:
Filesystem tests failed!: CorruptedFileSystem
└─ panic_probe::print_defmt::print @ /home/dasprid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/panic-probe-0.3.2/src/lib.rs:104
CBJamo commented 1 month ago

Sorry about that, I forgot to update the example in #30, They'll be fixed soon.

DASPRiD commented 1 month ago

Thanks. Looking at examples/rp2040/src/main.rs, it doesn't seem that you changed anything I didn't change in my diff. Is the error message I see not related to this then?

CBJamo commented 1 month ago

That is correct, that pr only fixes the compile errors in the examples.

The CorruptedFileSystem error you're seeing is probably unrelated. Can you try flashing the sd card with this known-good fat32 image?

DASPRiD commented 1 month ago

I assume I can just dd that onto the /dev/sdX1 device?

DASPRiD commented 1 month ago

Confirmed, that worked. Now the question is why it doesn't work when formatted via gparted…

DASPRiD commented 1 month ago

Okay, figured it out, gonna open a new issue.