geoffwilliams@home:~$

ESP32 SD Card strangeness

This is a new one:

ESP32 with a vfat SD card. Everything working fine. Take SD card out, copy .json config file over top of existing file on PC, SD card back in ESP32, power on and WIFI no longer connecting/soft lockup.

Running fskc on SD card gives no errors.

Luckily my program is configured to print out the config file on startup for debugging purposes. On a serial console, I see most of the config file being printed out, however, the end of the file is replaced by a continuous stream of smiley face (☺/0x01) characters:

"lomq32/devices/makerfabs/malo4mos/121": { "name": "tv pumps", "descript☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺

After some digging, it turns out on ESP32, the FAT implementation can sometimes read the old/wrong clusters when you copy files over the top of existing ones - and the strange characters I was seeing were basically an overflow/underflow when reading from the card.

The fix?

On PC:

  1. Delete config file from SD card
  2. Copy the (identical) file from the PC to the SD card again
  3. Unmount SD card, insert into ESP32, power on

The System booted normally and joined WIFI after this.

Strange huh?

Post comment

Markdown is allowed, HTML is not. All comments are moderated.