Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7ff486b
project vimrc for FZF
itsarune Nov 23, 2023
e2258b1
filter out .swp files
itsarune Nov 25, 2023
f293ab4
bootstrap bazel embedded
itsarune Jun 27, 2025
c118b47
Merge branch 'vimrc' of github.com:itsarune/Software into mdv6_firmware
itsarune Jul 3, 2025
b9f3498
still working on compilation
itsarune Jul 3, 2025
b6abd24
wip mdv6 firmware
itsarune Jul 8, 2025
4096749
wip
itsarune Jul 12, 2025
a08bac2
wip
itsarune Jul 12, 2025
63a0307
wip
itsarune Jul 19, 2025
0a63875
wip
itsarune Jul 19, 2025
7545dd2
Add new cross-compiler config
itsarune Jul 19, 2025
0db7c0f
wip move software/motor -> firmware/motor
itsarune Jul 19, 2025
6ae782b
Updated main from MDV6 spi branch
itsarune Jul 21, 2025
46e6eb7
wip
itsarune Jul 22, 2025
3cd5057
compiles but doesn't link
itsarune Aug 2, 2025
3aa48ae
both compiles AND links!
itsarune Aug 2, 2025
b147774
add bazel-embedded
itsarune Aug 8, 2025
d592ca0
wip
itsarune Aug 9, 2025
cdfb16b
wip
itsarune Aug 9, 2025
530796f
perhaps flashing works
itsarune Aug 9, 2025
9fc2642
wip
itsarune Aug 11, 2025
5a8c997
wip
Sep 6, 2025
d2e0816
add arm toolchain to opt/tbotspython
Sep 6, 2025
354b482
debug overflow
Sep 6, 2025
074a75f
Merge branch 'master' of github.com:UBC-Thunderbots/Software into mdv…
itsarune Sep 21, 2025
5b15b11
wip
itsarune Sep 21, 2025
42c0442
compiles now
itsarune Sep 28, 2025
bc19655
Add compile and linker flags to optimize space usage
Jan 1, 2026
321de05
Merge branch 'master' of github.com:UBC-Thunderbots/Software into mdv…
Jan 1, 2026
59c8679
Build mdv6 firmware in CI
Jan 1, 2026
dcb0a3a
shouldn't commit this
Jan 1, 2026
8297d83
fix syntax issue in actions file
Jan 1, 2026
a7f0085
fix firmware builds
Jan 1, 2026
0d9fe8f
Bazel 8 hail mary
Jan 1, 2026
179ff2f
fix alt builds
Jan 1, 2026
fd8e159
don't test firmware file
Jan 1, 2026
4a85591
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 3, 2026
f781b24
openocd flashing works i think?
Jan 11, 2026
3a39581
Merge branch 'master' of github.com:UBC-Thunderbots/Software into mdv…
Jan 11, 2026
5003131
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 11, 2026
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
22 changes: 20 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
-//software/ai/hl/... \
-//software/field_tests/... \
-//software/embedded/... \
-//toolchains/cc/...
-//toolchains/cc/... \
-//firmware/...

- name: Jetson Nano Build Test
run: |
Expand All @@ -43,6 +44,22 @@ jobs:
cd src
bazel build //software/embedded:thunderloop_main --copt=-O3 --//software/embedded:host_platform=PI --platforms=//toolchains/cc:robot

- name: Motor Firmware build Test
run: |
cd src
bazel build //firmware/motor:mdv6_firmware_main --platforms=//toolchains/cc:motor_board

motor-firmare:
name: Motor Firmware
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/environment-setup

- name: Build Motor Firmware
run: |
cd src
bazel build //firmware/motor:mdv6_firmware_main --platforms=//toolchains/cc:motor_board

software-tests:
name: Software Tests
Expand All @@ -60,7 +77,8 @@ jobs:
-//software/ai/hl/... \
-//software/field_tests/... \
-//software/ai/navigator/... \
-//toolchains/cc/...
-//toolchains/cc/... \
-//firmware/...

robot-tests:
name: Robot Software Tests
Expand Down
4 changes: 4 additions & 0 deletions environment_setup/setup_software.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,8 @@ print_status_msg "Set up ansible-lint"
/opt/tbotspython/bin/ansible-galaxy collection install ansible.posix
print_status_msg "Finished setting up ansible-lint"

print_status_msg "Setting up STM32 cross-compiler"
install_stm32_cross_compiler $g_arch
print_status_msg "Done setting up STM32 cross-compiler"

print_status_msg "Done Software Setup, please reboot for changes to take place"
13 changes: 13 additions & 0 deletions environment_setup/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ install_python_dev_cross_compile_headers() {
rm -rf /tmp/tbots_download_cache/python-3.12.0.tar.xz
}

