Skip to content

The NAND flash header calculation is incorrect #124

Open

Description

@keyehe

the handle_cmd_initialize fucntion,

The correctability variable is incorrect, causing the header calculation to be incorrect when header==0.
The FMND1G08U3J IC,
■
RELIABILITY

10 0,000 Program / Erase cycles
(with 4 bit/512 Byte ECC)

Correct header is 0xC0902405
BUT,
header = pmecc_get_default_header(correctability);
header = 0xC6908405

/* try reading ONFI data */
if (nand_onfi_device_detect(&nand) && nand_onfi_check_compatibility(&nand)) {
	nand_onfi_disable_internal_ecc(&nand);
	nand_onfi_get_model(&model_from_onfi);
	model = &model_from_onfi;
	correctability = nand_onfi_get_ecc_correctability();
	if (correctability != 0xff) {
		/* ONFI correctability is number of ECC bits per 512 bytes of data */
		correctability *= nand_onfi_get_page_size() / 512;
	}
}

/* Initialize PMECC */
if (header == 0) {
	header = pmecc_get_default_header(correctability);
	trace_warning_wp("Using default PMECC configuration\r\n");
}

After I made some corrections, I was able to get the correct values, but the code still felt a little off.
Before:
if (correctability != 0xff) {
After:
if (correctability == 0xff) {

Activity

  1. keyehe commented on Dec 1, 2025

    @keyehe
    Author

    correctability != 0xff is right. SORRY!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions