#define MXC_UNLOCK_BLK_END 0xFFFF
extern unsigned int hal_timer_count(void);
-int nfc_program_region(flash_addr_t addr, u8 *buf, u32 len);
-int nfc_erase_region(flash_addr_t addr, u32 len, bool skip_bad, bool verbose);
+static int nfc_program_region(flash_addr_t addr, u8 *buf, u32 len);
+static int nfc_erase_region(flash_addr_t addr, u32 len, bool skip_bad, bool verbose);
static int nfc_write_pg_random(u32 pg_no, u32 pg_off, u8 *buf, u32 ecc_force);
static int nfc_read_pg_random(u32 pg_no, u32 pg_off, u32 ecc_force, u32 cs_line,
*
* @return FLASH_ERR_OK (0) if successful; non-zero otherwise
*/
-int nfc_erase_region(flash_addr_t addr, u32 len, bool skip_bad, bool verbose)
+static int nfc_erase_region(flash_addr_t addr, u32 len, bool skip_bad, bool verbose)
{
u32 sz, blk, update = 0, j = 0;
* @param len number of bytes
* @return FLASH_ERR_OK (0) if successful; non-zero otherwise
*/
-int nfc_program_region(flash_addr_t addr, u8 *buf, u32 len)
+static int nfc_program_region(flash_addr_t addr, u8 *buf, u32 len)
{
u32 sz, blk, update = 0, partial_block_size;
return FLASH_ERR_INVALID;
}
- partial_block_size = addr % NF_BLK_SZ;
+ partial_block_size = NF_BLK_SZ - (addr % NF_BLK_SZ);
mxc_nfc_buf_clear(NAND_SPAR_BUF0, 0xff, NF_SPARE_SZ);
addr = nfc_l_to_p(addr);
blk = OFFSET_TO_BLOCK(addr);
if (nfc_is_badblock(blk, g_bbt)) {
diag_printf("\nSkipping bad block %u at addr 0x%08llx\n", blk, addr);
+ g_block_offset++;
goto incr_address;
}
mark_blk_bad(blk, g_bbt, BLK_BAD_RUNTIME);
// we don't need to update the table immediately here since even
// with power loss now, we should see the same program error again.
+ g_block_offset++;
goto incr_address;
}
diag_printf(".");
incr_address:
addr += partial_block_size;
partial_block_size = NF_BLK_SZ;
- g_block_offset++;
}
if (update) {
if (program_bbt_to_flash() != 0) {
nfc_printf(NFC_DEBUG_MED, "%s: addr=0x%08llx, offset=%03x buf=0x%p, len=0x%08x\n",
__FUNCTION__, addr, offset, buf, len);
- addr = nfc_l_to_p(addr);
if (addr < (u32)flash_info.start || (addr + len) > (u32)flash_info.end || len == 0) {
diag_printf("** Error: flash address 0x%08llx..0x%08llx outside valid range %p..%p\n",
(u64)addr, (u64)addr + len - 1, flash_info.start, flash_info.end);
return FLASH_ERR_INVALID;
}
+ addr = nfc_l_to_p(addr);
while (len > 0) {
int i;