kobs-ng: Add support for overriding size
[openwrt/openwrt.git] / package / boot / kobs-ng / patches / 002-add-init-size-param.patch
1 --- a/src/main.c
2 +++ b/src/main.c
3 @@ -94,6 +94,7 @@ void usage(void)
4 " [KOBS] boot structures config options\n"
5 " --chip_0_device_path=<path> .......... Device of boot (default /dev/mtd0)\n"
6 " --chip_1_device_path=<path> .......... The second chip in case of multichip NAND\n"
7 + " --chip_0_size=<size> ................. Override size of chip_0 device\n"
8 " --search_exponent=<value> ............ NCB field (default 2)\n"
9 " --data_setup_time=<value> ............ NCB field (default 80)\n"
10 " --data_hold_time=<value> ............. NCB field (default 60)\n"
11 --- a/src/mtd.c
12 +++ b/src/mtd.c
13 @@ -716,6 +716,11 @@ struct mtd_data *mtd_open(const struct m
14 goto out;
15 }
16
17 + /* override MTD size */
18 + if (md->cfg.chip_0_size) {
19 + miu->size = md->cfg.chip_0_size;
20 + }
21 +
22 /* verify it's a nand */
23 if (miu->type != MTD_NANDFLASH) {
24 fprintf(stderr, "mtd: device %s not NAND\n", mp->name);
25 @@ -2914,7 +2919,7 @@ static const struct {
26 } mtd_int_args[] = {
27 ARG_IGNORE(chip_count),
28 ARG_IGNORE(chip_0_offset),
29 - ARG_IGNORE(chip_0_size),
30 + ARG(chip_0_size),
31 ARG_IGNORE(chip_1_offset),
32 ARG_IGNORE(chip_1_size),
33 ARG(search_exponent),
34 @@ -3107,7 +3112,7 @@ void mtd_cfg_dump(struct mtd_config *cfg
35 // Pd(chip_count);
36 Ps(chip_0_device_path);
37 // Pd(chip_0_offset);
38 -// Pd(chip_0_size);
39 + Pd(chip_0_size);
40 Ps(chip_1_device_path);
41 // Pd(chip_1_offset);
42 // Pd(chip_1_size);