From c5c4c5166786553958d3bfd4973bbee75cb38657 Mon Sep 17 00:00:00 2001 From: David Kuder Date: Fri, 14 Oct 2022 22:40:33 -0400 Subject: [PATCH] preAllocate fail preAllocate has angered the TrackZero and must be punished, out with preAllocate, in with writing zeros 512 bytes at a time. --- src/cmd.ino | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cmd.ino b/src/cmd.ino index 9bb75e6..ffa60fd 100755 --- a/src/cmd.ino +++ b/src/cmd.ino @@ -1196,6 +1196,7 @@ void makeimagecmd(int argc, char **argv) { Serial.printf(": Unable to open '%s'.\r\n", tmp_path); } else { // Take advantage of our cylinders being 1MB +#if 0 if(!file.preAllocate(fileSize)) { file.close(); sd.remove(tmp_path+3); @@ -1206,10 +1207,25 @@ void makeimagecmd(int argc, char **argv) { Serial.printf(": Pre-allocate failed, SD Card must be formatted as ExFat.\r\n"); return; } +#endif if(!strcmp(argv[2], "msdos")) { file.write(mbr_bin, 512); + fileSize -= 512; } + + memset(zero, 0, 512); + + while(fileSize) { + if((fileSize & 0x7FFF) == 0) + Serial.printf("."); + if((fileSize & 0x3FFFFF) == 0) + Serial.printf("\r\n"); + file.write(zero, 512); + fileSize -= 512; + } + Serial.printf("\r\n"); + file.close(); return;