43
43
#include "debug.h"
44
44
#include "deck.h"
45
45
#include "esp_deck_flasher.h"
46
- #include "FreeRTOS.h"
47
46
#include "task.h"
48
47
#include "event_groups.h"
49
48
#include "queue.h"
@@ -78,6 +77,9 @@ static bool isInit = false;
78
77
79
78
#define CPX_ENABLE_CRTP_BRIDGE 0x10
80
79
80
+ #define GAP8_MAX_MEM_WRITE_TIMEOUT_MS 5000
81
+ #define GAP8_MAX_MEM_VERIFY_TIMEOUT_MS 5000
82
+
81
83
typedef struct {
82
84
uint8_t cmd ;
83
85
uint32_t startAddress ;
@@ -126,7 +128,8 @@ static bool gap8DeckFlasherWrite(const uint32_t memAddr, const uint8_t writeLen,
126
128
gap8BlPacket -> startAddress = 0x40000 ;
127
129
gap8BlPacket -> writeSize = * (memDef -> newFwSizeP );
128
130
bootPacket .dataLength = sizeof (GAP8BlCmdPacket_t );
129
- cpxSendPacketBlocking (& bootPacket );
131
+ bool writeOk = cpxSendPacketBlockingTimeout (& bootPacket , M2T (GAP8_MAX_MEM_WRITE_TIMEOUT_MS ));
132
+ ASSERT (writeOk );
130
133
}
131
134
132
135
// The GAP8 can only flash data in multiples of 4 bytes,
@@ -144,7 +147,8 @@ static bool gap8DeckFlasherWrite(const uint32_t memAddr, const uint8_t writeLen,
144
147
memcpy (& bootPacket .data , flashBuffer , flashBufferIndex );
145
148
bootPacket .dataLength = flashBufferIndex ;
146
149
147
- cpxSendPacketBlocking (& bootPacket );
150
+ bool writeOk = cpxSendPacketBlockingTimeout (& bootPacket , M2T (GAP8_MAX_MEM_WRITE_TIMEOUT_MS ));
151
+ ASSERT (writeOk );
148
152
149
153
flashBufferIndex = 0 ;
150
154
int sizeLeftToBuffer = writeLen - sizeLeftToBufferFull ;
@@ -163,13 +167,16 @@ static bool gap8DeckFlasherWrite(const uint32_t memAddr, const uint8_t writeLen,
163
167
gap8BlPacket -> startAddress = 0x40000 ;
164
168
gap8BlPacket -> writeSize = * (memDef -> newFwSizeP );
165
169
bootPacket .dataLength = sizeof (GAP8BlCmdPacket_t );
166
- cpxSendPacketBlocking (& bootPacket );
170
+ bool writeOk = cpxSendPacketBlockingTimeout (& bootPacket , M2T (GAP8_MAX_MEM_WRITE_TIMEOUT_MS ));
171
+ ASSERT (writeOk );
167
172
168
- xEventGroupWaitBits (bootloaderSync ,
173
+ EventBits_t bits = xEventGroupWaitBits (bootloaderSync ,
169
174
CPX_WAIT_FOR_BOOTLOADER_REPLY ,
170
175
pdTRUE , // Clear bits before returning
171
176
pdFALSE , // Wait for any bit
172
- portMAX_DELAY );
177
+ M2T (GAP8_MAX_MEM_VERIFY_TIMEOUT_MS ));
178
+ bool flashWritten = (bits & CPX_WAIT_FOR_BOOTLOADER_REPLY );
179
+ ASSERT (flashWritten );
173
180
}
174
181
175
182
return true;
0 commit comments