diff --git a/.github/workflows/compile-rtk-everywhere.yml b/.github/workflows/compile-rtk-everywhere.yml index 3f627c956..e17b5047e 100644 --- a/.github/workflows/compile-rtk-everywhere.yml +++ b/.github/workflows/compile-rtk-everywhere.yml @@ -7,10 +7,6 @@ env: FILENAME_PREFIX: RTK_Everywhere_Firmware FIRMWARE_VERSION_MAJOR: 2 FIRMWARE_VERSION_MINOR: 3 - POINTPERFECT_LBAND_TOKEN: ${{ secrets.POINTPERFECT_LBAND_TOKEN }} - POINTPERFECT_IP_TOKEN: ${{ secrets.POINTPERFECT_IP_TOKEN }} - POINTPERFECT_LBAND_IP_TOKEN: ${{ secrets.POINTPERFECT_LBAND_IP_TOKEN }} - POINTPERFECT_RTCM_TOKEN: ${{ secrets.POINTPERFECT_RTCM_TOKEN }} CORE_VERSION: 3.0.7 jobs: @@ -54,124 +50,49 @@ jobs: echo "DEBUG_LEVEL=error" >> "$GITHUB_ENV" fi - - name: Setup Arduino CLI - uses: arduino/setup-arduino-cli@v1 - - - name: Start config file - run: arduino-cli config init --additional-urls "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json" - - - name: Update core index - run: arduino-cli core update-index - - - name: Update library index - run: arduino-cli lib update-index - - - name: Install platform - run: arduino-cli core install esp32:esp32@${{ env.CORE_VERSION }} - - - name: Get IDF version - run: | - cd /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs - IDF_VERSION=$(ls | grep idf-release) - echo "ESP_IDF=${IDF_VERSION}" >> "$GITHUB_ENV" - - - name: Get Known Libraries - run: arduino-cli lib install - ArduinoJson@7.0.4 - ESP32Time@2.0.0 - ESP32_BleSerial@2.0.1 - "ESP32-OTA-Pull"@1.0.0 - JC_Button@2.1.2 - PubSubClient@2.8.0 - "SdFat"@2.1.1 - "SparkFun LIS2DH12 Arduino Library"@1.0.3 - "SparkFun MAX1704x Fuel Gauge Arduino Library"@1.0.4 - "SparkFun u-blox GNSS v3"@3.1.10 - "SparkFun Qwiic OLED Arduino Library"@1.0.13 - SSLClientESP32@2.0.0 - "SparkFun Extensible Message Parser"@1.0.4 - "SparkFun BQ40Z50 Battery Manager Arduino Library"@1.0.0 - "ArduinoMqttClient"@0.1.8 - "SparkFun u-blox PointPerfect Library"@1.11.4 - "SparkFun IM19 IMU Arduino Library"@1.0.1 - "SparkFun UM980 Triband RTK GNSS Arduino Library"@1.0.5 - "SparkFun LG290P Quadband RTK GNSS Arduino Library"@1.0.8 - "SparkFun I2C Expander Arduino Library"@1.0.1 - "SparkFun Apple Accessory Arduino Library"@3.0.9 - "SparkFun Authentication Coprocessor Arduino Library"@1.0.0 - "SparkFun Toolkit"@1.0.6 - - - name: Patch libmbedtls + - name: Run Dockerfile and copy files + # The --quiet suppresses the build output, keeping the secrets safe run: | - cd Firmware/RTK_Everywhere/Patch/ - cp libmbedtls.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libmbedtls.a - cp libmbedtls_2.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libmbedtls_2.a - cp libmbedcrypto.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libmbedcrypto.a - cp libmbedx509.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libmbedx509.a - - - name: Patch NetworkEvents - run: | - cd Firmware/RTK_Everywhere/Patch/ - cp NetworkEvents.* /home/runner/.arduino15/packages/esp32/hardware/esp32/${{ env.CORE_VERSION }}/libraries/Network/src/ - - - name: Patch libbt - run: | - cd Firmware/RTK_Everywhere/Patch/ - cp libbt.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libbt.a - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - # Configure Python - now we have Python installed, we need to provide everything needed by esptool otherwise the compile fails - - name: Configure Python - run: | - pip3 install pyserial - - - name: Update index_html - run: | - cd Firmware/Tools - python index_html_zipper.py ../RTK_Everywhere/AP-Config/index.html ../RTK_Everywhere/form.h - - - name: Update main_js - run: | - cd Firmware/Tools - python main_js_zipper.py ../RTK_Everywhere/AP-Config/src/main.js ../RTK_Everywhere/form.h + cd ./Firmware + echo "*** The docker build is quiet to protect the GitHub secrets ***" + docker build -t rtk_everywhere_firmware --no-cache --quiet \ + --build-arg CORE_VERSION=${{ env.CORE_VERSION }} \ + --build-arg FIRMWARE_VERSION_MAJOR=${{ env.FIRMWARE_VERSION_MAJOR }} \ + --build-arg FIRMWARE_VERSION_MINOR=${{ env.FIRMWARE_VERSION_MINOR }} \ + --build-arg POINTPERFECT_LBAND_TOKEN="${{ secrets.POINTPERFECT_LBAND_TOKEN }}" \ + --build-arg POINTPERFECT_IP_TOKEN="${{ secrets.POINTPERFECT_IP_TOKEN }}" \ + --build-arg POINTPERFECT_LBAND_IP_TOKEN="${{ secrets.POINTPERFECT_LBAND_IP_TOKEN }}" \ + --build-arg POINTPERFECT_RTCM_TOKEN="${{ secrets.POINTPERFECT_RTCM_TOKEN }}" \ + --build-arg ENABLE_DEVELOPER=${{ env.ENABLE_DEVELOPER }} \ + --build-arg DEBUG_LEVEL=${{ env.DEBUG_LEVEL }} \ + . + docker create --name=rtk_everywhere rtk_everywhere_firmware:latest + mkdir ./build + docker cp rtk_everywhere:/RTK_Everywhere.ino.bin ./build + docker cp rtk_everywhere:/RTK_Everywhere.ino.elf ./build + docker cp rtk_everywhere:/RTK_Everywhere/form.h ./RTK_Everywhere + docker container rm rtk_everywhere - name: Commit and push form.h - uses: actions-js/push@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - directory: ./Firmware/RTK_Everywhere - branch: ${{ env.BRANCH }} - message: 'Update form.h via Python' - - - name: Copy custom RTKEverywhere.csv - run: - # Compile the source using the 16MB partition file. Other platforms (ie, the 8MB Postcard) use - # the same binary but use a different partition binary during the upload phase. - # View the different RTK partition files used during upload here: - # https://github.com/sparkfun/SparkFun_RTK_Firmware_Uploader/tree/main/RTK_Firmware_Uploader/resource - cp Firmware/RTKEverywhere.csv /home/runner/.arduino15/packages/esp32/hardware/esp32/${{ env.CORE_VERSION }}/tools/partitions/RTKEverywhere.csv - - - name: Compile Sketch - run: arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${{ env.DEBUG_LEVEL }},PSRAM=enabled ./Firmware/RTK_Everywhere/RTK_Everywhere.ino - --build-property build.partitions=RTKEverywhere - --build-property upload.maximum_size=4055040 - --build-property "compiler.cpp.extra_flags=-MMD -c \"-DPOINTPERFECT_LBAND_TOKEN=$POINTPERFECT_LBAND_TOKEN\" \"-DPOINTPERFECT_IP_TOKEN=$POINTPERFECT_IP_TOKEN\" \"-DPOINTPERFECT_LBAND_IP_TOKEN=$POINTPERFECT_LBAND_IP_TOKEN\" \"-DPOINTPERFECT_RTCM_TOKEN=$POINTPERFECT_RTCM_TOKEN\" \"-DFIRMWARE_VERSION_MAJOR=$FIRMWARE_VERSION_MAJOR\" \"-DFIRMWARE_VERSION_MINOR=$FIRMWARE_VERSION_MINOR\" \"-DENABLE_DEVELOPER=${{ env.ENABLE_DEVELOPER }}\"" - --export-binaries + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add ./Firmware/RTK_Everywhere/form.h + git commit -m "Update form.h via Python" + git push origin ${{ env.BRANCH }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Rename binary run: | - cd Firmware/RTK_Everywhere/build/esp32.esp32.esp32/ + cd ./Firmware/build mv RTK_Everywhere.ino.bin ${{ env.FILENAME_PREFIX }}${{ env.FILE_ENDING_UNDERSCORE }}.bin - name: Upload binary to action uses: actions/upload-artifact@v4 with: name: ${{ env.FILENAME_PREFIX }}${{ env.FILE_ENDING_UNDERSCORE }} - path: ./Firmware/RTK_Everywhere/build/esp32.esp32.esp32/${{ env.FILENAME_PREFIX }}${{ env.FILE_ENDING_UNDERSCORE }}.bin + path: ./Firmware/build/${{ env.FILENAME_PREFIX }}${{ env.FILE_ENDING_UNDERSCORE }}.bin - name: Push binary to Binaries Repo @@ -180,7 +101,7 @@ jobs: env: API_TOKEN_GITHUB: ${{ secrets.PUSH_BINARIES_REPO }} with: - source_file: ./Firmware/RTK_Everywhere/build/esp32.esp32.esp32/${{ env.FILENAME_PREFIX }}${{ env.FILE_ENDING_UNDERSCORE }}.bin + source_file: ./Firmware/build/${{ env.FILENAME_PREFIX }}${{ env.FILE_ENDING_UNDERSCORE }}.bin destination_repo: 'sparkfun/SparkFun_RTK_Everywhere_Firmware_Binaries' destination_folder: '' user_email: 'nathan@sparkfun.com' diff --git a/.github/workflows/non-release-build.yml b/.github/workflows/non-release-build.yml index 2c544a485..8802349b5 100644 --- a/.github/workflows/non-release-build.yml +++ b/.github/workflows/non-release-build.yml @@ -7,10 +7,6 @@ env: FILENAME_PREFIX: RTK_Everywhere_Firmware FIRMWARE_VERSION_MAJOR: 99 FIRMWARE_VERSION_MINOR: 99 - POINTPERFECT_LBAND_TOKEN: ${{ secrets.POINTPERFECT_LBAND_TOKEN }} - POINTPERFECT_IP_TOKEN: ${{ secrets.POINTPERFECT_IP_TOKEN }} - POINTPERFECT_LBAND_IP_TOKEN: ${{ secrets.POINTPERFECT_LBAND_IP_TOKEN }} - POINTPERFECT_RTCM_TOKEN: ${{ secrets.POINTPERFECT_RTCM_TOKEN }} CORE_VERSION: 3.0.7 jobs: @@ -54,110 +50,38 @@ jobs: echo "DEBUG_LEVEL=error" >> "$GITHUB_ENV" fi - - name: Setup Arduino CLI - uses: arduino/setup-arduino-cli@v1 - - - name: Start config file - run: arduino-cli config init --additional-urls "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json" - - - name: Update core index - run: arduino-cli core update-index - - - name: Update library index - run: arduino-cli lib update-index - - - name: Install platform - run: arduino-cli core install esp32:esp32@${{ env.CORE_VERSION }} - - - name: Get IDF version - run: | - cd /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs - IDF_VERSION=$(ls | grep idf-release) - echo "ESP_IDF=${IDF_VERSION}" >> "$GITHUB_ENV" - - - name: Get Known Libraries - run: arduino-cli lib install - ArduinoJson@7.0.4 - ESP32Time@2.0.0 - ESP32_BleSerial@2.0.1 - "ESP32-OTA-Pull"@1.0.0 - JC_Button@2.1.2 - PubSubClient@2.8.0 - "SdFat"@2.1.1 - "SparkFun LIS2DH12 Arduino Library"@1.0.3 - "SparkFun MAX1704x Fuel Gauge Arduino Library"@1.0.4 - "SparkFun u-blox GNSS v3"@3.1.10 - "SparkFun Qwiic OLED Arduino Library"@1.0.13 - SSLClientESP32@2.0.0 - "SparkFun Extensible Message Parser"@1.0.4 - "SparkFun BQ40Z50 Battery Manager Arduino Library"@1.0.0 - "ArduinoMqttClient"@0.1.8 - "SparkFun u-blox PointPerfect Library"@1.11.4 - "SparkFun IM19 IMU Arduino Library"@1.0.1 - "SparkFun UM980 Triband RTK GNSS Arduino Library"@1.0.5 - "SparkFun LG290P Quadband RTK GNSS Arduino Library"@1.0.8 - "SparkFun I2C Expander Arduino Library"@1.0.1 - "SparkFun Apple Accessory Arduino Library"@3.0.9 - "SparkFun Authentication Coprocessor Arduino Library"@1.0.0 - "SparkFun Toolkit"@1.0.6 - - - name: Patch libmbedtls - run: | - cd Firmware/RTK_Everywhere/Patch/ - cp libmbedtls.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libmbedtls.a - cp libmbedtls_2.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libmbedtls_2.a - cp libmbedcrypto.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libmbedcrypto.a - cp libmbedx509.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libmbedx509.a - - - name: Patch NetworkEvents - run: | - cd Firmware/RTK_Everywhere/Patch/ - cp NetworkEvents.* /home/runner/.arduino15/packages/esp32/hardware/esp32/${{ env.CORE_VERSION }}/libraries/Network/src/ - - - name: Patch libbt + - name: Run Dockerfile and copy files + # The --quiet suppresses the build output, keeping the secrets safe run: | - cd Firmware/RTK_Everywhere/Patch/ - cp libbt.a /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs/${{ env.ESP_IDF }}/esp32/lib/libbt.a - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - # Configure Python - now we have Python installed, we need to provide everything needed by esptool otherwise the compile fails - - name: Configure Python - run: | - pip3 install pyserial - - - name: Update index_html - run: | - cd Firmware/Tools - python index_html_zipper.py ../RTK_Everywhere/AP-Config/index.html ../RTK_Everywhere/form.h - - - name: Update main_js - run: | - cd Firmware/Tools - python main_js_zipper.py ../RTK_Everywhere/AP-Config/src/main.js ../RTK_Everywhere/form.h + cd ./Firmware + echo "*** The docker build is quiet to protect the GitHub secrets ***" + docker build -t rtk_everywhere_firmware --no-cache --quiet \ + --build-arg CORE_VERSION=${{ env.CORE_VERSION }} \ + --build-arg FIRMWARE_VERSION_MAJOR=${{ env.FIRMWARE_VERSION_MAJOR }} \ + --build-arg FIRMWARE_VERSION_MINOR=${{ env.FIRMWARE_VERSION_MINOR }} \ + --build-arg POINTPERFECT_LBAND_TOKEN="${{ secrets.POINTPERFECT_LBAND_TOKEN }}" \ + --build-arg POINTPERFECT_IP_TOKEN="${{ secrets.POINTPERFECT_IP_TOKEN }}" \ + --build-arg POINTPERFECT_LBAND_IP_TOKEN="${{ secrets.POINTPERFECT_LBAND_IP_TOKEN }}" \ + --build-arg POINTPERFECT_RTCM_TOKEN="${{ secrets.POINTPERFECT_RTCM_TOKEN }}" \ + --build-arg ENABLE_DEVELOPER=${{ env.ENABLE_DEVELOPER }} \ + --build-arg DEBUG_LEVEL=${{ env.DEBUG_LEVEL }} \ + . + docker create --name=rtk_everywhere rtk_everywhere_firmware:latest + mkdir ./build + docker cp rtk_everywhere:/RTK_Everywhere.ino.bin ./build + docker cp rtk_everywhere:/RTK_Everywhere.ino.elf ./build + docker cp rtk_everywhere:/RTK_Everywhere/form.h ./RTK_Everywhere + docker container rm rtk_everywhere - name: Commit and push form.h - uses: actions-js/push@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - directory: ./Firmware/RTK_Everywhere - branch: ${{ env.BRANCH }} - message: 'Update form.h via Python' - - - name: Copy custom RTKEverywhere.csv - run: - # Use the 16MB partitions by default. 8MB (Postcard) partitions must be compiled separately - cp Firmware/RTKEverywhere.csv /home/runner/.arduino15/packages/esp32/hardware/esp32/${{ env.CORE_VERSION }}/tools/partitions/RTKEverywhere.csv - - - name: Compile Sketch - run: arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${{ env.DEBUG_LEVEL }},PSRAM=enabled ./Firmware/RTK_Everywhere/RTK_Everywhere.ino - --build-property build.partitions=RTKEverywhere - --build-property upload.maximum_size=4055040 - --build-property "compiler.cpp.extra_flags=-MMD -c \"-DPOINTPERFECT_LBAND_TOKEN=$POINTPERFECT_LBAND_TOKEN\" \"-DPOINTPERFECT_IP_TOKEN=$POINTPERFECT_IP_TOKEN\" \"-DPOINTPERFECT_LBAND_IP_TOKEN=$POINTPERFECT_LBAND_IP_TOKEN\" \"-DPOINTPERFECT_RTCM_TOKEN=$POINTPERFECT_RTCM_TOKEN\" \"-DFIRMWARE_VERSION_MAJOR=$FIRMWARE_VERSION_MAJOR\" \"-DFIRMWARE_VERSION_MINOR=$FIRMWARE_VERSION_MINOR\" \"-DENABLE_DEVELOPER=${{ env.ENABLE_DEVELOPER }}\"" - --export-binaries + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add ./Firmware/RTK_Everywhere/form.h + git commit -m "Update form.h via Python" + git push origin ${{ env.BRANCH }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create artifact name run: | @@ -165,13 +89,14 @@ jobs: - name: Create artifact directory run: | - cd Firmware/RTK_Everywhere/build/esp32.esp32.esp32/ + cd ./Firmware/build mkdir ${{ env.ARTIFACT }} mv RTK_Everywhere.ino.bin ${{ env.ARTIFACT }} + mv RTK_Everywhere.ino.elf ${{ env.ARTIFACT }} - name: Upload artifact directory to action - avoid double-zip uses: actions/upload-artifact@v4 with: name: ${{ env.ARTIFACT }} - path: Firmware/RTK_Everywhere/build/esp32.esp32.esp32/${{ env.ARTIFACT }} + path: ./Firmware/build/${{ env.ARTIFACT }} retention-days: 7 diff --git a/Firmware/Dockerfile b/Firmware/Dockerfile new file mode 100644 index 000000000..91eab12df --- /dev/null +++ b/Firmware/Dockerfile @@ -0,0 +1,135 @@ +FROM ubuntu:latest AS upstream + +ARG DEBIAN_FRONTEND=noninteractive + +ARG CORE_VERSION=3.0.7 + +ARG FIRMWARE_VERSION_MAJOR=99 +ARG FIRMWARE_VERSION_MINOR=99 + +# ESP32 Core Debug Level +# We use "none" for releases and "error" for release_candidate +# You may find "verbose" useful while you are debugging your changes +ARG DEBUG_LEVEL=error + +# Developer Mode +# You may find "true" useful while you are making changes +# Set to false for releases +ARG ENABLE_DEVELOPER=true + +# If you have your own u-blox PointPerfect token(s), define them here +# or pass in as args when building the Dockerfile +# POINTPERFECT_LBAND_TOKEN is the token for the deprecated u-blox L-band SPARTN service +# POINTPERFECT_IP_TOKEN is the token for the deprecated u-blox IP SPARTN service +# POINTPERFECT_LBAND_IP_TOKEN is the token for the deprecated u-blox combined L-band and IP SPARTN service +# POINTPERFECT_RTCM_TOKEN is the token for the u-blox RTCM over NTRIP service +ARG POINTPERFECT_LBAND_TOKEN=0xAA,0xBB,0xCC,0xDD,0x00,0x11,0x22,0x33,0x0A,0x0B,0x0C,0x0D,0x00,0x01,0x02,0x03 +ARG POINTPERFECT_IP_TOKEN=0xAA,0xBB,0xCC,0xDD,0x00,0x11,0x22,0x33,0x0A,0x0B,0x0C,0x0D,0x00,0x01,0x02,0x03 +ARG POINTPERFECT_LBAND_IP_TOKEN=0xAA,0xBB,0xCC,0xDD,0x00,0x11,0x22,0x33,0x0A,0x0B,0x0C,0x0D,0x00,0x01,0x02,0x03 +ARG POINTPERFECT_RTCM_TOKEN=0xAA,0xBB,0xCC,0xDD,0x00,0x11,0x22,0x33,0x0A,0x0B,0x0C,0x0D,0x00,0x01,0x02,0x03 + +# Get curl and python3 +RUN apt-get update \ + && apt-get install -y curl python3 python3-pip python3-venv \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Avoid the externally managed environment constraint +RUN PYTHON_VER=$(ls /usr/lib | grep python3.) \ + && echo "Python version: ${PYTHON_VER}" \ + && rm /usr/lib/${PYTHON_VER}/EXTERNALLY-MANAGED + +# Install Python dependencies - esptool needs pyserial +#RUN python3 -m pip install --upgrade pip && \ +RUN pip install pyserial + +# Setup Arduino CLI +#RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh +RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh + +# Start config file +RUN arduino-cli config init --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json + +# Update core index +RUN arduino-cli core update-index + +# Update library index +RUN arduino-cli lib update-index + +# Install platform +RUN arduino-cli core install "esp32:esp32@${CORE_VERSION}" + +# Get Known Libraries +RUN arduino-cli lib install ArduinoJson@7.0.4 +RUN arduino-cli lib install ESP32Time@2.0.0 +RUN arduino-cli lib install ESP32_BleSerial@2.0.1 +RUN arduino-cli lib install "ESP32-OTA-Pull"@1.0.0 +RUN arduino-cli lib install JC_Button@2.1.2 +RUN arduino-cli lib install PubSubClient@2.8.0 +RUN arduino-cli lib install "SdFat"@2.1.1 +RUN arduino-cli lib install "SparkFun LIS2DH12 Arduino Library"@1.0.3 +RUN arduino-cli lib install "SparkFun MAX1704x Fuel Gauge Arduino Library"@1.0.4 +RUN arduino-cli lib install "SparkFun u-blox GNSS v3"@3.1.10 +RUN arduino-cli lib install "SparkFun Qwiic OLED Arduino Library"@1.0.13 +RUN arduino-cli lib install SSLClientESP32@2.0.0 +RUN arduino-cli lib install "SparkFun Extensible Message Parser"@1.0.4 +RUN arduino-cli lib install "SparkFun BQ40Z50 Battery Manager Arduino Library"@1.0.0 +RUN arduino-cli lib install "ArduinoMqttClient"@0.1.8 +RUN arduino-cli lib install "SparkFun u-blox PointPerfect Library"@1.11.4 +RUN arduino-cli lib install "SparkFun IM19 IMU Arduino Library"@1.0.1 +RUN arduino-cli lib install "SparkFun UM980 Triband RTK GNSS Arduino Library"@1.0.5 +RUN arduino-cli lib install "SparkFun LG290P Quadband RTK GNSS Arduino Library"@1.0.8 +RUN arduino-cli lib install "SparkFun I2C Expander Arduino Library"@1.0.1 +RUN arduino-cli lib install "SparkFun Apple Accessory Arduino Library"@3.0.9 +RUN arduino-cli lib install "SparkFun Authentication Coprocessor Arduino Library"@1.0.0 +RUN arduino-cli lib install "SparkFun Toolkit"@1.0.6 + +# Copy RTK_Everywhere and build deployment image +FROM upstream AS deployment + +# Add the source files +ADD . . + +# Patch libmbedtls and libbt +RUN cd ./RTK_Everywhere/Patch \ + && ESP_IDF=$(ls /root/.arduino15/packages/esp32/tools/esp32-arduino-libs | grep idf-release) \ + && echo "ESP IDF Version: ${ESP_IDF}" \ + && cp libmbedtls.a "/root/.arduino15/packages/esp32/tools/esp32-arduino-libs/${ESP_IDF}/esp32/lib/libmbedtls.a" \ + && cp libmbedtls_2.a "/root/.arduino15/packages/esp32/tools/esp32-arduino-libs/${ESP_IDF}/esp32/lib/libmbedtls_2.a" \ + && cp libmbedcrypto.a "/root/.arduino15/packages/esp32/tools/esp32-arduino-libs/${ESP_IDF}/esp32/lib/libmbedcrypto.a" \ + && cp libmbedx509.a "/root/.arduino15/packages/esp32/tools/esp32-arduino-libs/${ESP_IDF}/esp32/lib/libmbedx509.a" \ + && cp libbt.a "/root/.arduino15/packages/esp32/tools/esp32-arduino-libs/${ESP_IDF}/esp32/lib/libbt.a" + +# Patch NetworkEvents +RUN cd ./RTK_Everywhere/Patch \ + && cp NetworkEvents.* "/root/.arduino15/packages/esp32/hardware/esp32/${CORE_VERSION}/libraries/Network/src/" + +# Update form.h with index_html and main_js +RUN cd ./Tools \ + && python3 index_html_zipper.py ../RTK_Everywhere/AP-Config/index.html ../RTK_Everywhere/form.h \ + && python3 main_js_zipper.py ../RTK_Everywhere/AP-Config/src/main.js ../RTK_Everywhere/form.h + +# Copy custom RTKEverywhere.csv +# Use the 16MB partitions by default. 8MB (Postcard) partitions must be compiled separately +RUN cp RTKEverywhere.csv "/root/.arduino15/packages/esp32/hardware/esp32/${CORE_VERSION}/tools/partitions/RTKEverywhere.csv" + +# Compile Sketch +RUN cd ./RTK_Everywhere \ + && arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${DEBUG_LEVEL},PSRAM=enabled \ + ./RTK_Everywhere.ino \ + --build-property build.partitions=RTKEverywhere \ + --build-property upload.maximum_size=4055040 \ + --build-property "compiler.cpp.extra_flags=-MMD -c \ + \"-DPOINTPERFECT_LBAND_TOKEN=${POINTPERFECT_LBAND_TOKEN}\" \ + \"-DPOINTPERFECT_IP_TOKEN=${POINTPERFECT_IP_TOKEN}\" \ + \"-DPOINTPERFECT_LBAND_IP_TOKEN=${POINTPERFECT_LBAND_IP_TOKEN}\" \ + \"-DPOINTPERFECT_RTCM_TOKEN=${POINTPERFECT_RTCM_TOKEN}\" \ + \"-DFIRMWARE_VERSION_MAJOR=${FIRMWARE_VERSION_MAJOR}\" \ + \"-DFIRMWARE_VERSION_MINOR=${FIRMWARE_VERSION_MINOR}\" \ + \"-DENABLE_DEVELOPER=${ENABLE_DEVELOPER}\"" \ + --export-binaries + +# Copy the compile output. List the files +FROM deployment AS output +COPY --from=deployment ./RTK_Everywhere/build/esp32.esp32.esp32 / +CMD echo $(ls /*.*) diff --git a/Firmware/RTK_Everywhere/form.h b/Firmware/RTK_Everywhere/form.h index 1ee1f8ca3..6ea79bba8 100644 --- a/Firmware/RTK_Everywhere/form.h +++ b/Firmware/RTK_Everywhere/form.h @@ -26,7 +26,7 @@ // python main_js_zipper.py static const uint8_t main_js[] PROGMEM = { - 0x1F, 0x8B, 0x08, 0x08, 0xAD, 0xF2, 0xEF, 0x68, 0x02, 0xFF, 0x6D, 0x61, 0x69, 0x6E, 0x2E, 0x6A, + 0x1F, 0x8B, 0x08, 0x08, 0xCE, 0xCB, 0x00, 0x69, 0x02, 0xFF, 0x6D, 0x61, 0x69, 0x6E, 0x2E, 0x6A, 0x73, 0x2E, 0x67, 0x7A, 0x69, 0x70, 0x00, 0xED, 0x7D, 0x7B, 0x5F, 0x1B, 0x39, 0xB2, 0xE8, 0xFF, 0xF9, 0x14, 0x5A, 0xDF, 0xBD, 0x6B, 0xB3, 0x80, 0x69, 0x9B, 0x47, 0x20, 0x84, 0x9C, 0x4B, 0x80, 0x24, 0xDC, 0xE5, 0xB5, 0x98, 0xCC, 0x4C, 0x26, 0x27, 0x87, 0xD3, 0xD8, 0xC2, 0xF4, 0x89, 0xDD, @@ -1096,7 +1096,7 @@ static const uint8_t main_js[] PROGMEM = { // python index_html_zipper.py static const uint8_t index_html[] PROGMEM = { - 0x1F, 0x8B, 0x08, 0x08, 0xAD, 0xF2, 0xEF, 0x68, 0x02, 0xFF, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x2E, + 0x1F, 0x8B, 0x08, 0x08, 0xCE, 0xCB, 0x00, 0x69, 0x02, 0xFF, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x2E, 0x68, 0x74, 0x6D, 0x6C, 0x2E, 0x67, 0x7A, 0x69, 0x70, 0x00, 0xED, 0x7D, 0x59, 0x76, 0xDB, 0xCA, 0x92, 0xE0, 0xFF, 0x5D, 0x45, 0x16, 0xAB, 0xBB, 0x2C, 0x57, 0x4B, 0x14, 0x48, 0x4A, 0xB2, 0xAC, 0x67, 0xF3, 0x1C, 0x8D, 0xB6, 0xFA, 0x49, 0x32, 0x4B, 0x94, 0xDF, 0x1D, 0xFA, 0x74, 0xDF, 0x03, diff --git a/Firmware/compile_with_docker.bat b/Firmware/compile_with_docker.bat new file mode 100644 index 000000000..e3a34af0b --- /dev/null +++ b/Firmware/compile_with_docker.bat @@ -0,0 +1,6 @@ +docker build -t rtk_everywhere_firmware --no-cache-filter deployment . +docker create --name=rtk_everywhere rtk_everywhere_firmware:latest +docker cp rtk_everywhere:/RTK_Everywhere.ino.bin . +docker cp rtk_everywhere:/RTK_Everywhere.ino.elf . +docker cp rtk_everywhere:/RTK_Everywhere.ino.bootloader.bin . +docker container rm rtk_everywhere diff --git a/docs/firmware_compile.md b/docs/firmware_compile.md index bbd88da6f..4b6edd83d 100644 --- a/docs/firmware_compile.md +++ b/docs/firmware_compile.md @@ -2,9 +2,233 @@ 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. -Please see the [compilation workflow](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/compile-rtk-everywhere.yml#L77) on Github for the latest core and library versions. +* [How SparkFun does it](#how-sparkfun-does-it) +* [Using Docker](#using-docker) +* [Compiling on Windows (Deprecated)](#compiling-on-windows-deprecated) -## Windows +## How SparkFun does it + +At SparkFun, we use GitHub Actions and a Workflow to compile each release of RTK Everywhere. We run the [compilation workflow](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/compile-rtk-everywhere.yml) directly on GitHub. A virtual ubuntu machine installs the [Arduino CLI](https://github.com/arduino/arduino-cli/releases), installs the ESP32 Arduino core, patches the core in a couple of places, installs all the required libraries at the required version, converts the embedded HTML and Bootstrap JavaScript to binary zip format, and generates the firmware binary for the ESP32. That binary is either uploaded as an Artifact (by [non-release-build](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/non-release-build.yml)) or pushed to the [SparkFun RTK Everywhere Firmware Binaries](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware_Binaries) repo (by [compilation workflow](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/compile-rtk-everywhere.yml)). + +You are welcome to clone or fork this repo and do the exact same thing yourself. But you may need a paid GitHub Pro account to run the GitHub Actions, especially if you keep your clone / fork private. + +If you run the [compilation workflow](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/compile-rtk-everywhere.yml), it will compile the firmware and attempt to push the binary to the Binaries repo. This will fail as your account won't have the right permissions. The [non-release-build](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/non-release-build.yml) is the one for you. The firmware binary will be attached as an Artifact to the workflow run. Navigate to Actions \ Non-Release Build, select the latest run of Non-Release Build, the binary is in the Artifacts. + +You can then use (e.g.) the [SparkFun RTK Firmware Uploader](https://github.com/sparkfun/SparkFun_RTK_Firmware_Uploader) to upload the binary onto the ESP32. + +## Using Docker + +Installing the correct version of the ESP32 core and of each required Arduino library, is tedious and error-prone. Especially on Windows. We've lost count of the number of times code compilation fails on our local machines, because we had the wrong ESP32 core installed, or forgot to patch libbt or libmbedcrypto... It is much easier to sandbox the firmware compilation using an environment like [Docker](https://www.docker.com/). + +Docker is open-source. It is our new favourite thing! + +Here is a step-by-step guide for how to install Docker and compile the firmware from scratch: + +### Clone, fork or download the RTK Everywhere Firmware repo + +To build the RTK Everywhere Firmware, you obviously need a copy of the source code. + +If you are familiar with Git and GitHub Desktop, you can clone the RTK Everywhere Firmware repo directly into GitHub Desktop: + +![Clone RTK Everywhere with GitHub Desktop](./img/CompileSource/Clone_Repo_To_GitHub_Desktop.png) + +If you want to _contribute_ to RTK Everywhere, and already have a GitHub account, you can Fork the repo: + +![Fork RTK Everywhere](./img/CompileSource/Fork_Repo.png) + +Clone your fork to your local machine, make changes, and send us a Pull Request. This is exactly what the SparkFun Team do when developing the code. Please use the `release_candidate` branch for any such changes. We are very unlikely to merge anything directly into `main`, unless it is (e.g.) docs corrections or improvements. + +If you don't want to do either of those, you can simply Download a Zip copy of the repo instead. You will receive a complete copy as a Zip file. You can do this from the green **Code** button, or click on the icon below to download a copy of the main (released) branch: + +[![Download ZIP](./img/CompileSource/Download_Zip.png)](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/archive/refs/heads/main.zip "Download ZIP (main branch)") + +For the real Wild West experience, you can also download a copy of the `release_candidate` code branch. This is where the team is actively changing and testing the code, before it becomes a full release. The code there will _usually_ compile and will _usually_ work, but we don't guarantee it! We may be part way through implementing some breaking changes at the time of your download... + +[![Download ZIP - release candidate](./img/CompileSource/Download_Zip.png)](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/archive/refs/heads/release_candidate.zip "Download ZIP (release_candidate branch)") + +### Install Docker Desktop + +* **(Optional)** Head to [Docker](https://www.docker.com/) and create an account. A free "Personal" account will cover occasional compilations of the firmware +* Download and install [Docker Desktop](https://docs.docker.com/get-started/get-docker/) - there are versions for Mac, Windows and Linux. You may need to restart to complete the installation. +* Run the Desktop + * You don't _need_ to have an account and you don't _need_ to be signed in + * You only need to be signed in if you want to store or share your Container on Docker Hub + * If you don't sign in, Docker Desktop will run in Personal mode - which will cover local compilations of the firmware +* On Windows, you may see an error saying "**WSL needs updating** Your version of Windows Subsystem for Linux (WSL) is too old". If you do: + * Open a command prompt + * Type `wsl --update` to update WSL. At the time of writing, this installs Windows Subsystem for Linux 2.6.1 + * Restart the Docker Desktop +* If you are using Docker for the first time, the "What is a container?" and "How do I run a container?" demos are useful - _but not essential_ + * On Windows, you may want to give Docker Desktop permission to access to your Network, so it can access (e.g.) HTML ports + * You can Stop the container and Delete it when you are done +* You may want to prevent Docker from running when your machine starts up + * Uncheck "Start Docker Desktop when you sign in to your computer" in the Desktop settings + +### Using Docker to create the firmware binary + +* **Make sure you have Docker Desktop running.** You don't need to be signed in, but it needs to be running. +* Open a Command Prompt and `cd` into the SparkFun_RTK_Everywhere_Firmware folder +* Check you are in the right place. Type `dir` and hit enter. You should see the following files and folders: + +``` + .gitattributes + .github + .gitignore + docs + Firmware + Graphics + Issue_Template.md + License.md + README.md +``` + +* `cd Firmware` and then `dir` again. You should see: + +``` + compile_with_docker.bat + Dockerfile + readme.md + RTKEverywhere.csv + RTKEverywhere_8MB.csv + RTK_Everywhere +``` + +* The file that does most of the work is the `Dockerfile` + +* But, if you're short on time, run `compile_with_docker.bat`. It does everything for you: + +![Output of the compile batch file](./img/CompileSource/compile_me_batch_file.png) + +* Hey presto! You have your newly compiled firmware binary! + +You can then use (e.g.) the [SparkFun RTK Firmware Uploader](https://github.com/sparkfun/SparkFun_RTK_Firmware_Uploader) to upload the binary onto the ESP32. + +### Running the Dockerfile manually + +If you want to see and understand what's going on under the hood with the Dockerfile, Image and Container: + +Here is how to perform each step manually: + +* To begin, run the Dockerfile. Type: + +``` +docker build -t rtk_everywhere_firmware . +``` + +![Dockerfile starting](./img/CompileSource/Dockerfile_starting.png) + +![Dockerfile complete](./img/CompileSource/Dockerfile_complete.png) + +* If you want to see the full build progress including the output of echo or ls, use: + +``` +docker build -t rtk_everywhere_firmware --progress=plain . +``` + +* If you want to rebuild the image completely from scratch, without using the cache, use: + +``` +docker build -t rtk_everywhere_firmware --progress=plain --no-cache . +``` + +Building the full Image from scratch is slow, taking several minutes. You should only need to do it once - unless you make any changes to the Dockerfile. + +* **When you make changes to the source code and want to recompile, use:** + +``` +docker build -t rtk_everywhere_firmware --no-cache-filter deployment . +``` + +This uses the cache for the `upstream` stage and avoids recreating the full ubuntu machine. But it ignores the cache for the `deployment` stage, ensuring the code is recompiled. + +### Access the firmware binary by running the Image + +In Docker Desktop, in the Images tab, you should now be able to see an Image named `rtk_everywhere_firmware`. We now need to Run that Image to access the firmware binary. Click the triangular Run icon under Actions: + +![Docker image ready to run](./img/CompileSource/Docker_Image.png) + +Running the Image will create a Container, through which we can access the output of the arduino-cli code compilation. + +By default, the Container name is random. To avoid this, we define one in the **Optional settings** : + +![Docker Container - named rtk_everywhere](./img/CompileSource/Docker_Container.png) + +Run the Container and you should see: + +![Container is complete](./img/CompileSource/Container_complete.png) + +In the Command Prompt, type the following : + +``` +docker cp rtk_everywhere:/RTK_Everywhere.ino.bin . +``` + +Hey presto! A file called `RTK_Everywhere.ino.bin` appears in the current directory. That's the firmware binary we are going to upload to the ESP32. + +![Firmware binary](./img/CompileSource/Firmware_binary.png) + +If you need the `.elf` file so you can debug code crashes with me-no-dev's [ESP ExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecoder): + +``` +docker cp rtk_everywhere:/RTK_Everywhere.ino.elf . +``` + +If you need the `.bootloader.bin` file so you can upload it with esptool: + +``` +docker cp rtk_everywhere:/RTK_Everywhere.ino.bootloader.bin . +``` + +If you want the files to appear in a more convenient directory, replace the single `.` with a folder path. + +Delete the `rtk_everywhere` container afterwards, to save disk space and so you can reuse the same container name next time. If you forget, you will see an error: + +```Conflict. The container name "/rtk_everywhere" is already in use by container. You have to remove (or rename) that container to be able to reuse that name.``` + +* **Remember:** when you make changes to the source code and want to recompile, use: + +``` +docker build -t rtk_everywhere_firmware --no-cache-filter deployment . +``` + +#### Shortcut: compile_with_docker.bat + +**Shortcut:** the `compile_with_docker.bat` batch file does everything for you: + +``` +docker build -t rtk_everywhere_firmware --no-cache-filter deployment . +docker create --name=rtk_everywhere rtk_everywhere_firmware:latest +docker cp rtk_everywhere:/RTK_Everywhere.ino.bin . +docker cp rtk_everywhere:/RTK_Everywhere.ino.elf . +docker cp rtk_everywhere:/RTK_Everywhere.ino.bootloader.bin . +docker container rm rtk_everywhere +``` + +#### Changing the build properties + +**Changing the build properties:** if you want to change the build properties and (e.g.) include your own PointPerfect token, paste the following into a .bat file or shell script: + +``` +docker build -t rtk_everywhere_firmware --no-cache-filter deployment^ + --build-arg FIRMWARE_VERSION_MAJOR=99^ + --build-arg FIRMWARE_VERSION_MINOR=99^ + --build-arg POINTPERFECT_LBAND_TOKEN="0xAA,0xBB,<<=YOUR TOKEN IN C HEX FORMAT=>>,0x02,0x03"^ + --build-arg POINTPERFECT_IP_TOKEN="0xAA,0xBB,<<=YOUR TOKEN IN C HEX FORMAT=>>,0x02,0x03"^ + --build-arg POINTPERFECT_LBAND_IP_TOKEN="0xAA,0xBB,<<=YOUR TOKEN IN C HEX FORMAT=>>,0x02,0x03"^ + --build-arg POINTPERFECT_RTCM_TOKEN="0xAA,0xBB,<<=YOUR TOKEN IN C HEX FORMAT=>>,0x02,0x03"^ + --build-arg ENABLE_DEVELOPER=false^ + --build-arg DEBUG_LEVEL=none^ + . +docker create --name=rtk_everywhere rtk_everywhere_firmware:latest +docker cp rtk_everywhere:/RTK_Everywhere.ino.bin . +docker cp rtk_everywhere:/RTK_Everywhere.ino.elf . +docker cp rtk_everywhere:/RTK_Everywhere.ino.bootloader.bin . +docker container rm rtk_everywhere +``` + +## Compiling on Windows (Deprecated) + +**Note: we recommend using the Docker method. It is far easier and much less error-prone...** The SparkFun RTK Everywhere Firmware is compiled using Arduino CLI (currently [v1.0.4](https://github.com/arduino/arduino-cli/releases)). To compile: @@ -23,17 +247,33 @@ The SparkFun RTK Everywhere Firmware is compiled using Arduino CLI (currently [v 4. RTK Everywhere uses a custom partition file. Download the [RTKEverywhere.csv](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/Firmware/RTKEverywhere.csv) or [RTKEverywhere_8MB.csv](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/Firmware/RTKEverywhere_8MB.csv) for the RTK Postcard. 5. 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 + C:\Users\[user name]\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\tools\partitions\RTKEverywhere.csv This will increase the program partitions, as well as the SPIFFs partition to utilize the full 16MB of flash (8MB in the case of the Postcard). -6. Compile using the following command +6. Patch the core (libmbedtls, NetworkEvents and libbt) - as shown in the workflow + +7. Update the web config `form.h` by running the two python scripts in the `Tools` folder: + +``` +python index_html_zipper.py ../RTK_Everywhere/AP-Config/index.html ../RTK_Everywhere/form.h +python main_js_zipper.py ../RTK_Everywhere/AP-Config/src/main.js ../RTK_Everywhere/form.h +``` + +8. Compile using the following command + +``` + arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=none,PSRAM=enabled ./Firmware/RTK_Everywhere/RTK_Everywhere.ino --build-property build.partitions=RTKEverywhere --build-property upload.maximum_size=4055040 --build-property "compiler.cpp.extra_flags=-MMD -c" --export-binaries +``` + +9. Once compiled, upload to the device using the following two commands. Replace `COM4` with the COM port on which the RTK device is located. - arduino-cli compile 'Firmware/RTK_Everywhere' --build-property build.partitions=RTKEverywhere --build-property upload.maximum_size=4055040 --fqbn esp32:esp32:esp32:FlashSize=16M,PSRAM=enabled +``` + esptool.exe --chip esp32 --port \\.\COM4 --baud 460800 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 RTK_Surveyor.ino.bootloader.bin 0x8000 RTK_Surveyor_Partitions_16MB.bin 0xe000 boot_app0.bin 0x10000 RTK_Surveyor.ino.bin -8. Once compiled, upload to the device using the following command where `[COM_PORT]` is the COM port on which the RTK device is located (ie `COM42`). + esptool.exe --chip esp32 --port \\.\COM4 --before default_reset run - arduino-cli upload -p [COM_PORT] --fqbn esp32:esp32:esp32:UploadSpeed=512000,FlashSize=16M 'Firmware/RTK_Everywhere' +``` If you are seeing the error: @@ -44,255 +284,3 @@ You have either not replaced the partition file correctly or failed to include t !!! 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: - -1. Using a browser, download the Ubuntu 20.04 Desktop image -2. virtualbox - 1. Click on the new button - 2. Specify the machine Name, e.g.: Sparkfun_RTK_20.04 - 3. Select Type: Linux - 4. Select Version: Ubuntu (64-bit) - 5. Click the Next> button - 6. Select the memory size: 7168 - 7. Click the Next> button - 8. Click on Create a virtual hard disk now - 9. Click the Create button - 10. Select VDI (VirtualBox Disk Image) - 11. Click the Next> button - 12. Select Dynamically allocated - 13. Click the Next> button - 14. Select the disk size: 128 GB - 15. Click the Create button - 16. Click on Storage - 17. Click the empty CD icon - 18. On the right-hand side, click the CD icon - 19. Click on Choose a disk file... - 20. Choose the ubuntu-20.04... iso file - 21. Click the Open button - 22. Click on Network - 23. Under 'Attached to:' select Bridged Adapter - 24. Click the OK button - 25. Click the Start button -3. Install Ubuntu 20.04 -4. Log into Ubuntu -5. Click on Activities -6. Type terminal into the search box -7. Optionally install the SSH server - 1. In the terminal window - 1. sudo apt install -y net-tools openssh-server - 2. ifconfig - - Write down the IP address - - 2. On the PC - 1. ssh-keygen -t rsa -f ~/.ssh/Sparkfun_RTK_20.04 - 2. ssh-copy-id -o IdentitiesOnly=yes -i ~/.ssh/Sparkfun_RTK_20.04 <username>@<IP address> - 3. ssh -Y <username>@<IP address> - -### Build Environment - -Execute the following commands to create the build environment for the SparkFun RTK Everywhere Firmware: - -1. sudo adduser $USER dialout -2. sudo shutdown -r 0 - - Reboot to ensure that the dialout privilege is available to the user - -3. sudo apt update -4. sudo apt install -y git gitk git-cola minicom python3-pip -5. sudo pip3 install pyserial -6. mkdir ~/SparkFun -7. mkdir ~/SparkFun/esptool -8. cd ~/SparkFun/esptool -9. git clone https://github.com/espressif/esptool . -10. cd ~/SparkFun -11. nano serial-port.sh - - Insert the following text into the file: - - ```C++ - #!/bin/bash - # serial-port.sh - # - # Shell script to read the serial data from the RTK Express ESP32 port - # - # Parameters: - # 1: ttyUSBn - # - sudo minicom -b 115200 -8 -D /dev/$1 < /dev/tty - ``` - -12. chmod +x serial-port.sh -13. nano new-firmware.sh - - Insert the following text into the file: - - ```C++ - #!/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 - ``` - -14. chmod +x new-firmware.sh -15. nano new-firmware-4mb.sh - - Insert the following text into the file: - - ```C++ - #!/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 - ``` - -16. chmod +x new-firmware-4mb.sh - - Get the SparkFun RTK Everywhere Firmware sources - -17. mkdir ~/SparkFun/RTK -18. cd ~/SparkFun/RTK -19. git clone https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware . - - Get the SparkFun RTK binaries - -20. mkdir ~/SparkFun/RTK_Binaries -21. cd ~/SparkFun/RTK_Binaries -22. git clone https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware_Binaries.git . - - Install the Arduino IDE - -23. mkdir ~/SparkFun/arduino -24. cd ~/SparkFun/arduino -25. wget https://downloads.arduino.cc/arduino-1.8.15-linux64.tar.xz -26. tar -xvf ./arduino-1.8.15-linux64.tar.xz -27. cd arduino-1.8.15/ -28. sudo ./install.sh - - Add the ESP32 support - -29. Arduino - - 1. Click on File in the menu bar - 2. Click on Preferences - 3. Go down to the Additional Boards Manager URLs text box - 4. Only if the textbox already has a value, go to the end of the value or values and add a comma - 5. Add the link: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - 6. Note the value in Sketchbook location - 7. Click the OK button - 8. Click on File in the menu bar - 9. Click on Quit - - Get the required external libraries, then add to the Sketchbook location from above - -30. cd ~/Arduino/libraries -31. mkdir AsyncTCP -32. cd AsyncTCP/ -33. git clone https://github.com/me-no-dev/AsyncTCP.git . -34. cd .. -35. mkdir ESPAsyncWebServer -36. cd ESPAsyncWebServer -37. git clone https://github.com/me-no-dev/ESPAsyncWebServer . - - Connect the Config ESP32 port of the RTK to a USB port on the computer - -38. ls /dev/ttyUSB* - - Enable the libraries in the Arduino IDE - -39. Arduino - - 1. From the menu, click on File - 2. Click on Open... - 3. Select the ~/SparkFun/RTK/Firmware/RTK_Surveyor/RTK_Surveyor.ino file - 4. Click on the Open button - - Select the ESP32 development module - - 5. From the menu, click on Tools - 6. Click on Board - 7. Click on Board Manager… - 8. Click on esp32 - 9. Select version 2.0.2 - 10. Click on the Install button in the lower right - 11. Close the Board Manager... - 12. From the menu, click on Tools - 13. Click on Board - 14. Click on ESP32 Arduino - 15. Click on ESP32 Dev Module - - Load the required libraries - - 16. From the menu, click on Tools - 17. Click on Manage Libraries… - 18. For each of the following libraries: - - 1. Locate the library - 2. Click on the library - 3. Select the version listed in the compile-rtk-firmware.yml file for the [main](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/compile-rtk-firmware.yml) or the [release_candidate](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/release_candidate/.github/workflows/compile-rtk-firmware.yml) branch - 4. 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 - - 19. Click on the Close button - - Select the terminal port - - 20. From the menu, click on Tools - 21. Click on Port, Select the port that was displayed in step 38 above - 22. Select /dev/ttyUSB0 - 23. Click on Upload Speed - 24. Select 230400 - - Setup the partitions for the 16 MB flash - - 25. From the menu, click on Tools - 26. Click on Flash Size - 27. Select 16MB - 28. From the menu, click on Tools - 29. Click on Partition Scheme - 30. Click on 16M Flash (3MB APP/9MB FATFS) - 31. From the menu click on File - 32. Click on Quit - -40. cd ~/SparkFun/RTK/ -41. cp Firmware/app3M_fat9M_16MB.csv ~/.arduino15/packages/esp32/hardware/esp32/2.0.2/tools/partitions/app3M_fat9M_16MB.csv diff --git a/docs/img/CompileSource/Clone_Repo_To_GitHub_Desktop.png b/docs/img/CompileSource/Clone_Repo_To_GitHub_Desktop.png new file mode 100644 index 000000000..86ee53682 Binary files /dev/null and b/docs/img/CompileSource/Clone_Repo_To_GitHub_Desktop.png differ diff --git a/docs/img/CompileSource/Container_complete.png b/docs/img/CompileSource/Container_complete.png new file mode 100644 index 000000000..661c61628 Binary files /dev/null and b/docs/img/CompileSource/Container_complete.png differ diff --git a/docs/img/CompileSource/Docker_Container.png b/docs/img/CompileSource/Docker_Container.png new file mode 100644 index 000000000..bca62cef0 Binary files /dev/null and b/docs/img/CompileSource/Docker_Container.png differ diff --git a/docs/img/CompileSource/Docker_Image.png b/docs/img/CompileSource/Docker_Image.png new file mode 100644 index 000000000..653f49699 Binary files /dev/null and b/docs/img/CompileSource/Docker_Image.png differ diff --git a/docs/img/CompileSource/Dockerfile_complete.png b/docs/img/CompileSource/Dockerfile_complete.png new file mode 100644 index 000000000..0d6d504a1 Binary files /dev/null and b/docs/img/CompileSource/Dockerfile_complete.png differ diff --git a/docs/img/CompileSource/Dockerfile_starting.png b/docs/img/CompileSource/Dockerfile_starting.png new file mode 100644 index 000000000..aa7bba139 Binary files /dev/null and b/docs/img/CompileSource/Dockerfile_starting.png differ diff --git a/docs/img/CompileSource/Download_Zip.png b/docs/img/CompileSource/Download_Zip.png new file mode 100644 index 000000000..00163c2f1 Binary files /dev/null and b/docs/img/CompileSource/Download_Zip.png differ diff --git a/docs/img/CompileSource/Firmware_binary.png b/docs/img/CompileSource/Firmware_binary.png new file mode 100644 index 000000000..2408d0b7a Binary files /dev/null and b/docs/img/CompileSource/Firmware_binary.png differ diff --git a/docs/img/CompileSource/Fork_Repo.png b/docs/img/CompileSource/Fork_Repo.png new file mode 100644 index 000000000..1a15eb90f Binary files /dev/null and b/docs/img/CompileSource/Fork_Repo.png differ diff --git a/docs/img/CompileSource/compile_me_batch_file.png b/docs/img/CompileSource/compile_me_batch_file.png new file mode 100644 index 000000000..80bec09c5 Binary files /dev/null and b/docs/img/CompileSource/compile_me_batch_file.png differ