espressif / newlib-esp32

Version of newlib used in ESP32 ROM and ESP-IDF
GNU General Public License v2.0
31 stars 18 forks source link

newlib should be compiled with HAVE_BLKSIZE flag #1

Closed jolivepetrus closed 2 years ago

jolivepetrus commented 7 years ago

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.

igrr commented 7 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.

jolivepetrus commented 7 years ago

Thanks for your feedback. Tested your suggestion and works fine without recompile newlib.

igrr commented 2 years ago

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