littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
5.12k stars 790 forks source link

Read and write data issue. #922

Open TriTerraIT opened 8 months ago

TriTerraIT commented 8 months ago

I am using LittleFS in esp32 module. I have to write some uint32_t data into the file. I have write 266 and 522 (both in uint32_t) into the file. However, it become 10 when I read them again. 266mod256 and 522mod256 equal 10. However, I don't know why this issue happen. The other number from 10-600 is completely fine. Is someone have this experience before? Thank you

I have write a number into the LittleFS file but it change after I read it. This issue can be reproduced everytime.

M-Bab commented 3 months ago

Can you send a code snippet where you do the fwrite command writing the numbers?

geky commented 1 week ago

Sounds like you might be calling write with size=1, when you should use size=sizeof(uint32_t).

But seconding @M-Bab, it's hard to know without the actual code.