install_stm32_cross_compiler() {
arch="aarch64"
if is_x86 $1; then
arch="x86_64"
fi
download_link=https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-${arch}-arm-none-eabi.tar.xz

wget -N $download_link -O /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz
tar -xf /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz -C /tmp/tbots_download_cache/
sudo mv /tmp/tbots_download_cache/arm-gnu-toolchain-14.3.rel1-${arch}-arm-none-eabi /opt/tbotspython/arm-none-eabi-gcc
rm /tmp/tbots_download_cache/arm-gnu-toolchain.tar.xz
}

is_x86() {
if [[ $1 == "x86_64" ]]; then
return 0
Expand Down
18 changes: 18 additions & 0 deletions src/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ http_archive(
url = "https://github.com/saebyn/munkres-cpp/archive/61086fcf5b3a8ad4bda578cdc2d1dca57b548786.tar.gz",
)

# For flashing the motor driver board
http_archive(
name = "bazel_embedded",
sha256 = "91a78efbb0f94479fe9ca2912aced712be9e7028325bada9a73e7d325427b404",
strip_prefix = "bazel-embedded-cf5b240d510313b3383e0cdb550eb9f32be7244e",
url = "https://github.com/bazelembedded/bazel-embedded/archive/cf5b240d510313b3383e0cdb550eb9f32be7244e.zip",
)

openocd = use_extension("//:defs.bzl", "openocd_extension")
use_repo(openocd, "com_openocd")

http_archive(
name = "LTC4151",
build_file = "@//extlibs:LTC4151.BUILD",
Expand Down Expand Up @@ -233,6 +244,7 @@ register_toolchains(
"//toolchains/cc:cc_toolchain_for_k8_jetson_nano_cross_compile",
"//toolchains/cc:cc_toolchain_for_k8",
"//toolchains/cc:cc_toolchain_for_aarch64",
"//toolchains/cc:cc_toolchain_for_stm32",
)

##############################################
Expand Down Expand Up @@ -265,6 +277,12 @@ new_local_repository(
path = "/opt/tbotspython/aarch64-tbots-linux-gnu/",
)

new_local_repository(
name = "motor_board_gcc",
build_file = "@//extlibs:motor_board_gcc.BUILD",
path = "/opt/tbotspython/arm-none-eabi-gcc/",
)

new_local_repository(
name = "py_cc_toolchain_host",
build_file = "@//extlibs:py_cc_toolchain.BUILD",
Expand Down
27 changes: 27 additions & 0 deletions src/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/extlibs/motor_board_gcc.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package(default_visibility = ["//visibility:public"])

filegroup(
name = "includes",
srcs = glob([
"arm-none-eabi/include",
"lib/gcc/arm-none-eabi/14.3.1/include",
]),
)
Empty file added src/firmware/BUILD
Empty file.
60 changes: 60 additions & 0 deletions src/firmware/motor/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
load("@bazel_embedded//tools/openocd:defs.bzl", "openocd_flash")

package(default_visibility = ["//visibility:public"])

filegroup(
name = "mdv6_firmware_srcs",
srcs = glob(["**/*.c"]),
)

filegroup(
name = "mdv6_firmware_hdrs",
srcs = glob(["**/*.h"]),
)

cc_binary(
name = "mdv6_firmware_main",
# Linker file informs the toolchain how much RAM and flash you have as well as its locations on the chip
additional_linker_inputs = [
"mdv6_firmware.ld",
],
linkopts = ["-T $(location mdv6_firmware.ld)"],
target_compatible_with = [
"@platforms//cpu:armv6-m",
"@platforms//os:none",
],
deps = [
":mdv6_firmware",
],
)

cc_library(
name = "mdv6_firmware",
srcs = glob(["**/*.c"]),
hdrs = glob(["**/*.h"]),
defines = [
# Our MCU is the STM32F0251: https://www.st.com/resource/en/datasheet/stspin32f0251.pdf
"STM32F031x6",
# Use the Low-Layer APIs because it gives us more control over the hardware (as opposed to the HAL).
# https://www.st.com/content/ccc/resource/technical/document/user_manual/56/32/53/cb/69/86/49/0e/DM00223149.pdf/files/DM00223149.pdf/jcr:content/translations/en.DM00223149.pdf
"USE_FULL_LL_DRIVER",
],
)

openocd_flash(
name = "mdv6_firmware_flash",
device_configs = [
# Part of the STM32F0 family
# https://www.st.com/resource/en/reference_manual/rm0091-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
"target/stm32f0x.cfg",
],
# WARNING! `flash_offset` attribute is broken in the Bazel rule. The .elf file (mdv6_firmware_main.stripped)
# contains the memory mappings already, so this attribute is necessary.
flash_offset = "",
# .stripped strips debug symbols to reduce the size of the binary.
# see: https://bazel.build/reference/be/c-cpp#cc_binary
image = ":mdv6_firmware_main.stripped",
interface_configs = [
"interface/stlink.cfg", # The ST-Link V2 programmer is used to flash the firmware.
],
)
Loading
Loading