Skip to content

Commit a91b414

Browse files
committed
Read whole page to access spare area
1 parent 94b95c9 commit a91b414

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

firmware/nand_programmer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <stdbool.h>
1717

1818
#define NP_PACKET_BUF_SIZE 64
19-
#define NP_MAX_PAGE_SIZE 0x0800
19+
#define NP_MAX_PAGE_SIZE 0x0840 /* 2KB + 64 spare */
2020
#define NP_WRITE_ACK_BYTES 1984
2121
#define NP_NAND_TIMEOUT 0x1000000
2222

@@ -303,11 +303,10 @@ static int np_cmd_nand_read_id(np_prog_t *prog)
303303
static int np_read_bad_block_info_from_page(np_prog_t *prog, uint32_t block,
304304
uint32_t page, bool *is_bad)
305305
{
306-
uint8_t bad_block_data;
307306
uint32_t status, addr = block * prog->chip_info.block_size;
308307

309-
status = nand_read_data(&bad_block_data, page, prog->chip_info.page_size,
310-
sizeof(bad_block_data));
308+
status = nand_read_data(prog->page.buf, page, 0, prog->chip_info.page_size
309+
+ 1);
311310
switch (status)
312311
{
313312
case NAND_READY:
@@ -323,7 +322,8 @@ static int np_read_bad_block_info_from_page(np_prog_t *prog, uint32_t block,
323322
return NP_ERR_NAND_RD;
324323
}
325324

326-
*is_bad = bad_block_data != NP_NAND_GOOD_BLOCK_MARK;
325+
*is_bad = prog->page.buf[prog->chip_info.page_size] !=
326+
NP_NAND_GOOD_BLOCK_MARK;
327327

328328
return 0;
329329
}

0 commit comments

Comments
 (0)