Search found 3 matches
- Tue Sep 12, 2023 9:12 pm
- Forum: ESP-IDF
- Topic: ESP32 crashes when reading bytes from file on FAT partition using fgetc
- Replies: 4
- Views: 1939
Re: ESP32 crashes when reading bytes from file on FAT partition using fgetc
I found the problem: it was an overflow in the char buffer that received the bytes from the file, the buffer was smaller than the file size. I found the backtrace was a bit misleading though...
- Tue Sep 12, 2023 2:15 pm
- Forum: ESP-IDF
- Topic: ESP32 crashes when reading bytes from file on FAT partition using fgetc
- Replies: 4
- Views: 1939
Re: ESP32 crashes when reading bytes from file on FAT partition using fgetc
fgetc(...) returns an int , with EOF being a valid int but not a valid uint8_t value. Because uint_fast8_t c, c != EOF will not be true or false in the way your code expects it to be. I've tried using int c instead of uint_fast8_t but the problem remains (with the same back-trace). I've also tested...
- Mon Sep 11, 2023 8:19 pm
- Forum: ESP-IDF
- Topic: ESP32 crashes when reading bytes from file on FAT partition using fgetc
- Replies: 4
- Views: 1939
ESP32 crashes when reading bytes from file on FAT partition using fgetc
I built a FAT partition inside the ESP32 flash using the "wear-leveling" example. I created a custom partition csv file as well as modified the CMakeLists.txt file to create the image. The problem seems to be the usage of the fgetc function when reading bytes from the files. Here's the relevant code...