@@ -1149,3 +1149,148 @@ void um980MenuConstellations()
1149
1149
}
1150
1150
1151
1151
#endif // COMPILE_UM980
1152
+
1153
+ // Check if updateUm980Firmware.txt exists
1154
+ bool checkUpdateUm980Firmware ()
1155
+ {
1156
+ if (online.fs == false )
1157
+ return false ;
1158
+
1159
+ if (LittleFS.exists (" /updateUm980Firmware.txt" ))
1160
+ {
1161
+ if (settings.debugGnss )
1162
+ systemPrintln (" LittleFS updateUm980Firmware.txt exists" );
1163
+
1164
+ // We do not remove the file here. See removeupdateUm980Firmware().
1165
+
1166
+ return true ;
1167
+ }
1168
+
1169
+ return false ;
1170
+ }
1171
+
1172
+ void removeUpdateUm980Firmware ()
1173
+ {
1174
+ if (online.fs == false )
1175
+ return ;
1176
+
1177
+ if (LittleFS.exists (" /updateUm980Firmware.txt" ))
1178
+ {
1179
+ if (settings.debugGnss )
1180
+ systemPrintln (" Removing updateUm980Firmware.txt " );
1181
+
1182
+ LittleFS.remove (" /updateUm980Firmware.txt" );
1183
+ }
1184
+ }
1185
+
1186
+ // Force UART connection to UM980 for firmware update on the next boot by creating updateUm980Firmware.txt in
1187
+ // LittleFS
1188
+ bool createUm980Passthrough ()
1189
+ {
1190
+ if (online.fs == false )
1191
+ return false ;
1192
+
1193
+ if (LittleFS.exists (" /updateUm980Firmware.txt" ))
1194
+ {
1195
+ if (settings.debugGnss )
1196
+ systemPrintln (" LittleFS updateUm980Firmware.txt already exists" );
1197
+ return true ;
1198
+ }
1199
+
1200
+ File updateUm980Firmware = LittleFS.open (" /updateUm980Firmware.txt" , FILE_WRITE);
1201
+ updateUm980Firmware.close ();
1202
+
1203
+ if (LittleFS.exists (" /updateUm980Firmware.txt" ))
1204
+ return true ;
1205
+
1206
+ if (settings.debugGnss )
1207
+ systemPrintln (" Unable to create updateUm980Firmware.txt on LittleFS" );
1208
+ return false ;
1209
+ }
1210
+
1211
+ void beginUm980FirmwareUpdate ()
1212
+ {
1213
+ // Note: We cannot increase the bootloading speed beyond 115200 because
1214
+ // we would need to alter the UM980 baud, then save to NVM, then allow the UM980 to reset.
1215
+ // This is workable, but the next time the RTK Torch resets, it assumes communication at 115200bps
1216
+ // This fails and communication is broken. We could program in some logic that attempts comm at 460800
1217
+ // then reconfigures the UM980 to 115200bps, then resets, but autobaud detection in the UM980 library is
1218
+ // not yet supported.
1219
+
1220
+ // Stop all UART tasks
1221
+ tasksStopGnssUart ();
1222
+
1223
+ systemPrintln ();
1224
+ systemPrintln (" Entering UM980 direct connect for firmware update and configuration. Disconnect this terminal "
1225
+ " connection. Use "
1226
+ " UPrecise to update the firmware. Baudrate: 115200bps. Press the power button to return "
1227
+ " to normal operation." );
1228
+ systemFlush ();
1229
+
1230
+ // Make sure ESP-UART1 is connected to UM980
1231
+ muxSelectUm980 ();
1232
+
1233
+ if (serialGNSS == nullptr )
1234
+ serialGNSS = new HardwareSerial (2 ); // Use UART2 on the ESP32 for communication with the GNSS module
1235
+
1236
+ serialGNSS->begin (115200 , SERIAL_8N1, pin_GnssUart_RX, pin_GnssUart_TX);
1237
+
1238
+ // UPrecise needs to query the device before entering bootload mode
1239
+ // Wait for UPrecise to send bootloader trigger (character T followed by character @) before resetting UM980
1240
+ bool inBootMode = false ;
1241
+
1242
+ // Echo everything to/from UM980
1243
+ while (1 )
1244
+ {
1245
+ // Data coming from UM980 to external USB
1246
+ if (serialGNSS->available ())
1247
+ Serial.write (serialGNSS->read ());
1248
+
1249
+ // Data coming from external USB to UM980
1250
+ if (Serial.available ())
1251
+ {
1252
+ byte incoming = Serial.read ();
1253
+ serialGNSS->write (incoming);
1254
+
1255
+ // Detect bootload sequence
1256
+ if (inBootMode == false && incoming == ' T' )
1257
+ {
1258
+ byte nextIncoming = Serial.peek ();
1259
+ if (nextIncoming == ' @' )
1260
+ {
1261
+ // Reset UM980
1262
+ um980Reset ();
1263
+ delay (25 );
1264
+ um980Boot ();
1265
+
1266
+ inBootMode = true ;
1267
+ }
1268
+ }
1269
+ }
1270
+
1271
+ if (digitalRead (pin_powerButton) == HIGH)
1272
+ {
1273
+ while (digitalRead (pin_powerButton) == HIGH)
1274
+ delay (100 );
1275
+
1276
+ // Remove file and reset to exit pass-through mode
1277
+ removeUpdateUm980Firmware ();
1278
+
1279
+ // Beep to indicate exit
1280
+ beepOn ();
1281
+ delay (300 );
1282
+ beepOff ();
1283
+ delay (100 );
1284
+ beepOn ();
1285
+ delay (300 );
1286
+ beepOff ();
1287
+
1288
+ systemPrintln (" Exiting UM980 passthrough mode" );
1289
+ systemFlush (); // Complete prints
1290
+
1291
+ ESP.restart ();
1292
+ }
1293
+ }
1294
+
1295
+ systemFlush (); // Complete prints
1296
+ }
0 commit comments