FlashStorage icon indicating copy to clipboard operation
FlashStorage copied to clipboard

Either Initilizing, Writing or Reading a String from Flash Storage bricks Seeeduino XIAO.

Open brdane opened this issue 1 year ago • 1 comments

I cannot quite pinpoint it to either one, but when a string is either initilized, written, or read from a XIAO's flash memory, the next time it is power cycled, there is essentially no communication to the PC it connects to. Not only this, but there is not even an attempt (no Windows 'device connected' sound effect that one normally gets.). The XIAO is bricked to the point to where jumping the reset pins does not even trigger a reset, so that makes me think the processor itself is bricked and can't even initilize/boot anymore.

I used a byte for FlashStorage as well, but I followed plenty of public examples to ensure I did the right steps to utilize it.

Initialization code used (along with some other variables used):

String deviceName = "DAP - 16 Knob Controller";

FlashStorage(d_name, String);
FlashStorage(writeflag, byte);

Reading Code Used:

inline void FetchDeviceName()
{
      char charBoi[32];

      byte nb = writeflag.read();

      if (nb != 69)
        return;


      deviceName = d_name.read();
        
}

Writing Code Used:

inline void WriteDeviceName(String newName)
{
  if (newName == "")
  return;

  d_name.write(newName);
}

Normally, I would do process of elimination and test each of the three functions seperately, but I do not want to risk keep bricking XIAO's.

brdane avatar Jan 09 '24 14:01 brdane

I took a risk with another XIAO, and tried some modified code. Instead of trying to store a string, I stored a struct that simply had a 32-char array... like so:

struct name
{
char actual_name[32];
};

FlashStorage(deviceName, name);

I write and read as normal using the existing read() and write() functions... works like a charm! I can write stuff, power cycle the XIAO, and read what I wrote upon powering it back on! I hope this post helps more people.

brdane avatar Jan 11 '24 02:01 brdane