Skip to content

Conversation

@stephenhensley
Copy link
Collaborator

@stephenhensley stephenhensley commented May 16, 2025

Summary

This PR addresses an intermittent issue that can occur causing the QSPI Flash chip to get stuck in write-protect mode.

This issue has been most commonly identified by the following behavior:

  • Unexplainably long bootup time (approx 5s -- while the QSPI fails to initialize)
  • Program that crash close to startup, or whenever accessing persistent data via QSPI
  • Seemingly "bricked" Daisy when running from the bootloader

Solution

With this update to the QSPI Initialization, the Daisy will automatically recover from this issue, and prevent it from causing further problems after initializaiton.
The QSPI is now initialized with fewer pins while manually disabling the write-protect via pin-state during single-SPI initialization, and clearing the SWRD bit if it is set. Once this bit has been cleared, the QSPI is then re-initialized in 4-bit mode.

Testing and Validation

These changes were tested thoroughly by numerous individuals via the dsy_bootloader_v6_2-dev5.bin patched bootloader would auto-recover, and revive any daisies affected by the above issues.

That version of the bootloader was built on an older version of libDaisy, but syncing these changes with the latest libDaisy only involved migrating the changes to the newer Pin struct, and I have retested with a file that manually sets the SRWD bit to verify the fix on the latest version.

To validate this change one can test the following sequence:

  1. flash the attached, Blink_set_srwd.bin file -- the problem can immediately be noticed by the 5s startup time before the program starts blinking.
  2. build libDaisy on this branch, and compile the new QspiReadAndWrite example (bin file also included in the attached zip)
  3. Flash that program, and connect via serial monitor.

Once connected, this program will erase, write, and validate the first 4kB of the QSPI memory, and print out success messages.
If this example is built on previous versions of libDaisy, the program will take additional time to start up, and will stall indefinitely when attempting to erase the QSPI.

Warning: If any other programs are flashed after step 1 before step 3, the problems described above will occur on the Daisy. The Daisy is not bricked, and flashing any binary compiled with this branch of libDaisy will recover from those issues.

qspi-test-bins.zip

@github-actions
Copy link

github-actions bot commented May 16, 2025

Test Results

150 tests  ±0   150 ✅ ±0   0s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit fdb1986. ± Comparison against base commit f7c63ae.

♻️ This comment has been updated with latest results.

@stephenhensley stephenhensley merged commit 7a3095d into electro-smith:master May 19, 2025
13 checks passed
@stephenhensley stephenhensley deleted the qspi-clear-statusreg branch May 19, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant