Skip to content

WDT reset with SD card #1255

Closed
earlephilhower/ESP8266SdFat
#3
@svaygame

Description

@svaygame

When creating a new file , need a lot of time for search the FAT for free clusters.
If there are a large number of files in SD card, might lead WDT reset

Trigger WDT timeout at here:
https://github.com/esp8266/Arduino/blob/master/libraries/SD/src/utility/SdVolume.cpp : line 58

  // search the FAT for free clusters
  for (uint32_t n = 0;; n++, endCluster++) {
    // can't find space checked all clusters
    if (n >= clusterCount_) return false;
    /// if( n %1024 == 0)delay(0); // Add dealy for WDT

    // past end - start from beginning of FAT
    if (endCluster > fatEnd) {
      bgnCluster = endCluster = 2;
    }
    uint32_t f;
    if (!fatGet(endCluster, &f)) return false;

    if (f != 0) {
      // cluster in use try next cluster as bgnCluster
      bgnCluster = endCluster + 1;
    } else if ((endCluster - bgnCluster + 1) == count) {
      // done - found space
      /// Serial.printf("result:%d , %d\n" , n , bgnCluster); // result: 371012 , 371014
      break;
    }

  }

It found space at 371012 time.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions