Skip to content

Commit 322a849

Browse files
committed
Aligned size of BB, write ack and error responses
1 parent 167070a commit 322a849

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

firmware/programmer/nand_programmer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ typedef struct __attribute__((__packed__))
157157
chip_id_t nand_id;
158158
} np_resp_id_t;
159159

160+
/* BB, write ack and error responses are aligned to the same size to avoid
161+
* receiver wait for additional data */
160162
typedef struct __attribute__((__packed__))
161163
{
162164
np_resp_t header;
@@ -168,12 +170,14 @@ typedef struct __attribute__((__packed__))
168170
{
169171
np_resp_t header;
170172
uint64_t bytes_ack;
173+
uint8_t dummy[4];
171174
} np_resp_write_ack_t;
172175

173176
typedef struct __attribute__((__packed__))
174177
{
175178
np_resp_t header;
176179
uint8_t err_code;
180+
uint8_t dummy[11];
177181
} np_resp_err_t;
178182

179183
typedef struct __attribute__((__packed__))

qt/cmd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ typedef struct __attribute__((__packed__))
133133
ChipId nandId;
134134
} RespId;
135135

136+
/* BB, write ack and error responses are aligned to the same size to avoid
137+
* receiver wait for additional data */
136138
typedef struct __attribute__((__packed__))
137139
{
138140
RespHeader header;
@@ -144,12 +146,14 @@ typedef struct __attribute__((__packed__))
144146
{
145147
RespHeader header;
146148
uint64_t ackBytes;
149+
uint8_t dummy[4];
147150
} RespWriteAck;
148151

149152
typedef struct __attribute__((__packed__))
150153
{
151154
RespHeader header;
152155
uint8_t errCode;
156+
uint8_t dummy[11];
153157
} RespError;
154158

155159
typedef struct __attribute__((__packed__))

qt/writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ int Writer::writeData()
301301
break;
302302
}
303303

304-
if (read(pbuf, writeDataAckLen))
304+
if (read(pbuf, sizeof(RespWriteAck)))
305305
return -1;
306306

307307
return 0;

qt/writer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class Writer : public QObject
1616
Q_OBJECT
1717

1818
static const uint32_t bufSize = 64;
19-
static const uint32_t writeDataAckLen = 10;
2019

2120
SerialPort *serialPort = nullptr;
2221
QString portName;

0 commit comments

Comments
 (0)