Last updated: 2026-07-29. Checked boxes mean done. Don't check them prematurely.
These can cause crashes, data corruption, or silent misbehavior.
-
int long long leninmain.c:138— This is not valid C. Two type specifiers (int+long long) on the same declaration. GCC happens to parse it aslong long, but clang rejects it. Fix: remove the strayint. -
flashcmd_verifyhardcodessnand_read—flashcmd_api.c:72callssnand_read()directly, bypassing theflash_cmddispatch. If called on a NOR flash chip, it reads via NAND protocol → garbage or hang. Currently dead code (CLI uses its owndo_verify), but it's exported in the header. Fix: removed the function entirely — dead code, never called. -
test_write_fail_flagis dead code —spi_nand_flash.c:629. Declared asint, set to 0, never read. Removed. - Test scripts are fake —
test_suite.shandtest_advanced.shdon't actually test anything. They print PASS unconditionally regardless of real behavior.BIN_DIRhardcodes/tmp/opencode/scribawhich doesn't exist on any development machine. These are documentation placeholders, not tests. Deleted. TESTING.md retains the manual test procedures.
Issues that won't crash today but degrade reliability and maintainability.
- NOR flash progress printing bypasses
timer.c—snor_eraseandsnor_readuse inlineprintf("\bErase %ld%%...")with hardcoded backspace-counting tricks.spi_nand_flash.cusestimer_print_progress(). Two completely different progress display mechanisms. Fixed: unified timer API (timer_progress(msg, current, total)), all call sites (NOR, NAND, EEPROM) now use the same function. -
timer.cprogress is fragile —timer_print_progressuses\bbackspace tricks to overwrite,progress_printedflag with unclear reset logic,volatileon a variable that can't be accessed concurrently. Fixed: rewritten to use\r+\e[K(ANSI clear-to-EOL), mergedtimer_progressandtimer_print_progressinto one function, removedvolatile. - 17
#ifdef __EMSCRIPTEN__blocks inspi_nor_flash.c— Down to 3 (legitimate platform diffs). Moved chunked read/write intoSPI_CONTROLLER_Read_NByte/Write_NByte; removed progress/timer guards (handled internally by timer.c). -
spi_nand_flash_core.c(447 lines) not compiled — Deleted. Globals already defined inspi_nand_flash.c. Dead code from a refactor. - Duplicate chip entries in
chips_data—EN25XQ128A(lines 585-586),PY25Q64HA(709-710). Removed exact duplicates. TheIS25LP256Dentries have different densities (256Mb vs 512Mb) — added clarifying comments. - Type inconsistency:
uint8_tvsu8— Converted three functions inspi_nor_flash.c(snor_wait_ready,snor_read_rg,snor_write_rg) tou8. -
bmt_oob_sizetype mismatch —OOB_sizechanged frominttou32. All comparisons now same signedness. Removed unnecessary casts. - Commented-out
snor_dbgcalls — Removed. -
/* Stray code removed: ... */inspi_nor_flash.c— Removed.
Structural issues that make the codebase harder to reason about.
-
do_verify(main.c) andflashcmd_verify(flashcmd_api.c) are near-duplicates — Consolidated: newflashcmd_verify(struct flash_cmd*, ...)in flashcmd_api.c, called from both-Wand-w -vpaths in main.c. Old brokenflashcmd_verify(snand_read hardcode) removed. -
timer_progress()/timer_print_progress()split — Two functions where one would do. Merged intotimer_progress(msg, current, total)returning void with rate-limiting internal. -
_SPI_NAND_SEMAPHORE_LOCK/UNLOCKmacros — Removed. No-ops in a single-threaded userspace program. All 14 call sites deleted. - CH341A SPI driver is 899 lines with its own USB transfer batching —
Introduced
struct spi_programmervtable inspi_controller. Each driver provides a vtable instance.spi_controller_init()handles auto-detect; allSPI_CONTROLLER_*functions dispatch through the vtable — no more if/else onprogrammer_type. Adding a third programmer is now trivial. -
spi_nand_flash_tables.cis 73 KB / 1839 lines — Documented field layout in header comment. Pure data, splitting by manufacturer adds no value.
Not urgent. Fix opportunistically when touching nearby code.
- TODO comments in
ch341a_i2c.h— Removed. Magic firmware blobs are correct as raw byte strings; structs would add alignment risk. -
volatile int progress_printedintimer.c— No thread, no ISR, no DMA. Removed (entire timer.c rewritten). - Missing JEDEC IDs in NOR chip table — Replaced REVISIT with documentation of the upper-16-bit matching convention. Full IDs require per-chip datasheets; partial IDs work correctly via the stripped match.
-
snor_progressstate tracking — Kept. Debug-only, zero cost when disabled, useful for diagnosing erase/program failures. - Add
-Wextrato Makefile — Added. Code compiles cleanly with-Wall -Wextra(zero warnings). -
#ifdef __EMSCRIPTEN__usesch341a_spi_send_commanddirectly — Removed all three direct calls (snor_read_sr,snor_read_devid,snor_read_rg). Now routed throughSPI_CONTROLLER_*vtable uniformly. -
flashcmd_verifytakesfile_lenparameter it doesn't use — Old function deleted in Sprint 1. Replacement has no unused parameters. -
nandflash_init,nandflash_read,nandflash_erase,nandflash_writeare wrapper functions — Inlined intosnand_*functions. Removed 4 unnecessary call frames.
- EEPROM support missing from WASM build — Added EEPROM source files
and
-DEEPROM_SUPPORTto CMakeLists.txt. -
ASYNCIFY_IMPORTSmust stay in sync — Documented in CMakeLists.txt with comment explaining the constraint. - Web build needs 64 MB initial memory — Documented in CMakeLists.txt
with practical limit note (~128 MB flash).
ALLOW_MEMORY_GROWTH=1is set for larger chips.
- Fix
int long longin main.c - Delete or fix
flashcmd_verifyto useflash_cmddispatch - Delete
test_write_fail_flag - Delete or rewrite test scripts (remove fake tests)
- Remove duplicate chip entries (verify IS25LP256D densities)
- Merge
timer_progress+timer_print_progressinto one function - Route NOR progress through the unified timer (remove inline printf tricks)
- Remove
volatilefrom timer globals - Fix the
\b-counting to use\r+ clear-to-EOL
- Move
do_verifylogic intoflashcmd_api.c, usingstruct flash_cmd* - Use the same function from CLI and WASM
- Delete the broken
flashcmd_verify
- Move WASM chunking logic into
spi_controller.c(makeRead_NBytehandle large reads internally regardless of platform) - Remove direct
ch341a_spi_send_commandcalls from NOR driver - Verify EZP2019 would work in WASM build after cleanup
- Convert
uint8_t→u8in NOR driver - Fix
bmt_oob_size/OOB_sizesignedness - Remove dead commented-out code
- Add
-Wextrato Makefile, fix warnings
- Delete or integrate
spi_nand_flash_core.c - Remove
_SPI_NAND_SEMAPHORE_*no-ops - Split
spi_nand_flash_tables.cby manufacturer - Extract common USB patterns from CH341A/EZP2019 drivers