nand_check_erased_ecc_chunk(9)
π nand_check_erased_ecc_chunk(9) β Kernel API Manual π
β¨ NAME β¨
nand_check_erased_ecc_chunk β check if an ECC chunk contains (almost) only 0xff data. That's the mission, bestie.
π SYNOPSIS π
int nand_check_erased_ecc_chunk (void *data , int datalen , void *ecc ,
int ecclen , void *extraoob , int extraooblen , int bitflips_threshold
);
π ARGUMENTS π
dataβ data buffer to test. Yes, this is the main character.datalenβ data length.eccβ ECC buffer.ecclenβ ECC length.extraoobβ extra OOB buffer.extraooblenβ extra OOB length.bitflips_thresholdβ maximum number of bitflips. Respect the limit.
πΈ DESCRIPTION πΈ
Okay so the vibe is: check if a data buffer and its associated ECC and OOB data contains only 0xff pattern. If it does, that means the underlying region has been erased and is ready to be programmed. The bitflips_threshold specify the maximum number of bitflips before considering the region as not erased. Basically, it's giving "is this chunk fresh or nah?"
π₯ NOTE π₯
- ECC algorithms are working on pre-defined block sizes which are usually different from the NAND page size. When fixing bitflips, ECC engines will report the number of errors per chunk, and the NAND core infrastructure expect you to return the maximum number of bitflips for the whole page. This is why you should always use this function on a single chunk and not on the whole page. After checking each chunk you should update your
max_bitflipsvalue accordingly. One chunk at a time, periodt. - When checking for bitflips in erased pages you should not only check the payload data but also their associated ECC data, because a user might have programmed almost all bits to 1 but a few. In this case, we shouldn't consider the chunk as erased, and checking ECC bytes prevent this case. ECC bytes are lowkey doing unpaid labor here.
- The
extraoobargument is optional, and should be used if some of your OOB data are protected by the ECC engine. It could also be used if you support subpages and want to attach some extra OOB data to an ECC chunk. Optional but iconic.
Returns a positive number of bitflips less than or equal to bitflips_threshold, or -ERROR_CODE for bitflips in excess of the threshold. In case of success, the passed buffers are filled with 0xff. Success = buffers get the 0xff glow-up.
π¦ SEE ALSO π¦
Kernel file ./drivers/mtd/nand/core.c, plus the whole friend group:
nand_check_erased_buf(9)nanddev_isbad(9)nanddev_markbad(9)nanddev_isreserved(9)nanddev_erase(9)nanddev_mtd_erase(9)nanddev_mtd_max_bad_blocks(9)nanddev_get_ecc_engine(9)nanddev_put_ecc_engine(9)nanddev_find_ecc_configuration(9)nanddev_ecc_engine_init(9)nanddev_ecc_engine_cleanup(9)nanddev_init(9)nanddev_cleanup(9)
Sign-off tea π«: source is ./drivers/mtd/nand, version/date is October 2026, and the page is nand_check_erased_ecc_chunk(9). Bye bestie, go check those chunks! π
β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms