Skip to content

Commit fa52074

Browse files
committed
Implemented configuration of bad block mark offset
1 parent 487cad8 commit fa52074

File tree

8 files changed

+23
-10
lines changed

8 files changed

+23
-10
lines changed

firmware/chip_info.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ typedef struct
2929
uint8_t erase1_cmd;
3030
uint8_t erase2_cmd;
3131
uint8_t status_cmd;
32+
uint8_t bb_mark_off;
3233
} chip_info_t;
3334

3435
#endif /* _CHIP_INFO_H_ */

firmware/nand_programmer.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ typedef struct __attribute__((__packed__))
126126
uint8_t erase1_cmd;
127127
uint8_t erase2_cmd;
128128
uint8_t status_cmd;
129+
uint8_t bb_mark_off;
129130
} np_conf_cmd_t;
130131

131132
enum
@@ -323,7 +324,7 @@ static int np_read_bad_block_info_from_page(np_prog_t *prog, uint32_t block,
323324
uint32_t status, addr = block * prog->chip_info.block_size;
324325

325326
status = nand_read_data(prog->page.buf, page, 0, prog->chip_info.page_size
326-
+ 1);
327+
+ prog->chip_info.spare_size);
327328
switch (status)
328329
{
329330
case NAND_READY:
@@ -339,8 +340,8 @@ static int np_read_bad_block_info_from_page(np_prog_t *prog, uint32_t block,
339340
return NP_ERR_NAND_RD;
340341
}
341342

342-
*is_bad = prog->page.buf[prog->chip_info.page_size] !=
343-
NP_NAND_GOOD_BLOCK_MARK;
343+
*is_bad = prog->page.buf[prog->chip_info.page_size +
344+
prog->chip_info.bb_mark_off] != NP_NAND_GOOD_BLOCK_MARK;
344345

345346
return 0;
346347
}
@@ -355,7 +356,7 @@ static int _np_cmd_read_bad_blocks(np_prog_t *prog)
355356
page_num = prog->chip_info.block_size / prog->chip_info.page_size;
356357

357358
/* Bad block - not 0xFF value in the first or second page in the block at
358-
* zero offset in the page spare area
359+
* some offset in the page spare area
359360
*/
360361
for (block = 0; block < block_num; block++)
361362
{
@@ -1000,6 +1001,7 @@ static void np_fill_chip_info(np_conf_cmd_t *conf_cmd, np_prog_t *prog)
10001001
prog->chip_info.erase1_cmd = conf_cmd->erase1_cmd;
10011002
prog->chip_info.erase2_cmd = conf_cmd->erase2_cmd;
10021003
prog->chip_info.status_cmd = conf_cmd->status_cmd;
1004+
prog->chip_info.bb_mark_off = conf_cmd->bb_mark_off;
10031005
prog->chip_is_conf = 1;
10041006
}
10051007

@@ -1026,6 +1028,7 @@ static void np_print_chip_info(np_prog_t *prog)
10261028
DEBUG_PRINT("Erase 1 command: %d\r\n", prog->chip_info.erase1_cmd);
10271029
DEBUG_PRINT("Erase 2 command: %d\r\n", prog->chip_info.erase2_cmd);
10281030
DEBUG_PRINT("Status command: %d\r\n", prog->chip_info.status_cmd);
1031+
DEBUG_PRINT("Bad block mark offset: %d\r\n", prog->chip_info.bb_mark_off);
10291032
}
10301033

10311034
static int np_cmd_nand_conf(np_prog_t *prog)

qt/chip_db.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ enum
5151
CHIP_PARAM_ERASE1_CMD,
5252
CHIP_PARAM_ERASE2_CMD,
5353
CHIP_PARAM_STATUS_CMD,
54+
CHIP_PARAM_BB_MARK_OFF,
5455
CHIP_PARAM_NUM,
5556
};
5657

qt/chip_db_dialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ChipDbDialog::ChipDbDialog(ChipDb *chipDb, QWidget *parent) : QDialog(parent),
2222
HEADER_MED_WIDTH);
2323
for (int i = CHIP_PARAM_T_CS; i <= CHIP_PARAM_T_REA; i++)
2424
ui->chipDbTableView->setColumnWidth(i, HEADER_SHORT_WIDTH);
25-
for (int i = CHIP_PARAM_ROW_CYCLES; i <= CHIP_PARAM_STATUS_CMD; i++)
25+
for (int i = CHIP_PARAM_ROW_CYCLES; i <= CHIP_PARAM_BB_MARK_OFF; i++)
2626
ui->chipDbTableView->setColumnWidth(i, HEADER_MED_WIDTH);
2727

