fcb->metadata_size = BF_VAL(fl0, BCH_FLASHLAYOUT0_META_SIZE);
fcb->ecc_blocks_per_page = BF_VAL(fl0, BCH_FLASHLAYOUT0_NBLOCKS);
fcb->bch_mode = readl(&bch_base->hw_bch_mode);
-/*
- fcb->boot_patch = 0;
- fcb->patch_sectors = 0;
-*/
+
fcb->fw1_start_page = fw1_start_block * fcb->sectors_per_block;
fcb->fw1_sectors = fw_num_blocks * fcb->sectors_per_block;
pr_fcb_val(fcb, fw1_start_page);
int ret;
nand_erase_options_t erase_opts = { 0, };
size_t actual;
+ size_t prg_length = max_len - skip * mtd->erasesize;
+ int prg_start = (start_block + skip) * mtd->erasesize;
erase_opts.offset = start_block * mtd->erasesize;
erase_opts.length = max_len;
(u64)start_block * mtd->erasesize,
(u64)start_block * mtd->erasesize + size - 1, addr);
actual = size;
- ret = nand_write_skip_bad(mtd, start_block * mtd->erasesize,
- &actual, NULL, erase_opts.length, addr,
- WITH_DROP_FFS);
+ ret = nand_write_skip_bad(mtd, prg_start, &actual, NULL,
+ prg_length, addr, WITH_DROP_FFS);
if (ret) {
printf("Failed to program flash: %d\n", ret);
return ret;