Skip to content

Commit e6964c9

Browse files
authored
Merge branch 'release_candidate' into repeated-states
2 parents b1cf889 + eded1ed commit e6964c9

38 files changed

+4367
-569
lines changed
1.86 MB
Binary file not shown.

Binaries/readme.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
This folder contains the various firmware versions for RTK Products (Surveyor, Express, Express+, and Facet). Each binary is created by exporting a sketch binary from Arduino. The sketch binary is then uploaded to the ESP32 along with boot_app0.bin, RTK_Surveyor.ino.bootloader.bin, and RTK_Surveyor.ino.partitions.bin. You can update the firmware on a device by loading a binary onto the SD card and inserting it into the RTK Surveyor (see more information [here](https://learn.sparkfun.com/tutorials/sparkfun-rtk-surveyor-hookup-guide/firmware-updates-and-customization)) or by using the following CLI:
1+
This folder contains the various firmware versions for RTK Products (Surveyor, Express, Express+, and Facet).
2+
3+
Updating the firmware can be achieved by using one of the following methods:
4+
5+
* Load the firmware on an SD card, then use a serial terminal with *Firmware Upgrade* menu
6+
* Load the firmware over WiFi when the device is in WiFi AP Config Mode
7+
* Use the [Windows GUI](https://github.com/sparkfun/SparkFun_RTK_Firmware/Uploader_GUI) and a USB cable. (This method is python based which can also be used on Linux, Mac OS, and Raspberry Pi)
8+
* Use the command line *batch_program.bat* (see below)
9+
10+
The SD method is generally recommended. For more information see [here](https://learn.sparkfun.com/tutorials/sparkfun-rtk-surveyor-hookup-guide/firmware-updates-and-customization).
11+
12+
Each binary is created by exporting a sketch binary from Arduino. The sketch binary is then uploaded to the ESP32 along with boot_app0.bin, RTK_Surveyor.ino.bootloader.bin, and RTK_Surveyor.ino.partitions.bin. You can update the firmware on a device by loading a binary onto the SD card and inserting it into the RTK Surveyor ) or by using the included 'batch_program.bat' along with the binary file name and COM port. For example *batch_program.bat RTK_Surveyor_Firmware_v2_0.bin COM3*.
13+
14+
The batch file runs the following commands:
215

316
esptool.exe --chip esp32 --port COM4 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 ./bin/RTK_Surveyor.ino.bootloader.bin 0x8000 ./bin/RTK_Surveyor.ino.partitions.bin 0xe000 ./bin/boot_app0.bin 0x10000 ./RTK_Surveyor_Firmware_vxx.bin
417

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ void beginBoard()
66
{
77
//Use ADC to check 50% resistor divider
88
int pin_adc_rtk_facet = 35;
9-
if (analogReadMilliVolts(pin_adc_rtk_facet) > (3300 / 2 * 0.9) && analogReadMilliVolts(pin_adc_rtk_facet) < (3300 / 2 * 1.1))
9+
uint16_t idValue = analogReadMilliVolts(pin_adc_rtk_facet);
10+
log_d("Board ADC ID: %d", idValue);
11+
12+
if (idValue > (3300 / 2 * 0.9) && idValue < (3300 / 2 * 1.1))
1013
{
1114
productVariant = RTK_FACET;
1215
}
16+
else if (idValue > (3300 * 2 / 3 * 0.9) && idValue < (3300 * 2 / 3 * 1.1))
17+
{
18+
productVariant = RTK_FACET_LBAND;
19+
}
1320
else if (isConnected(0x19) == true) //Check for accelerometer
1421
{
1522
if (zedModuleType == PLATFORM_F9P) productVariant = RTK_EXPRESS;
@@ -77,7 +84,7 @@ void beginBoard()
7784
strcpy(platformPrefix, "Express Plus");
7885
}
7986
}
80-
else if (productVariant == RTK_FACET)
87+
else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND)
8188
{
8289
//v11
8390
pin_muxA = 2;
@@ -113,8 +120,16 @@ void beginBoard()
113120
pinMode(pin_radio_cts, OUTPUT);
114121
digitalWrite(pin_radio_cts, LOW);
115122

116-
strcpy(platformFilePrefix, "SFE_Facet");
117-
strcpy(platformPrefix, "Facet");
123+
if (productVariant == RTK_FACET)
124+
{
125+
strcpy(platformFilePrefix, "SFE_Facet");
126+
strcpy(platformPrefix, "Facet");
127+
}
128+
else if (productVariant == RTK_FACET_LBAND)
129+
{
130+
strcpy(platformFilePrefix, "SFE_Facet_LBand");
131+
strcpy(platformPrefix, "Facet LBand");
132+
}
118133
}
119134

120135
Serial.printf("SparkFun RTK %s v%d.%d-%s\r\n", platformPrefix, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, __DATE__);
@@ -226,11 +241,11 @@ void beginSD()
226241
}
227242

228243
//Setup FAT file access semaphore
229-
if (xFATSemaphore == NULL)
244+
if (sdCardSemaphore == NULL)
230245
{
231-
xFATSemaphore = xSemaphoreCreateMutex();
232-
if (xFATSemaphore != NULL)
233-
xSemaphoreGive(xFATSemaphore); //Make the file system available for use
246+
sdCardSemaphore = xSemaphoreCreateMutex();
247+
if (sdCardSemaphore != NULL)
248+
xSemaphoreGive(sdCardSemaphore); //Make the file system available for use
234249
}
235250

236251
if (createTestFile() == false)
@@ -324,16 +339,14 @@ void stopUART2Tasks()
324339

325340
void beginFS()
326341
{
327-
#define FORMAT_LITTLEFS_IF_FAILED true
328-
329342
if (online.fs == false)
330343
{
331-
Serial.println("Starting FS");
332-
333-
if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)) {
344+
if (!LittleFS.begin(true)) //Format LittleFS if begin fails
345+
{
334346
log_d("Error: LittleFS not online");
335347
return;
336348
}
349+
Serial.println("LittleFS Started");
337350
online.fs = true;
338351
}
339352
}
@@ -354,7 +367,7 @@ void beginDisplay()
354367
{
355368
Serial.println(F("Display not detected"));
356369
}
357-
else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS || productVariant == RTK_FACET)
370+
else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS || productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND)
358371
{
359372
Serial.println(F("Display Error: Not detected."));
360373
}
@@ -579,7 +592,7 @@ void beginSystemState()
579592
setupBtn = new Button(pin_setupButton); //Create the button in memory
580593
powerBtn = new Button(pin_powerSenseAndControl); //Create the button in memory
581594
}
582-
else if (productVariant == RTK_FACET)
595+
else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND)
583596
{
584597
if (online.lband == false)
585598
systemState = settings.lastState; //Return to either Rover or Base Not Started. The last state previous to power down.
@@ -592,8 +605,7 @@ void beginSystemState()
592605
factoryReset();
593606
}
594607

