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__))
70
70
{
71
71
cmd_t cmd ;
72
72
uint32_t addr ;
73
+ uint32_t len ;
73
74
} write_start_cmd_t ;
74
75
75
76
typedef struct __attribute__((__packed__ ))
@@ -167,6 +168,7 @@ typedef struct
167
168
{
168
169
usb_t usb ;
169
170
uint32_t addr ;
171
+ uint32_t len ;
170
172
int addr_is_valid ;
171
173
page_t page ;
172
174
uint32_t bytes_written ;
@@ -417,6 +419,7 @@ static int cmd_nand_write_start(prog_t *prog)
417
419
}
418
420
419
421
prog -> addr = write_start_cmd -> addr ;
422
+ prog -> len = write_start_cmd -> len ;
420
423
prog -> addr_is_valid = 1 ;
421
424
422
425
prog -> page .page = write_start_cmd -> addr / chip_info -> page_size ;
@@ -552,7 +555,8 @@ static int cmd_nand_write_data(prog_t *prog)
552
555
}
553
556
554
557
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 )
556
560
{
557
561
if (send_write_ack (prog -> bytes_written ))
558
562
return -1 ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ typedef struct __attribute__((__packed__))
37
37
{
38
38
Cmd cmd;
39
39
uint32_t addr;
40
+ uint32_t len;
40
41
} WriteStartCmd;
41
42
42
43
typedef struct __attribute__ ((__packed__))
Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ int Writer::writeStart()
156
156
157
157
writeStartCmd.cmd .code = CMD_NAND_WRITE_S;
158
158
writeStartCmd.addr = addr;
159
+ writeStartCmd.len = len;
159
160
160
161
if (write ((uint8_t *)&writeStartCmd, sizeof (WriteStartCmd)))
161
162
return -1 ;
@@ -193,7 +194,7 @@ int Writer::writeData()
193
194
bytesWritten += dataLen;
194
195
len -= dataLen;
195
196
196
- if (bytesWritten != pageLim)
197
+ if (len && bytesWritten != pageLim)
197
198
continue ;
198
199
199
200
if (readAck (&ack))
You can’t perform that action at this time.
0 commit comments