joltwallet / esp_littlefs

LittleFS port for ESP-IDF
MIT License
259 stars 97 forks source link

Uart data corruption issue while write data using littlefs #131

Open Kuldeep-Chandel opened 1 year ago

Kuldeep-Chandel commented 1 year ago

ESP IDF Version: 4.4.4 Littlefs Version: "1.3.1" description: LittleFS is a small fail-safe filesystem for micro-controllers. url: https://github.com/joltwallet/esp_littlefs dependencies: idf: ">=4.1"

I'm using an ESP32S3 soc chip and on UART_NUM_1 receiving NMEA data and facing some issues.

I have two scenarios,

  1. While not using Littlefs

       I'm receiving NMEA data on uart and dumping the data then I'm not facing any checksum failed issues.
  2. While Using LittleFS

    I'm receiving NMEA data on uart, decoding the NMEA string, and saving the parameter into littlefs then I'm facing checksum failed issue.

As per my observation, maybe littlefs affect the global ISR of UART, and uart misses the string causing the checksum to fail.

Any ideas or suggestions to reduce this issue?

BrianPugh commented 1 year ago

Thanks for the report! Can you confirm this clarifications on your scenarios?

  1. Receiving NMEA on uart and storing it in RAM. After all data is received, I compute a checksum.

  2. Receiving NMEA on uart, and write it to a littlefs file. Upon reading the data back and computing a checksum, it is incorrect.

Can you also provide a minimal working example? I'm assuming the data doesn't have to be NMEA and could be anything. While I haven't done it recently, I've previously received binary data over UART and wrote the results using esp_littlefs without issue.

Particularly, are you sure you are flushing and closing the file prior to reading back the contents?

Kuldeep-Chandel commented 1 year ago

Thanks for your response.

1.Receiving NMEA on uart and storing it in RAM. After all, data is received, I compute a checksum.

  Receiving Nmea on uart and storing it in RAM, I calculate the checksum after receiving one string.

2.Receiving NMEA on uart, and write it to a littlefs file. Upon reading the data back and computing a checksum, it is incorrect.

I'm using three threads in our code, In the First thread I'm receiving NMEA on uart, and in the other two threads, I'm writing dummy data on Littlefs. In the scenario I'm facing an NMEA checksum failed issue.

If I'm commenting the Writing section of littlefs. As a result it checksum failed of the received nmea string gets stopped.

I have attached my source code for your reference. nmea0183_parser.zip

BrianPugh commented 11 months ago

@Kuldeep-Chandel I know this issue is quite old, but this sounds tangentially related to #161 . Does the solution mentioned there help fix the issues you were seeing?