Skip to content

Commit 83ff57e

Browse files
committed
Added spare area size parameter
1 parent 3c2a3c7 commit 83ff57e

File tree

10 files changed

+50
-34
lines changed

10 files changed

+50
-34
lines changed

firmware/chip_info.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ typedef struct
1010
{
1111
uint32_t page_size; /* without spare area */
1212
uint32_t block_size;
13-
uint32_t size;
13+
uint32_t total_size;
14+
uint32_t spare_size;
1415
uint8_t setup_time;
1516
uint8_t wait_setup_time;
1617
uint8_t hold_setup_time;

firmware/nand_programmer.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ typedef struct __attribute__((__packed__))
106106
np_cmd_t cmd;
107107
uint32_t page_size;
108108
uint32_t block_size;
109-
uint32_t size;
109+
uint32_t total_size;
110+
uint32_t spare_size;
110111
uint8_t setup_time;
111112
uint8_t wait_setup_time;
112113
uint8_t hold_setup_time;
@@ -335,7 +336,7 @@ static int _np_cmd_read_bad_blocks(np_prog_t *prog)
335336
bool is_bad;
336337
uint32_t block, block_num, page_num, page;
337338

338-
block_num = prog->chip_info.size / prog->chip_info.block_size;
339+
block_num = prog->chip_info.total_size / prog->chip_info.block_size;
339340
page_num = prog->chip_info.block_size / prog->chip_info.page_size;
340341

341342
/* Bad block - not 0xFF value in the first or second page in the block at
@@ -438,10 +439,10 @@ static int _np_cmd_nand_erase(np_prog_t *prog)
438439
return NP_ERR_LEN_NOT_ALIGN;
439440
}
440441

441-
if (addr + len > prog->chip_info.size)
442+
if (addr + len > prog->chip_info.total_size)
442443
{
443444
ERROR_PRINT("Erase address exceded 0x%lx+0x%lx is more then chip size "
444-
"0x%lx\r\n", addr, len, prog->chip_info.size);
445+
"0x%lx\r\n", addr, len, prog->chip_info.total_size);
445446
return NP_ERR_ADDR_EXCEEDED;
446447
}
447448

@@ -450,10 +451,10 @@ static int _np_cmd_nand_erase(np_prog_t *prog)
450451

451452
while (len)
452453
{
453-
if (addr >= prog->chip_info.size)
454+
if (addr >= prog->chip_info.total_size)
454455
{
455456
ERROR_PRINT("Erase address 0x%lx is more then chip size 0x%lx\r\n",
456-
addr, prog->chip_info.size);
457+
addr, prog->chip_info.total_size);
457458
return NP_ERR_ADDR_EXCEEDED;
458459
}
459460

@@ -470,7 +471,7 @@ static int _np_cmd_nand_erase(np_prog_t *prog)
470471
addr += prog->chip_info.block_size;
471472
page += pages_in_block;
472473
/* On partial erase do not count bad blocks */
473-
if (!is_bad || (is_bad && erase_cmd->len == prog->chip_info.size))
474+
if (!is_bad || (is_bad && erase_cmd->len == prog->chip_info.total_size))
474475
len -= prog->chip_info.block_size;
475476

476477
np_send_progress(total_len - len);
@@ -520,10 +521,10 @@ static int np_cmd_nand_write_start(np_prog_t *prog)
520521
addr = write_start_cmd->addr;
521522
len = write_start_cmd->len;
522523

523-
if (addr + len > prog->chip_info.size)
524+
if (addr + len > prog->chip_info.total_size)
524525
{
525526
ERROR_PRINT("Write address 0x%lx+0x%lx is more then chip size "
526-
"0x%lx\r\n", addr, len, prog->chip_info.size);
527+
"0x%lx\r\n", addr, len, prog->chip_info.total_size);
527528
return NP_ERR_ADDR_EXCEEDED;
528529
}
529530

