Bug SD size() returns random value until file has non-zero bytes of content

frankcohen
Posts: 25
Joined: Mon Apr 05, 2021 4:03 am

Bug SD size() returns random value until file has non-zero bytes of content

Postby frankcohen » Mon Sep 11, 2023 5:48 pm

I'm using an external SD/NAND with an ESP32-S3 to create and save log values to a file. NAND is a surface mount version of an SD card. I connect the NAND over SPI using pin 15 for the CS. This is part of my Reflections open-source project https://github.com/frankcohen/ReflectionsOS.

File mylog = SD.open( "/log1", FILE_WRITE );
if( !mylog )
{
Serial.print( F( "Unable to create log file " ) );
}
Serial.print( "mylog.size() = " );
Serial.println( (long) mylog.size() );

I see random size values in the Serial monitor. For example mylog.size = 1070537564. When I write the the file first, then the size values return correctly.

File mylog = SD.open( "/log1", FILE_WRITE );
if( !mylog )
{
Serial.print( F( "Unable to create log file " ) );
}
int logval2 = mylog.print( "Starting log" );
Serial.print( "mylog.size() = " );
Serial.println( (long) mylog.size() );

size returns 14, which is correct.

What's the process to open a bug report?

-Frank



Who is online

Users browsing this forum: No registered users and 25 guests