]>
Commit | Line | Data |
---|---|---|
5c390a5b | 1 | /* |
09c2b8f3 | 2 | * (C) Copyright 2014 Andreas Bießmann <[email protected]> |
5c390a5b AB |
3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | |
5 | */ | |
6 | ||
7 | /* | |
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 | |
11 | * hardware. | |
12 | * | |
13 | * See doc/README.atmel_pmecc for more information. | |
14 | */ | |
15 | ||
16 | #include <config.h> | |
17 | #include <stdlib.h> | |
18 | ||
19 | static int pmecc_get_ecc_bytes(int cap, int sector_size) | |
20 | { | |
21 | int m = 12 + sector_size / 512; | |
22 | return (m * cap + 7) / 8; | |
23 | } | |
24 | ||
25 | int main(int argc, char *argv[]) | |
26 | { | |
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; | |
33 | ||
34 | #ifdef CONFIG_ATMEL_NAND_HW_PMECC | |
35 | use_pmecc = 1; | |
36 | #endif | |
37 | ||
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; | |
41 | ||
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); | |
48 | printf("\n"); | |
49 | ||
50 | exit(EXIT_SUCCESS); | |
51 | } |