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

Upgrade STM32CubeMX version from 5.3.0 -> 6.9.2 #1016

Merged
merged 30 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6326b9c
upgrade version for dim
gtaharaedmonds Oct 10, 2023
162f7ee
upgrade BMS
gtaharaedmonds Oct 10, 2023
b93a45a
upgrade other boards
gtaharaedmonds Oct 10, 2023
f0f5e61
bump container
gtaharaedmonds Oct 10, 2023
288ed3e
update workflows temporarily
gtaharaedmonds Oct 10, 2023
0b09862
whoops
gtaharaedmonds Oct 10, 2023
c3e014b
fixup container
gtaharaedmonds Oct 10, 2023
e89f9e4
maybe
gtaharaedmonds Oct 10, 2023
ddadda9
maybe 2
gtaharaedmonds Oct 10, 2023
dbe7cdc
maybe maybe
gtaharaedmonds Oct 10, 2023
aea2a0d
maybe v4
gtaharaedmonds Oct 10, 2023
40d6249
maybe v5
gtaharaedmonds Oct 10, 2023
1031505
maybe actually
gtaharaedmonds Oct 10, 2023
7f2a77e
update workflow
gtaharaedmonds Oct 10, 2023
c2f8e94
fixup again
gtaharaedmonds Oct 10, 2023
27a270d
test 6
gtaharaedmonds Oct 10, 2023
db63c8b
test
gtaharaedmonds Oct 10, 2023
2cf9ce4
finally fixed?
gtaharaedmonds Oct 10, 2023
5ea6bb0
Finally fixed?
gtaharaedmonds Oct 10, 2023
288cb32
finally
gtaharaedmonds Oct 10, 2023
09a2be3
test stuff maybe
gtaharaedmonds Oct 12, 2023
de516e3
fix osDelayUntil for DCM
gtaharaedmonds Oct 13, 2023
f613bfe
fix the rest of boards and lint
gtaharaedmonds Oct 13, 2023
91f58dc
pcan project
gtaharaedmonds Oct 13, 2023
49481a6
address broken CI and PR review
gtaharaedmonds Oct 14, 2023
2e6d9e9
rebase
gtaharaedmonds Oct 24, 2023
0a1bc87
Merge branch 'master' into gus/upgrade_stm32cubemx_version
gtaharaedmonds Oct 25, 2023
cbc0bad
Merge branch 'master' into gus/upgrade_stm32cubemx_version
gtaharaedmonds Oct 29, 2023
5c29ab2
Merge branch 'master' into gus/upgrade_stm32cubemx_version
gtaharaedmonds Nov 1, 2023
9088569
revert container tag back to latest
gtaharaedmonds Nov 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# The STM32CubeMX installer is >100MB and must be tracked by git lfs
environment/data/en.STM32CubeMX_v5-3-0.zip filter=lfs diff=lfs merge=lfs -text
environment/data/en.stm32cubemx-lin-v6-9-2.zip filter=lfs diff=lfs merge=lfs -text
57 changes: 57 additions & 0 deletions .github/workflows/bin-dbc-gen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Add Binary and DBC to Releases tab
on:
push:
branches:
- master

jobs:
build:
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}}
with:
upload_artifact: true
generate-dbc:
name: Generate CAN DBC file
runs-on: ubuntu-22.04
container:
image: ubcformulaelectric/environment:latest
credentials:
username: ubcformulaelectric
password: ${{ secrets.docker_token }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with: # TODO check if submodules are required (can be optimized away)
submodules: recursive
- name: Generate DBC
run: |
python3 scripts/code_generation/jsoncan/generate_can_from_json.py --only_dbc --can_data_dir "can_bus/json" --dbc_output "can_bus/dbcs/CanMsgs.dbc"
- name: Upload DBC to Artifact
uses: actions/upload-artifact@v2
with:
name: CanMsgs.dbc
path: ./can_bus/dbcs/CanMsgs.dbc
make-release:
name: Add Binaries and DBC to Release Tab
runs-on: ubuntu-22.04
needs: [build, generate-dbc]
steps:
- name: Download Binaries and DBC from Artifacts
uses: actions/download-artifact@v2
- name: Create Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
title: "Binaries and DBCs"
tag: ${{ github.sha }}
prerelease: false
files: |
FSM.elf
BMS.elf
DCM.elf
DIM.elf
GSM.elf
PDM.elf
CanMsgs.dbc
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ jobs:
# It fakes out a display, since STM32CubeMX throws an error if it doesn't detect a display
- name: Generate code
run: |
echo "test: $GITHUB_WORKSPACE"
xvfb-run python3 scripts/utilities/generate_cube_code.py \
--board ${{ matrix.board }} \
--log4j_properties_output ~/.stm32cubemx/log4j.properties \
--ioc ${{ matrix.ioc_dir }}/${{ matrix.board }}.ioc \
--codegen_output_dir ${{ matrix.ioc_dir }} \
--ioc $GITHUB_WORKSPACE/${{ matrix.ioc_dir }}/${{ matrix.board }}.ioc \
--codegen_output_dir $GITHUB_WORKSPACE/${{ matrix.ioc_dir }} \
--cube_bin /usr/local/STM32CubeMX/STM32CubeMX

- name: Fix formatting
Expand All @@ -86,7 +87,7 @@ jobs:
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}}
docker_token: ${{ secrets.DOCKER_TOKEN }}

test-thruna:
needs: [ clang-format ]
Expand Down
4 changes: 2 additions & 2 deletions can_bus/PcanProject.peproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<PCANExplorerProject Version="6.0" AppVersion="6.6.1" Name="PcanProject">
<PCANExplorerProject Version="6.0" AppVersion="6.4.1" Name="PcanProject">
<Connections AutoReset="0" IgnoreRTRLength="0" ProcessRTR="1">
<Connection Name="Connection1" Bus="1" Enabled="1" Protocol="0" SymbolsFileName="CanMsgs.dbc" BitRate="28" Connection="PCAN-USB2@pcan_usb"/>
<Connection Name="Connection1" Bus="1" Enabled="1" Protocol="0" SymbolsFileName="CanMsgs.dbc" BitRate="28" Connection="Car@pcan_usb"/>
</Connections>
<Files>
<File RelativePath="dbcs\CanMsgs.dbc"/>
Expand Down
23 changes: 9 additions & 14 deletions environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ FROM ubuntu:22.04
# pip: For installing python packages
# git: For pulling external repos, invoked via cmake
# git-lfs: Large file storage, used for saving zipped STM32CubeMX installer
# openjdk-11-jdk: Java, required to install and run STM32CubeMX
# xvfb: Virtual frame buffer service, mocks out a display which doesn't exist on the CI machines
# (required to run STM32CubeMX without a GUI)
# libncurses5: Library required by clang-format
# valgrind: Used to check for memory leaks during x86 tests
# openocd: Our embedded GDB server of choice
# usbutils: USB tools (lsusb)
# nano: Basic Unix text editor
# libgtk-3-0: Random library required for running STM32CubeMX in container
# libxi6: Random library required for running STM32CubeMX V6 in container
# libxtst6: Random library required for running STM32CubeMX V6 in container
# libxrender1: Random library required for running STM32CubeMX V6 in container
RUN apt update -y && apt install -y \
gtaharaedmonds marked this conversation as resolved.
Show resolved Hide resolved
wget \
unzip \
Expand All @@ -23,14 +23,13 @@ RUN apt update -y && apt install -y \
xvfb \
libncurses5 \
valgrind \
libgtk-3-0 \
libxi6 \
libxtst6 \
libxrender1

COPY . /root/environment/

# Install SEGGER JLink tools.
WORKDIR /root/environment/data
RUN mkdir /opt/SEGGER
RUN tar -xf JLink_Linux_V792c_x86_64.tgz -C /opt/SEGGER

# Install python package dependencies.
WORKDIR /root/environment/scripts
RUN pip3 install -r ../requirements.txt
Expand All @@ -39,12 +38,8 @@ RUN pip3 install -r ../requirements.txt
RUN /bin/sh install_gcc_arm_none_eabi.sh /usr/local

# Install STM32CubeMX for auto-generating code.
RUN python3 install_stm32cubemx.py --install-dir /usr/local/STM32CubeMX --cube-zip ../data/en.STM32CubeMX_v5-3-0.zip
RUN python3 install_stm32cubemx.py --install-dir /usr/local/STM32CubeMX --cube-zip ../data/en.stm32cubemx-lin-v6-9-2.zip

# Cleanup copied directory.
WORKDIR /root/
RUN rm -rf environment

# Environment variable "force_color_prompt" needs to be set to "yes" to get colored output in shell.
# Hacky fix since we currently don't volume the bashrc, append the line "force_color_prompt=yes" to the top of root's bashrc.
RUN sed -i '1s/^/force_color_prompt=yes\n\n/' /root/.bashrc
Binary file removed environment/data/JLink_Linux_V792c_x86_64.tgz
Binary file not shown.
3 changes: 0 additions & 3 deletions environment/data/en.STM32CubeMX_v5-3-0.zip

This file was deleted.

3 changes: 3 additions & 0 deletions environment/data/en.stm32cubemx-lin-v6-9-2.zip
Git LFS file not shown
34 changes: 34 additions & 0 deletions environment/run_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# CI container image.
IMAGE="ubcformulaelectric/environment:latest"

# Check if the image exists locally.
if [[ "$(docker images -q ${IMAGE} 2> /dev/null)" == "" ]]; then
echo "Image '${IMAGE}' not found locally. Pulling from repository..."

# Pull the image from the repository.
docker pull ${IMAGE}

# Check if the pull was successful.
if [[ $? -eq 0 ]]; then
echo "Image pulled successfully."
else
echo "Failed to pull the image."
exit 1
fi
else
echo "Image '${IMAGE}' found locally."
fi

ENVIRONMENT_DIR="$(cd "$(dirname "$0")" && pwd)" # Directory of this script
REPO_ROOT_DIR="${ENVIRONMENT_DIR}/.." # Path to repo root
CONTAINER_MOUNT_DIR="/root/Consolidated-Firmware" # Directory in container to mount repo

# Run container, and mount local repo.
docker run \
--rm \
-it \
--mount type=bind,source=${REPO_ROOT_DIR},target=${CONTAINER_MOUNT_DIR} \
${IMAGE} \
bash
67 changes: 38 additions & 29 deletions environment/scripts/install_stm32cubemx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import argparse
import subprocess

CUBE_AUTO_INSTALL_XML = '''\
CUBE_AUTO_INSTALL_XML = """\
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<AutomatedInstallation langpack="eng">
<com.st.microxplorer.install.MXHTMLHelloPanel id="readme"/>
Expand All @@ -19,14 +19,16 @@
<com.st.microxplorer.install.MXInstallPanel id="install.panel"/>
<com.st.microxplorer.install.MXFinishPanel id="finish.panel"/>
</AutomatedInstallation>
'''
"""


def _isWindows():
"""
Check if the operating system is Windows
:return: True if using Windows, false otherwise
"""
return os.name == 'nt'
return os.name == "nt"


def install_stm32cubemx(install_dir, installer_zip):
"""
Expand All @@ -36,58 +38,65 @@ def install_stm32cubemx(install_dir, installer_zip):
@param installer_zip: STM32CubeMX installer zip file
"""
# Return early if the installer extension is not we expect
installer_extension = '.zip'
installer_extension = ".zip"
if not installer_zip.lower().endswith(installer_extension):
raise Exception('Expect: STM32CubeMX installer ({}) => Actual: {}'.format(installer_extension, installer_zip))
raise Exception(
f"Expect: STM32CubeMX installer ({installer_extension}) => Actual: {installer_zip}"
)

# Extract STM32CubeMX
extract_dir = os.path.join("/tmp", "STM32CubeMXSetup")
child = subprocess.Popen(["unzip", "-o", installer_zip, "-d", extract_dir])
child.wait()
if child.returncode != 0:
raise Exception(f"Failed to unzip {installer_zip}")

# Generate output folder if they don't exist already
auto_install_xml_dir = os.path.join('.', 'auto_generated')
# Generate output folder for autogenerated install XML if it doesn't exist already
auto_install_xml_dir = os.path.join(extract_dir, "auto_generated")
if not os.path.exists(auto_install_xml_dir):
os.mkdir(auto_install_xml_dir)

# Generate .xml that specifies the STM32CubeMX installation path
auto_install_xml = os.path.join(auto_install_xml_dir, 'cube-auto-install.xml')
auto_install_xml_f = open(auto_install_xml, 'w')
auto_install_xml = os.path.join(auto_install_xml_dir, "cube-auto-install.xml")
auto_install_xml_f = open(auto_install_xml, "w")
auto_install_xml_f.write(CUBE_AUTO_INSTALL_XML.format(CUBE_INSTALL_DIR=install_dir))
auto_install_xml_f.close()

# Extract STM32CubeMX
extract_dir = os.path.join('/tmp', 'STM32CubeMXSetup')
child = subprocess.Popen(['unzip', '-o', installer_zip, '-d', extract_dir])
child.wait()
if child.returncode is not 0:
Exception('Failed to unzip {}'.format(installer_zip))

# Find STM32CubeMX installer
cube_installer = ''
cube_installer_extension = '.exe'
cube_installer = None
for f in os.listdir(extract_dir):
if f.endswith(cube_installer_extension):
if f.startswith("SetupSTM32CubeMX"):
cube_installer = os.path.join(extract_dir, f)
if cube_installer == '':
Exception('Did not find a STM32CubeMX installer ({})'.format(cube_installer_extension))

if cube_installer == None:
raise Exception(f"Did not find a STM32CubeMX installer ({extract_dir})")

# Run STM32CubeMX installer
child = subprocess.Popen(['java', '-jar', cube_installer, auto_install_xml_f.name])
installer_dir = os.path.dirname(cube_installer)
installer_bin = os.path.basename(cube_installer)
child = subprocess.Popen(
[f"./{installer_bin}", auto_install_xml_f.name], cwd=installer_dir
)
child.wait()
if child.returncode is not 0:
Exception('Failed to install {}'.format(installer_zip))
if child.returncode != 0:
raise Exception(f"Failed to install {installer_zip}")

try:
if _isWindows():
subprocess.call(["where", "STM32CubeMX"])
else:
subprocess.call(["which", "STM32CubeMX"])
except OSError as e:
Exception('Could not verifiy that STM32CubeMX was installed correctly...' )
raise Exception("Could not verifiy that STM32CubeMX was installed correctly...")

print("Verified that STM32CubeMX was installed correctly!")

print('Verified that STM32CubeMX was installed correctly!')

if __name__ == '__main__':
if __name__ == "__main__":
# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument('--install-dir', help='STM32CubeMX installation directory')
parser.add_argument('--cube-zip', help='STM32CubeMX installer zip')
parser.add_argument("--install-dir", help="STM32CubeMX installation directory")
parser.add_argument("--cube-zip", help="STM32CubeMX installer zip")
args = parser.parse_args()

install_stm32cubemx(args.install_dir, args.cube_zip)
2 changes: 1 addition & 1 deletion firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(NOT STM32CUBEMX_BIN_PATH)
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
set(STM32CUBEMX_BIN_PATH "/Applications/STMicroelectronics/STM32CubeMX.app/Contents/MacOs/STM32CubeMX")
else()
set(STM32CUBEMX_BIN_PATH /usr/local/STM32CubeMX/STM32CubeMX)
set(STM32CUBEMX_BIN_PATH "/usr/local/STM32CubeMX/STM32CubeMX")
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion firmware/shared/src/io/Io_SharedHeartbeatMonitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

uint32_t Io_SharedHeartbeatMonitor_GetCurrentMs(void)
{
return osKernelSysTick() * portTICK_RATE_MS;
return osKernelGetTickCount() * portTICK_RATE_MS;
}
2 changes: 1 addition & 1 deletion firmware/shared/src/io/Io_SharedSoftwareWatchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void Io_SharedSoftwareWatchdog_CheckForTimeouts(void)
if (sw_watchdog_table.watchdogs[i].initialized == false)
continue;

if (osKernelSysTick() >= sw_watchdog_table.watchdogs[i].deadline)
if (osKernelGetTickCount() >= sw_watchdog_table.watchdogs[i].deadline)
{
// Check if the check-in status is set
if (sw_watchdog_table.watchdogs[i].check_in_status == true)
Expand Down
2 changes: 1 addition & 1 deletion firmware/shared/src/io/io_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

uint32_t io_time_getCurrentMs(void)
{
return osKernelSysTick() * portTICK_RATE_MS;
return osKernelGetTickCount() * portTICK_RATE_MS;
}
Loading