Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GS] Export UF2 file when calling uf2_loader.py script #334

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}")