@@ -210,10 +210,11 @@ struct btnxpuart_dev {
210
210
#define NXP_NAK_V3 0x7b
211
211
#define NXP_CRC_ERROR_V3 0x7c
212
212
213
- /* Bootloader signature error codes */
214
- #define NXP_ACK_RX_TIMEOUT 0x0002 /* ACK not received from host */
215
- #define NXP_HDR_RX_TIMEOUT 0x0003 /* FW Header chunk not received */
216
- #define NXP_DATA_RX_TIMEOUT 0x0004 /* FW Data chunk not received */
213
+ /* Bootloader signature error codes: Refer AN12820 from nxp.com */
214
+ #define NXP_CRC_RX_ERROR BIT(0) /* CRC error in previous packet */
215
+ #define NXP_ACK_RX_TIMEOUT BIT(2) /* ACK not received from host */
216
+ #define NXP_HDR_RX_TIMEOUT BIT(3) /* FW Header chunk not received */
217
+ #define NXP_DATA_RX_TIMEOUT BIT(4) /* FW Data chunk not received */
217
218
218
219
#define HDR_LEN 16
219
220
@@ -316,6 +317,16 @@ union nxp_v3_rx_timeout_nak_u {
316
317
u8 buf [6 ];
317
318
};
318
319
320
+ struct nxp_v3_crc_nak {
321
+ u8 nak ;
322
+ u8 crc ;
323
+ } __packed ;
324
+
325
+ union nxp_v3_crc_nak_u {
326
+ struct nxp_v3_crc_nak pkt ;
327
+ u8 buf [2 ];
328
+ };
329
+
319
330
/* FW dump */
320
331
#define NXP_FW_DUMP_SIZE (1024 * 1000)
321
332
@@ -1089,25 +1100,27 @@ static void nxp_handle_fw_download_error(struct hci_dev *hdev, struct v3_data_re
1089
1100
struct btnxpuart_dev * nxpdev = hci_get_drvdata (hdev );
1090
1101
__u32 offset = __le32_to_cpu (req -> offset );
1091
1102
__u16 err = __le16_to_cpu (req -> error );
1092
- union nxp_v3_rx_timeout_nak_u nak_tx_buf ;
1093
-
1094
- switch (err ) {
1095
- case NXP_ACK_RX_TIMEOUT :
1096
- case NXP_HDR_RX_TIMEOUT :
1097
- case NXP_DATA_RX_TIMEOUT :
1098
- nak_tx_buf .pkt .nak = NXP_NAK_V3 ;
1099
- nak_tx_buf .pkt .offset = __cpu_to_le32 (offset );
1100
- nak_tx_buf .pkt .crc = crc8 (crc8_table , nak_tx_buf .buf ,
1101
- sizeof (nak_tx_buf ) - 1 , 0xff );
1102
- serdev_device_write_buf (nxpdev -> serdev , nak_tx_buf .buf ,
1103
- sizeof (nak_tx_buf ));
1104
- break ;
1105
- default :
1106
- bt_dev_dbg (hdev , "Unknown bootloader error code: %d" , err );
1107
- break ;
1108
-
1103
+ union nxp_v3_rx_timeout_nak_u timeout_nak_buf ;
1104
+ union nxp_v3_crc_nak_u crc_nak_buf ;
1105
+
1106
+ if (err & NXP_CRC_RX_ERROR ) {
1107
+ crc_nak_buf .pkt .nak = NXP_CRC_ERROR_V3 ;
1108
+ crc_nak_buf .pkt .crc = crc8 (crc8_table , crc_nak_buf .buf ,
1109
+ sizeof (crc_nak_buf ) - 1 , 0xff );
1110
+ serdev_device_write_buf (nxpdev -> serdev , crc_nak_buf .buf ,
1111
+ sizeof (crc_nak_buf ));
1112
+ } else if (err & NXP_ACK_RX_TIMEOUT ||
1113
+ err & NXP_HDR_RX_TIMEOUT ||
1114
+ err & NXP_DATA_RX_TIMEOUT ) {
1115
+ timeout_nak_buf .pkt .nak = NXP_NAK_V3 ;
1116
+ timeout_nak_buf .pkt .offset = __cpu_to_le32 (offset );
1117
+ timeout_nak_buf .pkt .crc = crc8 (crc8_table , timeout_nak_buf .buf ,
1118
+ sizeof (timeout_nak_buf ) - 1 , 0xff );
1119
+ serdev_device_write_buf (nxpdev -> serdev , timeout_nak_buf .buf ,
1120
+ sizeof (timeout_nak_buf ));
1121
+ } else {
1122
+ bt_dev_err (hdev , "Unknown bootloader error code: %d" , err );
1109
1123
}
1110
-
1111
1124
}
1112
1125
1113
1126
static int nxp_recv_fw_req_v3 (struct hci_dev * hdev , struct sk_buff * skb )
0 commit comments