@@ -4,12 +4,49 @@ The bundled examples are one of the best parts of this library. This page explai
44
55## ` FlashDiagnostics/FlashDiagnostics.ino `
66
7- ### What it tests
7+ ### Exact test inventory (every operation it executes)
88
9- - Chip identity (` getJEDECID ` , capacity, max page, unique ID)
10- - Power operations (` powerDown ` , ` powerUp ` )
11- - Erase operations (` eraseChip ` , ` eraseSection ` , sector/block erase)
12- - Data I/O for many types (byte, char, word, short, long, float, struct, array, string)
9+ Identity and metadata (from ` getID() ` ):
10+
11+ - ` flash.libver(&_ver, &_subver, &_bugfix) ` (when ` LIBVER ` is enabled)
12+ - ` flash.getJEDECID() `
13+ - ` flash.getCapacity() `
14+ - ` flash.getMaxPage() `
15+ - ` flash.getUniqueID() `
16+
17+ Power tests:
18+
19+ - ` flash.powerDown() `
20+ - ` flash.powerUp() `
21+
22+ Erase tests:
23+
24+ - ` flash.eraseChip() `
25+ - ` flash.eraseSection(_addr, KB(72)) `
26+ - ` flash.eraseBlock64K(_addr) `
27+ - ` flash.eraseBlock32K(_addr) `
28+ - ` flash.eraseSector(_addr) ` (4 KB)
29+
30+ Primitive data write/read tests:
31+
32+ - ` flash.writeByte(addr, 35) ` + ` flash.readByte(addr) `
33+ - ` flash.writeChar(addr, -110) ` + ` flash.readChar(addr) `
34+ - ` flash.writeWord(addr, 4520) ` + ` flash.readWord(addr) `
35+ - ` flash.writeShort(addr, -1250) ` + ` flash.readShort(addr) `
36+ - ` flash.writeULong(addr, 876532) ` + ` flash.readULong(addr) `
37+ - ` flash.writeLong(addr, -10959) ` + ` flash.readLong(addr) `
38+ - ` flash.writeFloat(addr, 3.14) ` + ` flash.readFloat(addr) `
39+
40+ Higher-level data tests:
41+
42+ - ` flash.writeStr(addr, "This is a test String 123!@#") ` + ` flash.readStr(addr, _data) `
43+ - ` flash.writeAnything(addr, testStruct) ` + ` flash.readAnything(addr, testStructOut) `
44+ - ` flash.writeByteArray(addr, _d, 256) ` + ` flash.readByteArray(addr, _data, 256) `
45+
46+ Timing and diagnostics:
47+
48+ - ` flash.functionRunTime() ` is sampled after each operation to print runtime columns.
49+ - PASS/FAIL is decided by value comparison in each test function.
1350
1451### Why run it first
1552
@@ -77,6 +114,23 @@ Interactive serial command tester for direct operation-by-operation checks.
77114
78115Use this when you want to isolate a single failing operation (` writeByte ` , ` eraseSector ` , ` readStr ` , etc.) without full diagnostics noise.
79116
117+ ### Full command map (all interactive commands)
118+
119+ 1 . ` getJEDECID ` and component ID bytes
120+ 2 . ` writeByte(addr, byte) `
121+ 3 . ` readByte(addr) `
122+ 4 . ` writeWord(addr, word) `
123+ 5 . ` readWord(addr) `
124+ 6 . ` writeStr(addr, inputString) `
125+ 7 . ` readStr(addr, outputString) `
126+ 8 . ` writeByteArray(addr, pageBuffer, SPI_PAGESIZE) ` where ` pageBuffer ` is ` 0..255 `
127+ 9 . ` readByteArray(addr, data_buffer, SPI_PAGESIZE) ` via ` printPage `
128+ 10 . Full-chip dump: loops through flash and calls ` readByteArray ` repeatedly in ` printAllPages `
129+ 11 . ` eraseSector(addr) ` (4 KB)
130+ 12 . ` eraseBlock32K(addr) `
131+ 13 . ` eraseBlock64K(addr) `
132+ 14 . ` eraseChip() `
133+
80134### Tips
81135
82136- Set Serial Monitor to expected line ending mode from sketch notes.
@@ -126,6 +180,22 @@ The byte at address ... is: ...
126180
127181How to use ` getAddress() ` and ` sizeofStr() ` to allocate addresses safely without hardcoding offsets.
128182
183+ ### Exact API calls used
184+
185+ - Allocation:
186+ - ` flash.getAddress(sizeof(byte)) `
187+ - ` flash.getAddress(sizeof(float)) `
188+ - ` flash.getAddress(flash.sizeofStr(testStr[i])) `
189+ - Byte I/O:
190+ - ` flash.writeByte(byteAddr[i], testByte[i]) `
191+ - ` flash.readByte(byteAddr[i]) `
192+ - Float I/O:
193+ - ` flash.writeFloat(floatAddr[i], testFloat[i]) `
194+ - ` flash.readFloat(floatAddr[i]) `
195+ - String I/O:
196+ - ` flash.writeStr(strAddr[i], testStr[i]) `
197+ - ` flash.readStr(strAddr[i], _string) `
198+
129199### Troubleshooting value
130200
131201If this fails, you may have pre-written data conflicts or boundary behavior confusion.
@@ -158,6 +228,13 @@ Addresses should be valid hex values and read-back values should match writes.
158228
159229Simple ` writeStr ` /` readStr ` workflow.
160230
231+ ### Exact API calls used
232+
233+ - ` flash.getCapacity() ` (for random address generation)
234+ - ` flash.writeStr(strAddr, inputString) `
235+ - ` flash.readStr(strAddr, outputString) `
236+ - ` flash.eraseSector(strAddr) ` (cleanup after test)
237+
161238### Troubleshooting value
162239
163240Great for catching string-specific issues (length metadata, readback integrity, sector erase assumptions).
@@ -181,6 +258,19 @@ The written/read strings should be identical and the address should match in bot
181258
182259Write/read complete structs repeatedly, including nested members and arrays.
183260
261+ ### Exact API calls used
262+
263+ - ` flash.getCapacity() ` (random target address range)
264+ - ` flash.eraseSection(_addr, sizeof(configurationIn)) `
265+ - ` flash.writeAnything(_addr, configurationIn) `
266+ - ` flash.readAnything(_addr, configurationOut) `
267+
268+ Loop behavior detail:
269+
270+ - Runs ` NUMBEROFREPEATS ` iterations (` 100 ` by default).
271+ - Tracks ` eraseCount ` , ` writeCount ` , ` errorCount ` , ` readCount ` .
272+ - Final summary prints all counters.
273+
184274### Troubleshooting value
185275
186276Use this for data-model persistence validation. If this fails while primitive tests pass, inspect struct layout assumptions and erase coverage.
@@ -229,6 +319,15 @@ This file does not run as a standalone sketch. It provides helper print function
229319
230320If formatting looks wrong in diagnostics output, this helper file is the first place to inspect.
231321
322+ ### Helper functions defined in this file
323+
324+ - Output helpers: ` printLine ` , ` printTab ` , ` printTime ` , ` printTimer ` , ` pass `
325+ - Identity helpers: ` printUniqueID ` , ` getID `
326+ - Test routines:
327+ - ` powerDownTest ` , ` powerUpTest `
328+ - ` eraseChipTest ` , ` eraseSectionTest ` , ` eraseBlock64KTest ` , ` eraseBlock32KTest ` , ` eraseSectorTest `
329+ - ` byteTest ` , ` charTest ` , ` wordTest ` , ` shortTest ` , ` uLongTest ` , ` longTest ` , ` floatTest ` , ` structTest ` , ` arrayTest ` , ` stringTest `
330+
232331## Recommended order for beginners
233332
2343331 . ` FlashDiagnostics.ino `
0 commit comments