Closed jolivepetrus closed 2 years ago
Thanks for pointing this out!
I have looked through the source briefly. It seems __smakebuf_r
is the place where HAVE_BLKSIZE
affects fgetc
. The problem is that quite a few newlib functions which are in ESP32 ROM call into __smakebuf_r
. So if we recompile newlib, we would have to put these functions into IRAM or flash. This is certainly possible, but we need to evaluate the impact.
As a temporary workaround I can suggest using setvbuf
to turn off buffering.
Thanks for your feedback. Tested your suggestion and works fine without recompile newlib.
Sorry that we haven't updated this issue in time. newlib is compiled with HAVE_BLKSIZE flag since esp-2019r1 release of the toolchain, which corresponds to ESP-IDF v4.0 or later. https://github.com/espressif/newlib-esp32/blob/af7e0ec39b5c3e8b7bf383f734b517911efddd98/newlib/configure.host#L935
We have detect that fgetc, in current newlib-esp32, don't take in consideration the st_blksize member of the stat struct. In an hypothetical implementation of a virtual file system with a block size of 1 byte, this function will don't return after BUFSIZ bytes are readed.