2828
connect(ui->addChipDbButton, SIGNAL(clicked()), this,

qt/chip_db_table_model.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ QVariant ChipDbTableModel::data(const QModelIndex &index, int role) const
6060
case CHIP_PARAM_ERASE1_CMD:
6161
case CHIP_PARAM_ERASE2_CMD:
6262
case CHIP_PARAM_STATUS_CMD:
63+
case CHIP_PARAM_BB_MARK_OFF:
6364
return (*chipDb)[index.row()]->params[column];
6465
}
6566

@@ -102,7 +103,8 @@ QVariant ChipDbTableModel::headerData(int section, Qt::Orientation orientation,
102103
case CHIP_PARAM_WRITE2_CMD: return tr("Write 2 com.");
103104
case CHIP_PARAM_ERASE1_CMD: return tr("Erase 1 com.");
104105
case CHIP_PARAM_ERASE2_CMD: return tr("Erase 2 com.");
105-
case CHIP_PARAM_STATUS_CMD: return tr("Status com.");
106+
case CHIP_PARAM_STATUS_CMD: return tr("Status com.");
107+
case CHIP_PARAM_BB_MARK_OFF: return tr("BB mark off.");
106108
}
107109
}
108110

@@ -171,7 +173,9 @@ QVariant ChipDbTableModel::headerData(int section, Qt::Orientation orientation,
171173
case CHIP_PARAM_ERASE2_CMD:
172174
return tr("Erase 2 command");
173175
case CHIP_PARAM_STATUS_CMD:
174-
return tr("Status command");
176+
return tr("Status command");
177+
case CHIP_PARAM_BB_MARK_OFF:
178+
return tr("Bad block mark offset");
175179
}
176180
}
177181

@@ -238,6 +242,7 @@ bool ChipDbTableModel::setData(const QModelIndex &index, const QVariant &value,
238242
case CHIP_PARAM_ERASE1_CMD:
239243
case CHIP_PARAM_ERASE2_CMD:
240244
case CHIP_PARAM_STATUS_CMD:
245+
case CHIP_PARAM_BB_MARK_OFF:
241246
paramVal = value.toUInt(&convOk);
242247
if (!convOk)
243248
return false;

qt/cmd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ typedef struct __attribute__((__packed__))
8787
uint8_t erase1Cmd;
8888
uint8_t erase2Cmd;
8989
uint8_t statusCmd;
90+
uint8_t bbMarkOff;
9091
} ConfCmd;
9192

9293
enum

qt/nando_chip_db.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# name, page size, block size, total size, spare size, tCS, tCLS, tALS, tCLR, tAR, tWP, tRP, tDS, tCH, tCLH, tALH, tWC, tRC, tREA, row cycles, col. cycles, read 1 com., read 2 com., read ID com., reset com., write 1 com., write 2 com., erase 1 com., erase 2 com., status com.
2-
K9F2G08U0C, 2048, 131072, 268435456, 64, 20, 12, 12, 10, 10, 12, 12, 12, 5, 5, 5, 25, 25, 20, 3, 2, 0, 48, 144, 255, 128, 16, 96, 208, 112
3-
K9F1G08U0E, 2048, 131072, 134217728, 64, 20, 12, 12, 10, 10, 12, 12, 12, 5, 5, 5, 25, 25, 20, 3, 2, 0, 48, 144, 255, 128, 16, 96, 208, 112
1+
# name, page size, block size, total size, spare size, tCS, tCLS, tALS, tCLR, tAR, tWP, tRP, tDS, tCH, tCLH, tALH, tWC, tRC, tREA, row cycles, col. cycles, read 1 com., read 2 com., read ID com., reset com., write 1 com., write 2 com., erase 1 com., erase 2 com., status com., bad block mark off.
2+
K9F2G08U0C, 2048, 131072, 268435456, 64, 20, 12, 12, 10, 10, 12, 12, 12, 5, 5, 5, 25, 25, 20, 3, 2, 0, 48, 144, 255, 128, 16, 96, 208, 112, 0
3+
K9F1G08U0E, 2048, 131072, 134217728, 64, 20, 12, 12, 10, 10, 12, 12, 12, 5, 5, 5, 25, 25, 20, 3, 2, 0, 48, 144, 255, 128, 16, 96, 208, 112, 0

qt/programmer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ void Programmer::confChip(ChipInfo *chipInfo)
335335
(chipInfo->params[CHIP_PARAM_ERASE2_CMD]);
336336
confCmd.statusCmd = static_cast<uint8_t>
337337
(chipInfo->params[CHIP_PARAM_STATUS_CMD]);
338+
confCmd.bbMarkOff = static_cast<uint8_t>
339+
(chipInfo->params[CHIP_PARAM_BB_MARK_OFF]);
338340

339341
QObject::connect(&reader, SIGNAL(result(int)), this,
340342
SLOT(confChipCb(int)));

0 commit comments

Comments
 (0)