@@ -681,10 +682,10 @@ static int np_cmd_nand_write_data(np_prog_t *prog)
681682
prog->chip_info.page_size;
682683
}
683684

684-
if (prog->addr >= prog->chip_info.size)
685+
if (prog->addr >= prog->chip_info.total_size)
685686
{
686687
ERROR_PRINT("Write address 0x%lx is more then chip size 0x%lx\r\n",
687-
prog->addr, prog->chip_info.size);
688+
prog->addr, prog->chip_info.total_size);
688689
return NP_ERR_ADDR_EXCEEDED;
689690
}
690691

@@ -814,10 +815,10 @@ static int _np_cmd_nand_read(np_prog_t *prog)
814815
len = read_cmd->len;
815816
skip_bb = read_cmd->flags.skip_bb;
816817

817-
if (addr + len > prog->chip_info.size)
818+
if (addr + len > prog->chip_info.total_size)
818819
{
819820
ERROR_PRINT("Read address 0x%lx+0x%lx is more then chip size 0x%lx\r\n",
820-
addr, len, prog->chip_info.size);
821+
addr, len, prog->chip_info.total_size);
821822
return NP_ERR_ADDR_EXCEEDED;
822823
}
823824

@@ -851,7 +852,7 @@ static int _np_cmd_nand_read(np_prog_t *prog)
851852

