Skip to content

Commit

Permalink
[GS] Export UF2 file when calling uf2_loader.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
stojadin2701 committed Aug 11, 2023
1 parent 5562c35 commit 3f755cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/merge-criteria.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ jobs:
run: pio pkg install --global

- name: Build
run: platformio run -d ${{ matrix.project }}

shell: bash
run: |
platformio run -d ${{ matrix.project }}
if [[ "${{ matrix.project }}" == "ground_station" ]]; then
python ${{ matrix.project }}/uf2_loader.py ${{ matrix.project }}/.pio/build/esp32-s2-saola-1/firmware
fi
- name: Generate compile_commands.json
run: platformio run -d ${{ matrix.project }} --target compiledb

Expand All @@ -118,6 +123,7 @@ jobs:
with:
name: artifacts
path: |
./${{ matrix.project }}/.pio/build/**/firmware.UF2
./${{ matrix.project }}/.pio/build/**/firmware.bin
./${{ matrix.project }}/.pio/build/**/firmware.elf
./${{ matrix.project }}/.pio/build/**/compile_commands.json
Expand Down
11 changes: 8 additions & 3 deletions ground_station/uf2_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,14 @@ def download(self, inputPath):
os.remove(tempFilePath)
return None


# If this script is called directly, it converts the .bin binary into the .UF2 binary
if __name__ == "__main__":
loader = UF2Loader("ESP32S2", 0)
status = loader.download(".pio/build/esp32-s2-saola-1/firmware.bin")
binary_path = ".pio/build/esp32-s2-saola-1/firmware"
# if an argument is passed to the script, use it as the path to the binary
if len(sys.argv) > 1:
binary_path = sys.argv[1]
input = f"{binary_path}.bin"
output = f"{binary_path}.UF2"
status = loader.save(input, output)
print(f"Status: {status}")

0 comments on commit 3f755cb

Please sign in to comment.