|
134 | 134 | NP_STATUS_ERROR = 0x01, |
135 | 135 | NP_STATUS_BB = 0x02, |
136 | 136 | NP_STATUS_WRITE_ACK = 0x03, |
137 | | - NP_STATUS_BB_SKIP = 0x04, |
| 137 | + NP_STATUS_BB_SKIP = 0x04, |
| 138 | + NP_STATUS_PROGRESS = 0x05, |
138 | 139 | }; |
139 | 140 |
|
140 | 141 | typedef struct __attribute__((__packed__)) |
@@ -162,6 +163,12 @@ typedef struct __attribute__((__packed__)) |
162 | 163 | uint8_t err_code; |
163 | 164 | } np_resp_err_t; |
164 | 165 |
|
| 166 | +typedef struct __attribute__((__packed__)) |
| 167 | +{ |
| 168 | + np_resp_t header; |
| 169 | + uint32_t progress; |
| 170 | +} np_resp_progress_t; |
| 171 | + |
165 | 172 | typedef struct __attribute__((__packed__)) |
166 | 173 | { |
167 | 174 | uint8_t major; |
@@ -250,6 +257,17 @@ static int np_send_bad_block_info(uint32_t addr, uint32_t size, bool is_skipped) |
250 | 257 | return 0; |
251 | 258 | } |
252 | 259 |
|
| 260 | +static int np_send_progress(uint32_t progress) |
| 261 | +{ |
| 262 | + np_resp_t resp_header = { NP_RESP_STATUS, NP_STATUS_PROGRESS }; |
| 263 | + np_resp_progress_t resp_progress = { resp_header, progress }; |
| 264 | + |
| 265 | + if (np_comm_cb->send((uint8_t *)&resp_progress, sizeof(resp_progress))) |
| 266 | + return -1; |
| 267 | + |
| 268 | + return 0; |
| 269 | +} |
| 270 | + |
253 | 271 | static int _np_cmd_nand_read_id(np_prog_t *prog) |
254 | 272 | { |
255 | 273 | np_resp_id_t resp; |
@@ -379,11 +397,11 @@ static int np_nand_erase(np_prog_t *prog, uint32_t page) |
379 | 397 | static int _np_cmd_nand_erase(np_prog_t *prog) |
380 | 398 | { |
381 | 399 | int ret; |
382 | | - uint32_t addr, page, pages_in_block, len; |
| 400 | + uint32_t addr, page, pages_in_block, len, total_len; |
383 | 401 | np_erase_cmd_t *erase_cmd = (np_erase_cmd_t *)prog->rx_buf; |
384 | 402 | bool is_bad = false, skip_bb = erase_cmd->flags.skip_bb; |
385 | 403 |
|
386 | | - len = erase_cmd->len; |
| 404 | + total_len = len = erase_cmd->len; |
387 | 405 | addr = erase_cmd->addr; |
388 | 406 |
|
389 | 407 | DEBUG_PRINT("Erase at 0x%lx %lx bytes command\r\n", addr, len); |
@@ -445,6 +463,8 @@ static int _np_cmd_nand_erase(np_prog_t *prog) |
445 | 463 | /* On partial erase do not count bad blocks */ |
446 | 464 | if (!is_bad || (is_bad && erase_cmd->len == prog->chip_info.size)) |
447 | 465 | len -= prog->chip_info.block_size; |
| 466 | + |
| 467 | + np_send_progress(total_len - len); |
448 | 468 | } |
449 | 469 |
|
450 | 470 | return np_send_ok_status(); |
|
0 commit comments