S25FL512S: erase fails with E_ERR on DYB-protected sectors, then WIP stays set
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 28/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- cpp
- Domain
- cli, embedded-iot
Research direction
Start in spiFlash.cpp, where the erase loop checks only the BP bits and never sends Clear Status (0x30) after an E_ERR or P_ERR timeout, and where --unprotect-flash clears BP bits only. Reproducing needs a Spansion S25FL-S chip with DYB-protected sectors, which most contributors won't have. Done means a DYB-protected erase fails with a clear message or clears the DYBs, and an E_ERR state is cleared rather than timing out on every later sector.
Written by the indexing model from the issue text.
Description
Summary
Writing a Spansion S25FL512S fails when its sectors are protected by their DYB bits (Advanced Sector Protection). The status register's BP bits are clear. openFPGALoader checks only the BP bits, so it goes ahead with the erase. The chip refuses every sector erase and sets E_ERR. openFPGALoader never sends Clear Status (0x30), so WIP stays set and every later wait times out.
Board and versions
- MEGA65 R6: xc7a200tfbg484, S25FL512S (JEDEC 01 02 20), FT2232H cable (
-c ft2232) - openFPGALoader v0.12.0 (Ubuntu 24.04 package). The same code is on master:
spiFlash.cpphas no DYB or PPB handling, and--unprotect-flashonly clears the BP bits.
Command and output
openFPGALoader -c ft2232 --ftdi-serial 251633005A66 --fpga-part xc7a200tfbg484 \
--write-flash --verify --file-type bin --offset 0x2800000 core.cor
use: /usr/share/openFPGALoader/spiOverJtag_xc7a200tfbg484.bit.gz
load program
Load SRAM: [==================================================] 100.00%
Done
Detected: spansion S25FL512S 1024 sectors size: 512Mb
02800000 00000000 00000000 00
timeout: 23 89 89
23
wait: Error
Erasing: [============================================== ] 91.30%timeout: 23 89 89
23
wait: Error
Erasing: [============================================== ] 91.44%timeout: 23 89 89
23
wait: Error
...
- Status register 1 is 0x23: E_ERR (bit 5), WEL, and WIP. On the S-family, WIP stays set after an erase error until CLSR (0x30) or a reset.
- The first erase already fails. The bar shows the absolute address over the end address, and 0x2800000 / 0x2BD0000 is 91.3 %. That is misleading when
--offsetis large. It may be worth showing(addr - start) / (end - start)instead. - The addressing is fine: v0.12.0 sends 4BE64 (0xDC) above 16 MiB.
Cause
On the MEGA65 the sectors are DYB-protected when a host gets to the flash. The MEGA65's own flash tool clears each 256 KiB sector's DYB before erasing it. It sends DYB Write (0xE1, a 4-byte address, 0xFF) until DYB Read (0xE0) returns 0xFF, and then sends Clear Status (0x30). See unprotect_flash() and erase_sector() in mega65-core's src/utilities/qspicommon.c.
Suggestion
For the Spansion S25FL-S chips (at least the S25FL512S):
- Before erasing, read each sector's PPB (0xE2) and DYB (0xE0) in the range. If the PPB is protected, stop with a clear message. If the DYB is protected, clear it with WREN and 0xE1 … 0xFF when
--unprotect-flashis given (or always, as DYBs are volatile), and otherwise stop with a message rather than time out. - After a timeout with E_ERR or P_ERR (0x60) set, send 0x30 and stop. At the moment the loop continues and every later sector times out.
As a workaround outside openFPGALoader, I'm going to clear the DYBs through the v1 spiOverJtag bridge after a --dump-flash --skip-reset, and then write with --skip-load-bridge. I'm happy to test a patch on the MEGA65 R6.
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 396
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 15
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from trabucayre/openFPGALoader
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
trabucayre/openFPGALoader#767 ·
Maintainers usually reply within 1 day
-
Done Wait for feedback
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
trabucayre/openFPGALoader#735 · 2 comments ·
Maintainers usually reply within 1 day
-
spiFlash: sectors_erase() erases outside the requested rangePossibly taken @Milo0x1 claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 20/100
trabucayre/openFPGALoader#765 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
trabucayre/openFPGALoader#753 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
trabucayre/openFPGALoader#741 ·
Maintainers usually reply within 1 day
All issues in trabucayre/openFPGALoader
Similar issues
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/DirectXShaderCompiler#9155 ·
Maintainers usually reply within 2 days
-
Errors in 1.20 proseOpenCampaign DiD Campaign EI Campaign HttT Campaign TDG Campaign TSG Campaign WoF Enhancement Help Prose Stable 1.20
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wesnoth/wesnoth#11749 · 2 comments ·
Maintainers usually reply within 1 day
-
agent:Windows bug in progress pri:medium sev:low testing windows
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
protocolbuffers/protobuf#31768 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#125651 ·
Maintainers usually reply within 1 day