595-
if (systemState == STATE_ROVER_NOT_STARTED)
596-
firstRoverStart = true; //Allow user to enter test screen during first rover start
608+
firstRoverStart = true; //Allow user to enter test screen during first rover start
597609

598610
powerBtn = new Button(pin_powerSenseAndControl); //Create the button in memory
599611
}
@@ -667,9 +679,37 @@ void beginLBand()
667679
return;
668680
}
669681

670-
bool response = true;
682+
if (online.gnss == true)
683+
{
684+
i2cGNSS.checkUblox(); //Regularly poll to get latest data and any RTCM
685+
i2cGNSS.checkCallbacks(); //Process any callbacks: ie, eventTriggerReceived
686+
}
671687

672-
response &= i2cLBand.setVal32(UBLOX_CFG_PMP_CENTER_FREQUENCY, myLBandFreq); // Default 1539812500 Hz
688+
//If we have a fix, check which frequency to use
689+
if (fixType == 2 || fixType == 3 || fixType == 4 || fixType == 5) //2D, 3D, 3D+DR, or Time
690+
{
691+
if ( (longitude > -125 && longitude < -67) && (latitude > -90 && latitude < 90))
692+
{
693+
log_d("Setting LBand to US");
694+
settings.LBandFreq = 1556290000; //We are in US band
695+
}
696+
else if ( (longitude > -25 && longitude < 70) && (latitude > -90 && latitude < 90))
697+
{
698+
log_d("Setting LBand to EU");
699+
settings.LBandFreq = 1545260000; //We are in EU band
700+
}
701+
else
702+
{
703+
Serial.println("Unknown band area");
704+
settings.LBandFreq = 1556290000; //Default to US
705+
}
706+
recordSystemSettings();
707+
}
708+
else
709+
log_d("No fix available for LBand frequency determination");
710+
711+
bool response = true;
712+
response &= i2cLBand.setVal32(UBLOX_CFG_PMP_CENTER_FREQUENCY, settings.LBandFreq); // Default 1539812500 Hz
673713
response &= i2cLBand.setVal16(UBLOX_CFG_PMP_SEARCH_WINDOW, 2200); // Default 2200 Hz
674714
response &= i2cLBand.setVal8(UBLOX_CFG_PMP_USE_SERVICE_ID, 0); // Default 1
675715
response &= i2cLBand.setVal16(UBLOX_CFG_PMP_SERVICE_ID, 21845); // Default 50821

Firmware/RTK_Surveyor/Buttons.ino

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@
33
//Let's make sure they continue to press for 500ms
44
void powerOnCheck()
55
{
6-
#ifdef ENABLE_DEVELOPER
7-
return;
8-
#endif
9-
106
powerPressedStartTime = millis();
7+
if (digitalRead(pin_powerSenseAndControl) == LOW)
8+
delay(500);
119

12-
while (digitalRead(pin_powerSenseAndControl) == LOW)
13-
{
14-
delay(10);
15-
16-
if (millis() - powerPressedStartTime > 500)
17-
break;
18-
}
19-
20-
if (millis() - powerPressedStartTime < 500)
10+
#ifndef ENABLE_DEVELOPER
11+
if (digitalRead(pin_powerSenseAndControl) != LOW)
2112
powerDown(false); //Power button tap. Returning to off state.
13+
#endif
2214

2315
powerPressedStartTime = 0; //Reset var to return to normal 'on' state
2416
}
@@ -31,13 +23,17 @@ void powerDown(bool displayInfo)
3123
{
3224
//Attempt to write to file system. This avoids collisions with file writing from other functions like recordSystemSettingsToFile()
3325
//Wait up to 1000ms
34-
if (xSemaphoreTake(xFATSemaphore, 1000 / portTICK_PERIOD_MS) == pdPASS)
26+
if (xSemaphoreTake(sdCardSemaphore, 1000 / portTICK_PERIOD_MS) == pdPASS)
3527
{
3628
//Close down file system
3729
ubxFile.sync();
3830
ubxFile.close();
39-
//xSemaphoreGive(xFATSemaphore); //Do not release semaphore
40-
} //End xFATSemaphore
31+
//xSemaphoreGive(sdCardSemaphore); //Do not release semaphore
32+
} //End sdCardSemaphore
33+
else
34+
{
35+
Serial.printf("sdCardSemaphore failed to yield, %s line %d\r\n", __FILE__, __LINE__);
36+
}
4137

4238
online.logging = false;
4339
}

0 commit comments

Comments
 (0)