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