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

Develop #175

Merged
merged 14 commits into from
Dec 13, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
43 changes: 16 additions & 27 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
# Files excluded manually
Software/NUCLEO-F103RB/STM32F103RBTx_FLASH.ld linguist-vendored
Software/STM32F103RBTx/STM32F103RBTx_FLASH.ld linguist-vendored

#
# Folder/file matching for those files is a joke.
# Finally I made it using brute-force script:
# ls -lDR | grep ':$' | grep -e Middlewares -e Core -e FATFS -e CMSIS -eSTM32F1xx_HAL_Driver -e ST7735 | sed 's/:/\/* linguist-vendored/g' | sed 's/\.\///g'
#
Software/NUCLEO-F103RB/Core/* linguist-vendored
Software/NUCLEO-F103RB/Core/Inc/* linguist-vendored
Software/NUCLEO-F103RB/Core/Src/* linguist-vendored
Software/NUCLEO-F103RB/Core/Startup/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/CMSIS/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/CMSIS/Device/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/CMSIS/Device/ST/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/CMSIS/Device/ST/STM32F1xx/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/CMSIS/Device/ST/STM32F1xx/Include/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/CMSIS/Device/ST/STM32F1xx/Source/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/CMSIS/Include/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/ST7735/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/STM32F1xx_HAL_Driver/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/STM32F1xx_HAL_Driver/Inc/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/* linguist-vendored
Software/NUCLEO-F103RB/Drivers/STM32F1xx_HAL_Driver/Src/* linguist-vendored
Software/NUCLEO-F103RB/FATFS/* linguist-vendored
Software/NUCLEO-F103RB/FATFS/App/* linguist-vendored
Software/NUCLEO-F103RB/FATFS/Target/* linguist-vendored
Software/NUCLEO-F103RB/Middlewares/* linguist-vendored
Software/NUCLEO-F103RB/Middlewares/Third_Party/* linguist-vendored
Software/NUCLEO-F103RB/Middlewares/Third_Party/FatFs/* linguist-vendored
Software/NUCLEO-F103RB/Middlewares/Third_Party/FatFs/src/* linguist-vendored
Software/NUCLEO-F103RB/Middlewares/Third_Party/FatFs/src/option/* linguist-vendored

Software/STM32F103RBTx/Core/* linguist-vendored
Software/STM32F103RBTx/Core/Inc/* linguist-vendored
Software/STM32F103RBTx/Core/Src/* linguist-vendored
Software/STM32F103RBTx/Drivers/CMSIS/* linguist-vendored
Software/STM32F103RBTx/Drivers/CMSIS/Device/* linguist-vendored
Software/STM32F103RBTx/Drivers/CMSIS/Device/ST/* linguist-vendored
Software/STM32F103RBTx/Drivers/CMSIS/Device/ST/STM32F1xx/* linguist-vendored
Software/STM32F103RBTx/Drivers/CMSIS/Device/ST/STM32F1xx/Include/* linguist-vendored
Software/STM32F103RBTx/Drivers/CMSIS/Device/ST/STM32F1xx/Source/* linguist-vendored
Software/STM32F103RBTx/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/* linguist-vendored
Software/STM32F103RBTx/Drivers/CMSIS/Include/* linguist-vendored
Software/STM32F103RBTx/Drivers/STM32F1xx_HAL_Driver/* linguist-vendored
Software/STM32F103RBTx/Drivers/STM32F1xx_HAL_Driver/Inc/* linguist-vendored
Software/STM32F103RBTx/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/* linguist-vendored
Software/STM32F103RBTx/Drivers/STM32F1xx_HAL_Driver/Src/* linguist-vendored
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Define the flag to choose between X86 and ARM headers
set(USE_X86_HEADERS TRUE) # Set this to TRUE for X86, FALSE for ARM

add_subdirectory(Software/NUCLEO-F103RB/Application)
add_subdirectory(Software/STM32F103RBTx/Application)
add_subdirectory(Simulation/FirmwarePCSimulator)
add_subdirectory(Test/UT)

Expand Down
1 change: 0 additions & 1 deletion DevOps/BuildArtifacts/.gitignore

This file was deleted.

86 changes: 61 additions & 25 deletions DevOps/Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use an official Ubuntu base image
FROM ubuntu:20.04
FROM ubuntu:24.04

# Set the working directory
WORKDIR /workspace
Expand All @@ -18,14 +18,15 @@ RUN apt-get update && apt-get install -y \
clang-tools \
python3 \
python3-pip \
python3-dbg \
graphviz \
doxygen \
wget \
lld \
software-properties-common \
llvm-10-dev \
libclang-10-dev \
clang-10 \
llvm-15-dev \
libclang-15-dev \
clang-15 \
libgtest-dev \
libgmock-dev \
vim \
Expand All @@ -34,40 +35,75 @@ RUN apt-get update && apt-get install -y \
xsltproc \
plantuml \
libnewlib-arm-none-eabi \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
qt6-base-dev \
python3-pyqt6 \
python3-venv \
llvm-15 \
gdb \
strace \
elfutils \
file \
libxcb-cursor0 \
libxcb-cursor-dev \
libx11-xcb1 \
libxcb-render0 \
libxcb-shm0 \
libxcb-xfixes0 \
libxcb1 \
libxrender1 \
libxkbcommon-x11-0 \
libxcb-icccm4 \
libxcb-keysyms1 \
libxcb-image0 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-sync1 \
libxcb-xinerama0 \
libfontconfig1 \
libfreetype6 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Python-based tools in one step
RUN pip3 install \
# Create a virtual environment in /workspace/venv
RUN python3 -m venv /workspace/venv

# Activate the virtual environment and install the packages
RUN /workspace/venv/bin/pip install --upgrade pip && \
/workspace/venv/bin/pip install \
cpplint \
gprof2dot \
coverxygen \
hpp2plantuml
hpp2plantuml \
PyQt6

# Add virtual environment binaries to the PATH
ENV PATH="/workspace/venv/bin:$PATH"

# Set the QT_PLUGIN_PATH environment variable
ENV QT_PLUGIN_PATH="/workspace/venv/lib/python3.12/site-packages/PyQt6/Qt6/plugins"

# Install CMake manually (version 3.22.0)
RUN apt-get update && \
wget https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0-linux-x86_64.sh && \
mkdir /opt/cmake && \
sh cmake-3.22.0-linux-x86_64.sh --skip-license --prefix=/opt/cmake && \
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake && \
rm cmake-3.22.0-linux-x86_64.sh # Clean up
# RUN apt-get update && \
# wget https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0-linux-x86_64.sh && \
# mkdir /opt/cmake && \
# sh cmake-3.22.0-linux-x86_64.sh --skip-license --prefix=/opt/cmake && \
# ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake && \
# rm cmake-3.22.0-linux-x86_64.sh # Clean up

# Install include-what-you-use from source
RUN git clone https://github.com/include-what-you-use/include-what-you-use.git /usr/local/src/iwyu && \
cd /usr/local/src/iwyu && \
git checkout clang_10 && \
git pull && \
mkdir build && cd build && \
cmake -G "Unix Makefiles" .. && \
make -j $(nproc) && \
make install
# RUN git clone https://github.com/include-what-you-use/include-what-you-use.git /usr/local/src/iwyu && \
# cd /usr/local/src/iwyu && \
# git checkout clang_15 && \
# git pull && \
# mkdir build && cd build && \
# cmake -G "Unix Makefiles" .. && \
# make -j $(nproc) && \
# make install

# workaround for cppcheck html generator that needs older version
RUN pip uninstall -y pygments && pip install pygments==2.7.4

RUN pip uninstall -y pygments && \
pip install pygments==2.7.4

RUN mkdir -p /workspace/build
WORKDIR /workspace/build

Expand Down
40 changes: 37 additions & 3 deletions DevOps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
## Why?
For me, using Docker in embedded systems has a key advantage: it eliminates the need for a README filled with outdated commands for setting up the development environment. In reality, such lists are rarely kept up to date (I often forget to update them myself too!). Docker solves this problem by providing a structured list of everything you need to install to get your environment up and running. But it's more than just a list - it's code, meaning it can be verified, maintained, and reused easily.



## Prerequisites

* Install Docker. For Linux it should be simple, for Windows you need WSL installed first and some Linux image for it.
Expand All @@ -17,14 +15,23 @@ The idea is that we we will build image once and mount the project files, so tha

In the main directory (HardwareDataLogger) run the command to build the image.

Build the docker image:

docker-compose build dev

Start the Docker image:

docker-compose up -d

Log into the Docker image:

docker-compose exec dev bash

Additionally at the end of work:

docker-compose down --remove-orphans

## Running Include what you use

cd build

Expand All @@ -34,4 +41,31 @@ CC="clang-10" CXX="clang++-10" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-wh

for all the rest:

cmake ..
cmake ..


# Building and running Firmware PC Simulation

* Launch Docker as explained in the previous steps.
* Build the firmware in the PC variant:

cd /workspace/build/ && cmake .. && make -j24

* Start the simulation:

cd /workspace/Simulation/FirmwarePCSimulator/ && python3 main.py

* all at once:

cd /workspace/build/ && cmake .. && make -j24 && cd /workspace/Simulation/FirmwarePCSimulator/ && python3 main.py


### Troubleshooting:
The simulation is a desktop application that runs in Docker. Docker needs to be configured to display the simulation window. To test this, you can temporarily install some X11 applications and run them:

apt-get update && apt-get install -y x11-apps
xclock

If a small window with a clock is visible, it means everything is set up correctly.

Note: If using Windows, [MobaXterm](https://mobaxterm.mobatek.net/download-home-edition.html) (or another tool capable of displaying X11 windows) is required. The Visual Studio terminal will not work.
4 changes: 4 additions & 0 deletions Documentation/Diagrams/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.png
*.jpg
*.jpeg
*.gif
54 changes: 54 additions & 0 deletions Documentation/Diagrams/DisplayClassDiagram.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@startuml
abstract U8G2
class Display
class St7735DisplayDriver
class "stm32-st7735"
class "CubeMX HAL"
class MUIU8G2
class "User Defined Layouts"
class Hardware

U8G2 <|-- Display

Display *-- St7735DisplayDriver

St7735DisplayDriver ..> "CubeMX HAL" : uses

"stm32-st7735" .up.> St7735DisplayDriver : uses

"CubeMX HAL" --> Hardware : communicates via SPI

MUIU8G2 ..> U8G2 : uses

"User Defined Layouts" ..> MUIU8G2 : uses

"User Defined Layouts" ..> Display : uses

note on link
U8G2 and MUIU8G2 libraries are monochrome by default.
As a workaround, the color can be changed
directly through the Display class.
end note

' Note for "stm32-st7735"
note bottom of "stm32-st7735"
Library from STMicroelectronics
(not the commonly used stm32-st7735 library).
Implements communication with the ST7735 via SPI.
end note

' Note for "CubeMX HAL"
note as CubeMX_NOTE
Generated with CubeMX.
end note
"CubeMX HAL" .right. CubeMX_NOTE

' Note for U8G2 and MUIU8G2
note as U8G2_NOTE
Part of the u8g2 library,
providing GUI and fonts.
end note

MUIU8G2 .left. U8G2_NOTE
U8G2 .left. U8G2_NOTE
@enduml
1 change: 1 addition & 0 deletions Documentation/Diagrams/DisplayClassDiagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions Documentation/Diagrams/DisplaySequenceDiagram.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@startuml

box "MVC pattern"
participant "Controller" as CONTROLLER
participant "View" as VIEW
end box

participant "Device::Display" as DISPLAY
note right of DISPLAY
Device::Display
inherits from U8G2
end note

box "U8G2 library"
participant MUIU8G2
participant U8G2
end box

participant "Driver::St7735DisplayDriver" as DRIVER
box "STM library"
participant "stm32-st7735" as ST7735_LIB
end box

== Initialization ==

CONTROLLER --> DISPLAY : onInitialize
DISPLAY --> DRIVER : onInitialize
DISPLAY --> U8G2 : u8g2_Setup_st7735

DRIVER --> ST7735_LIB : Initialize hardware (TBD)
CONTROLLER --> VIEW: onInitialize
== Start ==

CONTROLLER --> DISPLAY : onStart
DISPLAY --> DRIVER : onStart
DRIVER --> ST7735_LIB : Configure settings (TBD)

CONTROLLER --> U8G2 : begin
CONTROLLER --> MUIU8G2 : begin

== Main Loop ==

VIEW --> MUIU8G2 : draw
MUIU8G2 --> U8G2 : u8x8_d_st7735
U8G2 --> DISPLAY : u8x8_d_st7735
DISPLAY --> DRIVER : drawBitmap
DRIVER --> ST7735_LIB : Send Data (TBD)

@enduml
Loading
Loading