Skip to content
Draft
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
29 changes: 0 additions & 29 deletions .github/workflows/hil_build.yml

This file was deleted.

70 changes: 66 additions & 4 deletions .github/workflows/obc_build.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: OBC Build
on: [push, pull_request]

concurrency:
group: rm46-hil
cancel-in-progress: false

jobs:
build:
OBC_BUILD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup
run: |
sudo apt-get update
sudo apt-get -y install build-essential cmake
sudo apt install -y build-essential gcc-multilib g++-multilib cmake curl

- name: Install requirements
run: |
Expand All @@ -28,18 +32,36 @@ jobs:
cmake .. -DCMAKE_BUILD_TYPE=OBC -G"Unix Makefiles" -DBOARD_TYPE=RM46_LAUNCHPAD -DDEBUG=0
make

- name: Upload CRC Binary (Release-Launchpad)
uses: actions/upload-artifact@v4
with:
name: launchpad-bin
path: build/OBC-firmware-crc.bin

- name: Build (Release-OBC Rev1)
run: |
cd build
cmake .. -DCMAKE_BUILD_TYPE=OBC -G"Unix Makefiles" -DBOARD_TYPE=OBC_REVISION_1 -DDEBUG=0
make

- name: Upload CRC Binary (Release-OBC Rev1)
uses: actions/upload-artifact@v4
with:
name: rev1-bin
path: build/OBC-firmware-crc.bin

- name: Build (Release-OBC Rev2)
run: |
cd build
cmake .. -DCMAKE_BUILD_TYPE=OBC -G"Unix Makefiles" -DBOARD_TYPE=OBC_REVISION_2 -DDEBUG=0
make

- name: Upload CRC Binary (Release-OBC Rev2)
uses: actions/upload-artifact@v4
with:
name: rev2-bin
path: build/OBC-firmware-crc.bin

- name: Build (Debug-Launchpad)
run: |
cd build
Expand All @@ -64,8 +86,8 @@ jobs:
name: bin-file
path: build/OBC-firmware.bin

crc:
needs: build
CRC:
needs: OBC_BUILD
runs-on: ubuntu-latest
steps:
- name: Download binary
Expand All @@ -78,3 +100,43 @@ jobs:
run: |
echo "CRC checksum:"
cksum OBC-firmware.bin

HARDWARE-IN-LOOP:
needs: OBC_BUILD
runs-on: [self-hosted, hil, rm46]

defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
sudo apt install -y build-essential gcc-multilib g++-multilib cmake curl
python3 -m venv venv/
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .

- name: Create Ground Station Binary Directory
run: |
mkdir build_gs
cd build_gs
cmake .. -DCMAKE_BUILD_TYPE=GS

- name: Build
run: |
cd build_gs
cmake --build .

- name: Download binary with CRC
uses: actions/download-artifact@v4
with:
name: launchpad-bin
path: .

- name: Run HIL
run: |
source venv/bin/activate
python3 hil/hil_main.py /dev/ttyACM0 OBC-firmware-crc.bin
18 changes: 0 additions & 18 deletions hil/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion hil/examples/CMakeLists.txt

This file was deleted.

87 changes: 0 additions & 87 deletions hil/examples/LogSink_Example.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions hil/hil_main.cpp

This file was deleted.

77 changes: 77 additions & 0 deletions hil/hil_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3

import os
import sys
from pathlib import Path

from serial import Serial

from obc.tools.python.app_update import send_bin

EXIT_OK = 0
EXIT_BAD_ARGS = 1
EXIT_FW_NOT_FOUND = 2
EXIT_FW_INVALID = 3
EXIT_SERIAL_NOT_FOUND = 4
EXIT_SERIAL_NO_PERMISSION = 5


# Helper logger function for this
def error_log(msg: str, code: int) -> None:
"""
Print an error message and terminate execution with a specific exit code

Args:
msg: Human-readable error message.
code: Process exit code.
"""
print(f"ERROR: {msg}")
sys.exit(code)


def main() -> int:
"""
Validate inputs and flash firmware onto the target hardware

Returns:
Exit status code.
"""
if len(sys.argv) != 3:
print("Usage: hil_main.py <serial_device> <firmware.bin>")
return EXIT_BAD_ARGS

serial_dev = sys.argv[1]
firmware_path = Path(sys.argv[2]).resolve()

# Firmware validation
if not firmware_path.exists():
error_log(f"Firmware file not found: {firmware_path}", EXIT_FW_NOT_FOUND)

if firmware_path.suffix != ".bin":
error_log("Firmware must be a .bin file", EXIT_FW_INVALID)

# Serial device validation (filesystem level)
if not os.path.exists(serial_dev):
error_log(f"Serial device does not exist: {serial_dev}", EXIT_SERIAL_NOT_FOUND)

if not os.access(serial_dev, os.R_OK | os.W_OK):
error_log(f"No permission to access serial device: {serial_dev}", EXIT_SERIAL_NO_PERMISSION)

print(f"Serial device path validated: {serial_dev}")

# Open + close once to ensure kernel-level readiness
# If this fails, Python will terminate immediately (desired)
ser = Serial(serial_dev, timeout=2)
ser.close()

print("[1] Flashing Hardware In The Loop")

# Flashing (any failure aborts process)
send_bin(str(firmware_path), serial_dev)

print("[2] Flashing Completed Successfully")
return EXIT_OK


if __name__ == "__main__":
sys.exit(main())
1 change: 0 additions & 1 deletion hil/logsink/CMakeLists.txt

This file was deleted.

Loading
Loading