Compiling Source
This is information about how to compile the RTK Everywhere firmware from source. This is for advanced users who would like to modify the functionality of the RTK products.
Windows
The SparkFun RTK Everywhere Firmware is compiled using Arduino CLI (currently v0.35.3). To compile:
-
Install Arduino CLI.
-
Install the ESP32 core for Arduino:
arduino-cli core install esp32:esp32@3.0.1
Note: Use v3.0.1 of the core.
Note: We use the 'ESP32 Dev Module' for pin numbering.
-
Obtain each of the libraries listed in the workflow either by using git or the Arduino CLI library manager. Be sure to obtain the version of the library reflected in the workflow. Be sure to include the external libraries (You may have to enable external library support in the CLI).
-
RTK Everywhere uses a custom partition file. Download the RTKEverywhere.csv file.
-
Add RTKEverywhere.csv partition table to the Arduino partitions folder. It should look something like
C:\Users\\[user name]\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\tools\partitions\RTKEverywhere.csv
This will increase the program partitions, as well as the SPIFFs partition to utilize the full 16MB of flash.
-
Compile using the following command
arduino-cli compile 'Firmware/RTK_Everywhere' --build-property build.partitions=RTKEverywhere --build-property upload.maximum_size=3145728 --fqbn esp32:esp32:esp32:FlashSize=16M,PSRAM=enabled
-
Once compiled, upload to the device using the following command where
[COM_PORT]
is the COM port on which the RTK device is located (ieCOM42
).arduino-cli upload -p [COM_PORT] --fqbn esp32:esp32:esp32:UploadSpeed=512000,FlashSize=16M 'Firmware/RTK_Everywhere'
If you are seeing the error:
text section exceeds available space ...
You have either not replaced the partition file correctly or failed to include the 'upload.maximum_size' argument in your compile command. See steps 4 through 6 above.
Note: There are a variety of compile guards (COMPILE_WIFI, COMPILE_AP, etc) at the top of RTK_Everywhere.ino that can be commented out to remove them from compilation. This will greatly reduce the firmware size and allow for faster development of functions that do not rely on these features (serial menus, system configuration, logging, etc).
Ubuntu 20.04
Virtual Machine
Execute the following commands to create the Linux virtual machine:
-
Using a browser, download the Ubuntu 20.04 Desktop image
-
virtualbox
- Click on the new button
- Specify the machine Name, e.g.: Sparkfun_RTK_20.04
- Select Type: Linux
- Select Version: Ubuntu (64-bit)
- Click the Next> button
- Select the memory size: 7168
- Click the Next> button
- Click on Create a virtual hard disk now
- Click the Create button
- Select VDI (VirtualBox Disk Image)
- Click the Next> button
- Select Dynamically allocated
- Click the Next> button
- Select the disk size: 128 GB
- Click the Create button
- Click on Storage
- Click the empty CD icon
- On the right-hand side, click the CD icon
- Click on Choose a disk file...
- Choose the ubuntu-20.04... iso file
- Click the Open button
- Click on Network
- Under 'Attached to:' select Bridged Adapter
- Click the OK button
- Click the Start button
-
Install Ubuntu 20.04
-
Log into Ubuntu
-
Click on Activities
-
Type terminal into the search box
-
Optionally install the SSH server
-
In the terminal window
- sudo apt install -y net-tools openssh-server
- ifconfig
Write down the IP address
-
On the PC
- ssh-keygen -t rsa -f ~/.ssh/Sparkfun_RTK_20.04
- ssh-copy-id -o IdentitiesOnly=yes -i ~/.ssh/Sparkfun_RTK_20.04 <username>@<IP address>
- ssh -Y <username>@<IP address>
-
Build Environment
Execute the following commands to create the build environment for the SparkFun RTK Everywhere Firmware:
- sudo adduser $USER dialout
-
sudo shutdown -r 0
Reboot to ensure that the dialout privilege is available to the user
-
sudo apt update
- sudo apt install -y git gitk git-cola minicom python3-pip
- sudo pip3 install pyserial
- mkdir ~/SparkFun
- mkdir ~/SparkFun/esptool
- cd ~/SparkFun/esptool
- git clone https://github.com/espressif/esptool .
- cd ~/SparkFun
-
nano serial-port.sh
Insert the following text into the file:
-
chmod +x serial-port.sh
-
nano new-firmware.sh
Insert the following text into the file:
#!/bin/bash # new-firmware.sh # # Shell script to load firmware into the RTK Express via the ESP32 port # # Parameters: # 1: ttyUSBn # 2: Firmware file # sudo python3 ~/SparkFun/RTK_Binaries/Uploader_GUI/esptool.py --chip esp32 --port /dev/$1 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect \ 0x1000 ~/SparkFun/RTK_Binaries/bin/RTK_Surveyor.ino.bootloader.bin \ 0x8000 ~/SparkFun/RTK_Binaries/bin/RTK_Surveyor_Partitions_16MB.bin \ 0xe000 ~/SparkFun/RTK_Binaries/bin/boot_app0.bin \ 0x10000 $2
-
chmod +x new-firmware.sh
-
nano new-firmware-4mb.sh
Insert the following text into the file:
#!/bin/bash # new-firmware-4mb.sh # # Shell script to load firmware into the 4MB RTK Express via the ESP32 port # # Parameters: # 1: ttyUSBn # 2: Firmware file # sudo python3 ~/SparkFun/RTK_Binaries/Uploader_GUI/esptool.py --chip esp32 --port /dev/$1 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect \ 0x1000 ~/SparkFun/RTK_Binaries/bin/RTK_Surveyor.ino.bootloader.bin \ 0x8000 ~/SparkFun/RTK_Binaries/bin/RTK_Surveyor_Partitions_4MB.bin \ 0xe000 ~/SparkFun/RTK_Binaries/bin/boot_app0.bin \ 0x10000 $2
-
chmod +x new-firmware-4mb.sh
Get the SparkFun RTK Everywhere Firmware sources
-
mkdir ~/SparkFun/RTK
- cd ~/SparkFun/RTK
-
git clone https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware .
Get the SparkFun RTK binaries
-
mkdir ~/SparkFun/RTK_Binaries
- cd ~/SparkFun/RTK_Binaries
-
git clone https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware_Binaries.git .
Install the Arduino IDE
-
mkdir ~/SparkFun/arduino
- cd ~/SparkFun/arduino
- wget https://downloads.arduino.cc/arduino-1.8.15-linux64.tar.xz
- tar -xvf ./arduino-1.8.15-linux64.tar.xz
- cd arduino-1.8.15/
-
sudo ./install.sh
Add the ESP32 support
-
Arduino
- Click on File in the menu bar
- Click on Preferences
- Go down to the Additional Boards Manager URLs text box
- Only if the textbox already has a value, go to the end of the value or values and add a comma
- Add the link: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- Note the value in Sketchbook location
- Click the OK button
- Click on File in the menu bar
- Click on Quit
Get the required external libraries, then add to the Sketchbook location from above
-
cd ~/Arduino/libraries
- mkdir AsyncTCP
- cd AsyncTCP/
- git clone https://github.com/me-no-dev/AsyncTCP.git .
- cd ..
- mkdir ESPAsyncWebServer
- cd ESPAsyncWebServer
-
git clone https://github.com/me-no-dev/ESPAsyncWebServer .
Connect the Config ESP32 port of the RTK to a USB port on the computer
-
ls /dev/ttyUSB*
Enable the libraries in the Arduino IDE
-
Arduino
- From the menu, click on File
- Click on Open...
- Select the ~/SparkFun/RTK/Firmware/RTK_Surveyor/RTK_Surveyor.ino file
- Click on the Open button
Select the ESP32 development module
- From the menu, click on Tools
- Click on Board
- Click on Board Manager…
- Click on esp32
- Select version 2.0.2
- Click on the Install button in the lower right
- Close the Board Manager...
- From the menu, click on Tools
- Click on Board
- Click on ESP32 Arduino
- Click on ESP32 Dev Module
Load the required libraries
- From the menu, click on Tools
- Click on Manage Libraries…
-
For each of the following libraries:
- Locate the library
- Click on the library
- Select the version listed in the compile-rtk-firmware.yml file for the main or the release_candidate branch
- Click on the Install button in the lower right
Library List:
- ArduinoJson
- ESP32Time
- ESP32-OTA-Pull
- ESP32_BleSerial
- Ethernet
- JC_Button
- MAX17048 - Used for “Test Sketch/Batt_Monitor”
- PubSubClient
- SdFat
- SparkFun LIS2DH12 Arduino Library
- SparkFun MAX1704x Fuel Gauge Arduino Library
- SparkFun Qwiic OLED Graphics Library
- SparkFun u-blox GNSS v3
- SparkFun_WebServer_ESP32_W5500
-
Click on the Close button
Select the terminal port
- From the menu, click on Tools
- Click on Port, Select the port that was displayed in step 38 above
- Select /dev/ttyUSB0
- Click on Upload Speed
- Select 230400
Setup the partitions for the 16 MB flash
- From the menu, click on Tools
- Click on Flash Size
- Select 16MB
- From the menu, click on Tools
- Click on Partition Scheme
- Click on 16M Flash (3MB APP/9MB FATFS)
- From the menu click on File
- Click on Quit
-
cd ~/SparkFun/RTK/
- cp Firmware/app3M_fat9M_16MB.csv ~/.arduino15/packages/esp32/hardware/esp32/2.0.2/tools/partitions/app3M_fat9M_16MB.csv