Skip to content

Commit

Permalink
Dimos Init (#1065)
Browse files Browse the repository at this point in the history
### Summary
First implementation of Dimos, as per spec'd by
[SW-39](https://ubcformulaelectric.atlassian.net/browse/SW-39).

### TODO Once merged, send message to software channel on slack that
`DPLATFORM=firmware` and `DTARGET` is old `DPLATFORM`
- Use -DPLATFORM to specify the platform you are building to, whether
`firmware` or `dimos`
- Use -DTARGET to specify the target you are building to, between `dev`,
`test`, `deploy` in dimos, and `arm` and `x86` in firmware.

### Changelist 
- [x] Dimos QT Build
- [x] JSONCAN integration
- [x] Try to move project to lower files (move things out of the top
level)
- [x] CMake better OS condition
- [x] Refactor matrix upwards

### Testing Done
- Local testing on Windows, Mac, Linux
- Testing on CI servers

### Checklist
*Please change `[ ]` to `[x]` when you are ready.*
- [x] I have read and followed the code conventions detailed in
[README.md](../README.md) (*This will save time for both you and the
reviewer!*).
- [x] If this pull request is longer then **500** lines, I have provided
*explicit* justification in the summary above explaining why I *cannot*
break this up into multiple pull requests (*Small PR's are faster and
less painful for everyone involved!*).


[SW-39]:
https://ubcformulaelectric.atlassian.net/browse/SW-39?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
Lucien950 authored Nov 11, 2023
1 parent 8b0b41b commit 1764c77
Show file tree
Hide file tree
Showing 52 changed files with 1,164 additions and 386 deletions.
28 changes: 28 additions & 0 deletions .github/actions/build_binary/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build Firmware Binaries Action
description: Builds the bianry for a given board
inputs:
board:
description: The board for which to build a binary
required: true
build_dir:
required: false
description: The directory in which to build the binary
default: build_fw_deploy

runs:
using: "composite"
steps:
# Fix to ensure that commands like git status work in child directories
# for gitpython in git_commit_info
- name: Setup git
shell: bash
run: git config --global --add safe.directory $(realpath .)

# xvfb-run is required to prefix any commands that run STM32CubeMX
# It fakes out a display, since STM32CubeMX throws an error if it doesn't detect a display
# Don't use Pipenv for Cmake since python packages are installed system-wide in the container
- name: Build
shell: bash
run: |
cmake -B ${{ inputs.build_dir }} -DPLATFORM=firmware -DTARGET=deploy -DHANDLE_DEPS=OFF
xvfb-run make --directory=${{ inputs.build_dir }} -j`nproc` ${{ inputs.board }}.elf
5 changes: 2 additions & 3 deletions .github/actions/push_release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ inputs:
description: The body of the release
required: true
latest:
description: Determine if this commit
description: Determine if this release should be marked as latest
required: false
type: boolean
default: false
default: 'false'

runs:
using: "composite"
Expand Down
59 changes: 0 additions & 59 deletions .github/workflows/build.yml

This file was deleted.

41 changes: 31 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
paths-ignore:
- 'software/**'

jobs:
clang-format:
name: Check C Formatting
Expand All @@ -29,11 +29,11 @@ jobs:

- name: Check for differences
run: git --no-pager diff --color --exit-code

codegen:
name: Check CubeMX Code Gen
runs-on: ubuntu-22.04
needs: [clang-format]
needs: [ clang-format ]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -87,9 +87,30 @@ jobs:
build-firmware-thruna:
needs: [ clang-format ]
name: Build Firmware Binaries
uses: ./.github/workflows/build.yml # https://github.blog/changelog/2022-01-25-github-actions-reusable-workflows-can-be-referenced-locally/ God is good
secrets:
docker_token: ${{ secrets.DOCKER_TOKEN }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- FSM
- PDM
- BMS
- DCM
- DIM
- f4dev
container:
image: ubcformulaelectric/environment:latest
credentials:
username: ubcformulaelectric
password: ${{ secrets.docker_token }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/actions/build_binary
with:
board: ${{ matrix.board }}

test-thruna:
needs: [ clang-format ]
Expand Down Expand Up @@ -128,7 +149,7 @@ jobs:

- name: Build
run: |
cmake -B $BUILD_DIR -DPLATFORM=x86 -DHANDLE_DEPS=OFF
cmake -B $BUILD_DIR -DPLATFORM=firmware -DTARGET=test -DHANDLE_DEPS=OFF
make --directory=$BUILD_DIR -j`nproc` ${{ matrix.board }}_test
- name: Run tests
Expand Down Expand Up @@ -162,7 +183,7 @@ jobs:

- name: Build
run: |
cmake -B $BUILD_DIR -DPLATFORM=x86 -DHANDLE_DEPS=OFF
cmake -B $BUILD_DIR -DPLATFORM=firmware -DTARGET=test -DHANDLE_DEPS=OFF
make --directory=$BUILD_DIR -j`nproc` shared_test
- name: Run tests
Expand All @@ -188,15 +209,15 @@ jobs:
# for gitpython in git_commit_info
- name: Setup git
run: git config --global --add safe.directory $(realpath .)

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build
run: |
cmake -B $BUILD_DIR -DPLATFORM=x86 -DNO_VENV=ON -DHANDLE_DEPS=OFF
cmake -B $BUILD_DIR -DPLATFORM=firmware -DTARGET=test -DNO_VENV=ON -DHANDLE_DEPS=OFF
make --directory=$BUILD_DIR -j`nproc` fakegen_test
- name: Run tests
Expand Down
36 changes: 31 additions & 5 deletions .github/workflows/master_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,37 @@ jobs:
# Build DBC and Binaries
build:
name: Build Firmware Binaries
uses: ./.github/workflows/build.yml
secrets:
docker_token: ${{secrets.DOCKER_TOKEN}}
with:
upload_artifact: true
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- FSM
- PDM
- BMS
- DCM
- DIM
- f4dev
container:
image: ubcformulaelectric/environment:latest
credentials:
username: ubcformulaelectric
password: ${{ secrets.docker_token }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/actions/build_binary
with:
board: ${{ matrix.board }}
# Uploads .elf binary to Github Actions workflow
- name: Save built artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.board }}.elf
path: ${{ env.BUILD_DIR }}/firmware/thruna/${{ matrix.board }}/${{ inputs.board }}.elf

generate-dbc:
name: Call DBC Generation
uses: ./.github/workflows/dbc-gen.yml
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ hooksl
can_bus/**/*.dbc

# CMake build directories
build_arm
build_x86
build_fw_deploy
build_fw_test
build_dimos_deploy
build_dimos_dev
build_dimos_test

environment/bin
CMakeUserPresets.json
Expand Down
18 changes: 10 additions & 8 deletions .vscode/cmake-variants.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
platform:
default: arm
choices:
arm:
short: Embedded
firmware_deploy:
short: Firmware Deploy
settings:
PLATFORM: arm
PLATFORM: firmware
TARGET: deploy
env:
PLATFORM: arm
BUILD_DIR: build_fw_deploy
buildType: Debug
x86:
short: Tests
firmware_test:
short: Firmware Tests
settings:
PLATFORM: x86
PLATFORM: firmware
TARGET: test
env:
PLATFORM: x86
BUILD_DIR: build_fw_test
buildType: Debug
24 changes: 12 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Debug Embedded: BMS",
"cwd": "${workspaceRoot}",
"executable": "build_arm/firmware/thruna/BMS/BMS.elf",
"executable": "build_fw_deploy/firmware/thruna/BMS/BMS.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
Expand All @@ -18,7 +18,7 @@
{
"name": "Debug Embedded: DCM",
"cwd": "${workspaceRoot}",
"executable": "build_arm/firmware/thruna/DCM/DCM.elf",
"executable": "build_fw_deploy/firmware/thruna/DCM/DCM.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
Expand All @@ -32,7 +32,7 @@
{
"name": "Debug Embedded: FSM",
"cwd": "${workspaceRoot}",
"executable": "build_arm/firmware/thruna/FSM/FSM.elf",
"executable": "build_fw_deploy/firmware/thruna/FSM/FSM.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
Expand All @@ -46,7 +46,7 @@
{
"name": "Debug Embedded: PDM",
"cwd": "${workspaceRoot}",
"executable": "build_arm/firmware/thruna/PDM/PDM.elf",
"executable": "build_fw_deploy/firmware/thruna/PDM/PDM.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
Expand All @@ -60,7 +60,7 @@
{
"name": "Debug Embedded: DIM",
"cwd": "${workspaceRoot}",
"executable": "build_arm/firmware/thruna/DIM/DIM.elf",
"executable": "build_fw_deploy/firmware/thruna/DIM/DIM.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
Expand All @@ -83,7 +83,7 @@
},
"osx": {
"MIMode": "lldb"
},
}
},
{
"name": "Debug Tests: DCM",
Expand All @@ -97,7 +97,7 @@
},
"osx": {
"MIMode": "lldb"
},
}
},
{
"name": "Debug Tests: FSM",
Expand All @@ -111,7 +111,7 @@
},
"osx": {
"MIMode": "lldb"
},
}
},
{
"name": "Debug Tests: PDM",
Expand All @@ -125,7 +125,7 @@
},
"osx": {
"MIMode": "lldb"
},
}
},
{
"name": "Debug Tests: DIM",
Expand All @@ -139,7 +139,7 @@
},
"osx": {
"MIMode": "lldb"
},
}
},
{
"name": "Debug Tests: Shared",
Expand All @@ -153,7 +153,7 @@
},
"osx": {
"MIMode": "lldb"
},
},
}
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "/can_bus/json/schema_tx.json"
}
],
"cmake.buildDirectory": "${workspaceFolder}/build_${env:PLATFORM}",
"cmake.buildDirectory": "${workspaceFolder}/${env:BUILD_DIR}",
"cmake.configureOnEdit": false,
"cmake.configureOnOpen": true
}
Loading

0 comments on commit 1764c77

Please sign in to comment.