File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ typedef struct __attribute__((__packed__))
7070{
7171 cmd_t cmd ;
7272 uint32_t addr ;
73+ uint32_t len ;
7374} write_start_cmd_t ;
7475
7576typedef struct __attribute__((__packed__ ))
@@ -167,6 +168,7 @@ typedef struct
167168{
168169 usb_t usb ;
169170 uint32_t addr ;
171+ uint32_t len ;
170172 int addr_is_valid ;
171173 page_t page ;
172174 uint32_t bytes_written ;
@@ -417,6 +419,7 @@ static int cmd_nand_write_start(prog_t *prog)
417419 }
418420
419421 prog -> addr = write_start_cmd -> addr ;
422+ prog -> len = write_start_cmd -> len ;
420423 prog -> addr_is_valid = 1 ;
421424
422425 prog -> page .page = write_start_cmd -> addr / chip_info -> page_size ;
@@ -552,7 +555,8 @@ static int cmd_nand_write_data(prog_t *prog)
552555 }
553556
554557 prog -> bytes_written += write_data_cmd -> len ;
555- if (prog -> bytes_written - prog -> bytes_ack >= chip_info -> page_size )
558+ if (prog -> bytes_written - prog -> bytes_ack >= chip_info -> page_size ||
559+ prog -> bytes_written == prog -> len )
556560 {
557561 if (send_write_ack (prog -> bytes_written ))
558562 return -1 ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ typedef struct __attribute__((__packed__))
3737{
3838 Cmd cmd;
3939 uint32_t addr;
40+ uint32_t len;
4041} WriteStartCmd;
4142
4243typedef struct __attribute__ ((__packed__))
Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ int Writer::writeStart()
156156
157157 writeStartCmd.cmd .code = CMD_NAND_WRITE_S;
158158 writeStartCmd.addr = addr;
159+ writeStartCmd.len = len;
159160
160161 if (write ((uint8_t *)&writeStartCmd, sizeof (WriteStartCmd)))
161162 return -1 ;
@@ -193,7 +194,7 @@ int Writer::writeData()
193194 bytesWritten += dataLen;
194195 len -= dataLen;
195196
196- if (bytesWritten != pageLim)
197+ if (len && bytesWritten != pageLim)
197198 continue ;
198199
199200 if (readAck (&ack))
You can’t perform that action at this time.
0 commit comments