Skip to content

Commit

Permalink
Aligned size of BB, write ack and error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
bbogush committed May 14, 2023
1 parent 167070a commit 322a849
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions firmware/programmer/nand_programmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ typedef struct __attribute__((__packed__))
chip_id_t nand_id;
} np_resp_id_t;

/* BB, write ack and error responses are aligned to the same size to avoid
* receiver wait for additional data */
typedef struct __attribute__((__packed__))
{
np_resp_t header;
Expand All @@ -168,12 +170,14 @@ typedef struct __attribute__((__packed__))
{
np_resp_t header;
uint64_t bytes_ack;
uint8_t dummy[4];
} np_resp_write_ack_t;

typedef struct __attribute__((__packed__))
{
np_resp_t header;
uint8_t err_code;
uint8_t dummy[11];
} np_resp_err_t;

typedef struct __attribute__((__packed__))
Expand Down
4 changes: 4 additions & 0 deletions qt/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ typedef struct __attribute__((__packed__))
ChipId nandId;
} RespId;

/* BB, write ack and error responses are aligned to the same size to avoid
* receiver wait for additional data */
typedef struct __attribute__((__packed__))
{
RespHeader header;
Expand All @@ -144,12 +146,14 @@ typedef struct __attribute__((__packed__))
{
RespHeader header;
uint64_t ackBytes;
uint8_t dummy[4];
} RespWriteAck;

typedef struct __attribute__((__packed__))
{
RespHeader header;
uint8_t errCode;
uint8_t dummy[11];
} RespError;

typedef struct __attribute__((__packed__))
Expand Down
2 changes: 1 addition & 1 deletion qt/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ int Writer::writeData()
break;
}

if (read(pbuf, writeDataAckLen))
if (read(pbuf, sizeof(RespWriteAck)))
return -1;

return 0;
Expand Down
1 change: 0 additions & 1 deletion qt/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Writer : public QObject
Q_OBJECT

static const uint32_t bufSize = 64;
static const uint32_t writeDataAckLen = 10;

SerialPort *serialPort = nullptr;
QString portName;
Expand Down

0 comments on commit 322a849

Please sign in to comment.