1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2014 Andreas Bießmann <andreas@biessmann.org>
7 * This is a host tool for generating an appropriate string out of board
8 * configuration. The string is required for correct generation of PMECC
9 * header which in turn is required for NAND flash booting of Atmel AT91 style
12 * See doc/README.atmel_pmecc for more information.
18 static int pmecc_get_ecc_bytes(int cap, int sector_size)
20 int m = 12 + sector_size / 512;
21 return (m * cap + 7) / 8;
24 int main(int argc, char *argv[])
26 unsigned int use_pmecc = 0;
27 unsigned int sector_per_page;
28 unsigned int sector_size = CONFIG_PMECC_SECTOR_SIZE;
29 unsigned int oob_size = CONFIG_SYS_NAND_OOBSIZE;
30 unsigned int ecc_bits = CONFIG_PMECC_CAP;
31 unsigned int ecc_offset;
33 #ifdef CONFIG_ATMEL_NAND_HW_PMECC
37 sector_per_page = CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_PMECC_SECTOR_SIZE;
38 ecc_offset = oob_size -
39 pmecc_get_ecc_bytes(ecc_bits, sector_size) * sector_per_page;
41 printf("usePmecc=%d,", use_pmecc);
42 printf("sectorPerPage=%d,", sector_per_page);
43 printf("sectorSize=%d,", sector_size);
44 printf("spareSize=%d,", oob_size);
45 printf("eccBits=%d,", ecc_bits);
46 printf("eccOffset=%d", ecc_offset);