852853
while (len)
853854
{
854-
if (addr >= prog->chip_info.size)
855+
if (addr >= prog->chip_info.total_size)
855856
{
856857
ERROR_PRINT("Read address 0x%lx is more then chip size 0x%lx",
857858
addr, prog->chip_info.page_size);
@@ -865,7 +866,7 @@ static int _np_cmd_nand_read(np_prog_t *prog)
865866
return -1;
866867

867868
/* On partial read do not count bad blocks */
868-
if (read_cmd->len == prog->chip_info.size)
869+
if (read_cmd->len == prog->chip_info.total_size)
869870
len -= prog->chip_info.block_size;
870871
addr += prog->chip_info.block_size;
871872
page.page += prog->chip_info.block_size /
@@ -937,7 +938,8 @@ static int np_cmd_nand_conf(np_prog_t *prog)
937938

938939
prog->chip_info.page_size = conf_cmd->page_size;
939940
prog->chip_info.block_size = conf_cmd->block_size;
940-
prog->chip_info.size = conf_cmd->size;
941+
prog->chip_info.total_size = conf_cmd->total_size;
942+
prog->chip_info.spare_size = conf_cmd->spare_size;
941943
prog->chip_info.setup_time = conf_cmd->setup_time;
942944
prog->chip_info.wait_setup_time = conf_cmd->wait_setup_time;
943945
prog->chip_info.hold_setup_time = conf_cmd->hold_setup_time;
@@ -948,7 +950,8 @@ static int np_cmd_nand_conf(np_prog_t *prog)
948950

949951
DEBUG_PRINT("Page size: %lu\r\n", prog->chip_info.page_size);
950952
DEBUG_PRINT("Block size: %lu\r\n", prog->chip_info.block_size);
951-
DEBUG_PRINT("Size: %lu\r\n", prog->chip_info.size);
953+
DEBUG_PRINT("Total size: %lu\r\n", prog->chip_info.total_size);
954+
DEBUG_PRINT("Spare size: %lu\r\n", prog->chip_info.spare_size);
952955
DEBUG_PRINT("Setup time: %d\r\n", prog->chip_info.setup_time);
953956
DEBUG_PRINT("Wait setup time: %d\r\n", prog->chip_info.wait_setup_time);
954957
DEBUG_PRINT("Hold setup time: %d\r\n", prog->chip_info.hold_setup_time);

qt/chip_db.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ uint32_t ChipDb::sizeGetById(int id)
200200
{
201201
ChipInfo *info = chipInfoGetById(id);
202202

203-
return info ? info->params[CHIP_PARAM_SIZE] : 0;
203+
return info ? info->params[CHIP_PARAM_TOTAL_SIZE] : 0;
204204
}
205205

206206
void ChipDb::addChip(ChipInfo &chipInfo)

qt/chip_db.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ enum
2424
CHIP_PARAM_NAME,
2525
CHIP_PARAM_PAGE_SIZE,
2626
CHIP_PARAM_BLOCK_SIZE,
27-
CHIP_PARAM_SIZE,
27+
CHIP_PARAM_TOTAL_SIZE,
28+
CHIP_PARAM_SPARE_SIZE,
2829
CHIP_PARAM_T_CS,
2930
CHIP_PARAM_T_CLS,
3031
CHIP_PARAM_T_ALS,

qt/chip_db_dialog.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ ChipDbDialog::ChipDbDialog(ChipDb *chipDb, QWidget *parent) : QDialog(parent),
1515
HEADER_LONG_WIDTH);
1616
ui->chipDbTableView->setColumnWidth(CHIP_PARAM_BLOCK_SIZE,
1717
HEADER_LONG_WIDTH);
18-
ui->chipDbTableView->setColumnWidth(CHIP_PARAM_SIZE, HEADER_LONG_WIDTH);
19-
for (int i = CHIP_PARAM_SIZE + 1; i < CHIP_PARAM_NUM; i++)
18+
ui->chipDbTableView->setColumnWidth(CHIP_PARAM_TOTAL_SIZE,
19+
HEADER_LONG_WIDTH);
20+
ui->chipDbTableView->setColumnWidth(CHIP_PARAM_SPARE_SIZE,
21+
HEADER_LONG_WIDTH);
22+
for (int i = CHIP_PARAM_SPARE_SIZE + 1; i < CHIP_PARAM_NUM; i++)
2023
ui->chipDbTableView->setColumnWidth(i, HEADER_SHORT_WIDTH);
2124

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

qt/chip_db_dialog.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<rect>
1010
<x>0</x>
1111
<y>0</y>
12-
<width>1150</width>
12+
<width>1226</width>
1313
<height>600</height>
1414
</rect>
1515
</property>
@@ -21,7 +21,7 @@
2121
</property>
2222
<property name="maximumSize">
2323
<size>
24-
<width>1150</width>
24+
<width>1226</width>
2525
<height>16777215</height>
2626
</size>
2727
</property>

qt/chip_db_table_model.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ QVariant ChipDbTableModel::data(const QModelIndex &index, int role) const
2929
return (*chipDb)[index.row()]->params[CHIP_PARAM_PAGE_SIZE];
3030
case CHIP_PARAM_BLOCK_SIZE:
3131
return (*chipDb)[index.row()]->params[CHIP_PARAM_BLOCK_SIZE];
32-
case CHIP_PARAM_SIZE:
33-
return (*chipDb)[index.row()]->params[CHIP_PARAM_SIZE];
32+
case CHIP_PARAM_TOTAL_SIZE:
33+
return (*chipDb)[index.row()]->params[CHIP_PARAM_TOTAL_SIZE];
34+
case CHIP_PARAM_SPARE_SIZE:
35+
return (*chipDb)[index.row()]->params[CHIP_PARAM_SPARE_SIZE];
3436
case CHIP_PARAM_T_CS:
3537
return (*chipDb)[index.row()]->params[CHIP_PARAM_T_CS];
3638
case CHIP_PARAM_T_CLS:
@@ -74,7 +76,8 @@ QVariant ChipDbTableModel::headerData(int section, Qt::Orientation orientation,
7476
case CHIP_PARAM_NAME: return tr("Name");
7577
case CHIP_PARAM_PAGE_SIZE: return tr("Page size");
7678
case CHIP_PARAM_BLOCK_SIZE: return tr("Block size");
77-
case CHIP_PARAM_SIZE: return tr("Size");
79+
case CHIP_PARAM_TOTAL_SIZE: return tr("Total size");
80+
case CHIP_PARAM_SPARE_SIZE: return tr("Spare size");
7881
case CHIP_PARAM_T_CS: return tr("tCS");
7982
case CHIP_PARAM_T_CLS: return tr("tCLS");
8083
case CHIP_PARAM_T_ALS: return tr("tALS");
@@ -102,8 +105,10 @@ QVariant ChipDbTableModel::headerData(int section, Qt::Orientation orientation,
102105
return tr("Page size in bytes");
103106
case CHIP_PARAM_BLOCK_SIZE:
104107
return tr("Block size in bytes");
105-
case CHIP_PARAM_SIZE:
108+
case CHIP_PARAM_TOTAL_SIZE:
106109
return tr("Total size in bytes");
110+
case CHIP_PARAM_SPARE_SIZE:
111+
return tr("Spare area size in bytes");
107112
case CHIP_PARAM_T_CS:
108113
return tr("Chip enable setup time");
109114
case CHIP_PARAM_T_CLS:
@@ -159,7 +164,8 @@ bool ChipDbTableModel::setData(const QModelIndex &index, const QVariant &value,
159164
return true;
160165
case CHIP_PARAM_PAGE_SIZE:
161166
case CHIP_PARAM_BLOCK_SIZE:
162-
case CHIP_PARAM_SIZE:
167+
case CHIP_PARAM_TOTAL_SIZE:
168+
case CHIP_PARAM_SPARE_SIZE:
163169
case CHIP_PARAM_T_CS:
164170
case CHIP_PARAM_T_CLS:
165171
case CHIP_PARAM_T_ALS:

qt/cmd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ typedef struct __attribute__((__packed__))
6767
Cmd cmd;
6868
uint32_t pageSize;
6969
uint32_t blockSize;
70-
uint32_t size;
70+
uint32_t totalSize;
71+
uint32_t spareSize;
7172
uint8_t setupTime;
7273
uint8_t waitSetupTime;
7374
uint8_t holdSetupTime;

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, pageSize, blockSize, size, tCS, tCLS, tALS, tCLR, tAR, tWP, tRP, tDS, tCH, tCLH, tALH, tWC, tRC, tREA
2-
K9F2G08U0C, 2048, 131072, 268435456, 20, 12, 12, 10, 10, 12, 12, 12, 5, 5, 5, 25, 25, 20
3-
K9F1G08U0E, 2048, 131072, 134217728, 20, 12, 12, 10, 10, 12, 12, 12, 5, 5, 5, 25, 25, 20
1+
# name, pageSize, blockSize, totalSize, spareSize, tCS, tCLS, tALS, tCLR, tAR, tWP, tRP, tDS, tCH, tCLH, tALH, tWC, tRC, tREA
2+
K9F2G08U0C, 2048, 131072, 268435456, 64, 20, 12, 12, 10, 10, 12, 12, 12, 5, 5, 5, 25, 25, 20
3+
K9F1G08U0E, 2048, 131072, 134217728, 64, 20, 12, 12, 10, 10, 12, 12, 12, 5, 5, 5, 25, 25, 20

qt/programmer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ void Programmer::confChip(ChipInfo *chipInfo)
292292
confCmd.cmd.code = CMD_NAND_CONF;
293293
confCmd.pageSize = chipInfo->params[CHIP_PARAM_PAGE_SIZE];
294294
confCmd.blockSize = chipInfo->params[CHIP_PARAM_BLOCK_SIZE];
295-
confCmd.size = chipInfo->params[CHIP_PARAM_SIZE];
295+
confCmd.totalSize = chipInfo->params[CHIP_PARAM_TOTAL_SIZE];
296+
confCmd.spareSize = chipInfo->params[CHIP_PARAM_SPARE_SIZE];
296297
confCmd.setupTime = params.setupTime;
297298
confCmd.waitSetupTime = params.waitSetupTime;
298299
confCmd.holdSetupTime = params.holdSetupTime;

0 commit comments

Comments
 (0)