Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .devcontainer/Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions .devcontainer/devcontainer.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Init submodules
run: |
git config --global --add safe.directory '*'
./tools/init-submodules.sh
./tools/init-submodules.sh
shell: bash

- name: Build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/format-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

- name: Setup Python
uses: actions/setup-python@v5
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build build-essential

- name: Cache simulator deps
uses: actions/cache@v4
with:
Expand All @@ -33,15 +33,15 @@ jobs:

- name: Configure (CMake)
run: |
cmake -S . -B out/build/simulator -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --preset simulator

- name: Build
run: |
cmake --build out/build/simulator
cmake --build --preset simulator

- name: Run tests (ctest)
run: |
ctest --test-dir out/build/simulator --no-tests=error --output-on-failure
ctest --preset simulator-all

- name: Upload test reports
if: always()
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ default_install_hook_types:
- pre-commit
- pre-push
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
}
],
"version": 4
}
}
123 changes: 29 additions & 94 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,107 +1,42 @@
{
"C_Cpp.default.cppStandard": "c++23",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 80}",
"C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 100}",
"C_Cpp.formatting": "clangFormat",
"C_Cpp.clang_format_style": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 80}",
"C_Cpp.clang_format_style": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 100}",
"C_Cpp.clang_format_sortIncludes": true,
"C_Cpp.intelliSenseCacheSize": 0,
"cmake.testExplorerIntegrationEnabled": true,
"cmake.defaultConfigurePreset": "simulator",
"cmake.defaultBuildPreset": "simulator",
"files.associations": {
<<<<<<< HEAD
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"barrier": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"coroutine": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cuchar": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"expected": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"latch": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"scoped_allocator": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"spanstream": "cpp",
"sstream": "cpp",
"stacktrace": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"syncstream": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
=======
"*.embeddedhtml": "html",
"mem.h": "c",
"tinydir.h": "c",
"dirent.h": "c",
"initializer_list": "cpp"
>>>>>>> origin/development
"initializer_list": "cpp",
"condition_variable": "cpp",
"chrono": "cpp",
"array": "cpp",
"*.tcc": "cpp",
"memory": "cpp",
"format": "cpp",
"istream": "cpp",
"functional": "cpp",
"tuple": "cpp",
"utility": "cpp",
"variant": "cpp",
"atomic": "cpp",
"string": "cpp",
"string_view": "cpp",
"ranges": "cpp",
"span": "cpp",
"bitset": "cpp",
"stacktrace": "cpp",
"regex": "cpp",
"valarray": "cpp",
"cstdlib": "cpp",
"mutex": "cpp",
"shared_mutex": "cpp"
}
}
27 changes: 26 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ option(USE_ETHERNET "Enable ethernet peripheral" OFF)
option(TARGET_NUCLEO "Targets the STM32H723 Nucleo development board" OFF)
option(USE_CCACHE "Use ccache if available" ON)
option(STLIB_USE_PCH "Enable precompiled headers for ST-LIB" ON)
option(STLIB_ENABLE_SANITIZERS "Enable AddressSanitizer + UBSan for simulator builds" OFF)
if(NOT DEFINED ENABLE_LTO)
if(CMAKE_CROSSCOMPILING)
set(ENABLE_LTO OFF)
Expand Down Expand Up @@ -79,6 +80,26 @@ endif()
message(STATUS "${PROJECT_NAME} Ethernet: ${USE_ETHERNET}")
message(STATUS "${PROJECT_NAME} Nucleo: ${TARGET_NUCLEO}")
message(STATUS "${PROJECT_NAME} Crosscompiling: ${CMAKE_CROSSCOMPILING}")
message(STATUS "${PROJECT_NAME} Sanitizers: ${STLIB_ENABLE_SANITIZERS}")

if(NOT CMAKE_CROSSCOMPILING)
add_library(stlib_sim_dev_flags INTERFACE)

if(STLIB_ENABLE_SANITIZERS)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(stlib_sim_dev_flags INTERFACE
-fsanitize=address,undefined
-fno-omit-frame-pointer
)
target_link_options(stlib_sim_dev_flags INTERFACE
-fsanitize=address,undefined
)
else()
message(WARNING "STLIB_ENABLE_SANITIZERS is ON but compiler does not support configured sanitizers")
endif()
endif()

endif()

if(CMAKE_CROSSCOMPILING)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/STM32CubeH7/Drivers)
Expand Down Expand Up @@ -430,6 +451,10 @@ set_target_properties(${STLIB_LIBRARY} PROPERTIES
C_STANDARD_REQUIRED YES
)

if(NOT CMAKE_CROSSCOMPILING)
target_link_libraries(${STLIB_LIBRARY} PUBLIC stlib_sim_dev_flags)
endif()

target_compile_definitions(${STLIB_LIBRARY} PUBLIC
$<$<BOOL:${CMAKE_CROSSCOMPILING}>:USE_HAL_DRIVER>
$<$<BOOL:${CMAKE_CROSSCOMPILING}>:STM32H723xx>
Expand Down Expand Up @@ -484,7 +509,7 @@ target_include_directories(${STLIB_LIBRARY} PUBLIC
$<$<NOT:$<BOOL:${CMAKE_CROSSCOMPILING}>>:${CMAKE_CURRENT_LIST_DIR}/Inc/MockedDrivers>
${CMAKE_CURRENT_LIST_DIR}/Inc/STM32CubeH7Wrapper

# LWIP includes
# LWIP includes
$<$<AND:$<BOOL:${CMAKE_CROSSCOMPILING}>,$<BOOL:${USE_ETHERNET}>>:${LWIP_DIR}/src/include>
$<$<AND:$<BOOL:${CMAKE_CROSSCOMPILING}>,$<BOOL:${USE_ETHERNET}>>:${LWIP_DIR}/system>
$<$<AND:$<BOOL:${CMAKE_CROSSCOMPILING}>,$<BOOL:${USE_ETHERNET}>>:${LWIP_DIR}/src/netif/ppp>
Expand Down
46 changes: 46 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "simulator-asan",
"displayName": "Simulator [ASAN+UBSAN]",
"inherits": [
"sim"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"STLIB_ENABLE_SANITIZERS": "ON"
}
}
],
"buildPresets": [
Expand Down Expand Up @@ -269,6 +280,41 @@
{
"name": "simulator",
"configurePreset": "simulator"
},
{
"name": "simulator-asan",
"configurePreset": "simulator-asan"
}
],
"testPresets": [
{
"name": "simulator-all",
"configurePreset": "simulator",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error"
}
},
{
"name": "simulator-adc",
"inherits": "simulator-all",
"filter": {
"include": {
"name": "ADCTest"
}
}
},
{
"name": "simulator-all-asan",
"configurePreset": "simulator-asan",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error"
}
}
]
}
2 changes: 1 addition & 1 deletion Inc/C++Utilities/Stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ template <typename T, size_t S> class Stack {
size_t top_idx;
};

#endif // STACK_HPP
#endif // STACK_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ class DataWatchpointTrace {
}
}
}
};
};
2 changes: 1 addition & 1 deletion Inc/HALAL/Models/DMA/DMA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ class DMA {
private:
static vector<Stream> available_streams;
static vector<Stream> inscribed_streams;
};
};
1 change: 1 addition & 0 deletions Inc/HALAL/Models/DMA/DMA2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ struct DMA_Domain {
return (IRQn_Type)0;
else
compile_error("No tiene que llegar aqui nunca, creo");
return (IRQn_Type)0;
}

static constexpr inline bool is_one_of(Peripheral instance, auto... bases) {
Expand Down
2 changes: 1 addition & 1 deletion Inc/HALAL/Models/Packets/MdmaPacket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,4 @@ struct MdmaPacketDomain {
};
};

#endif // MDMA_PACKET_HPP
#endif // MDMA_PACKET_HPP
2 changes: 1 addition & 1 deletion Inc/HALAL/Models/SPI/SPI2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,4 +1458,4 @@ struct SPIDomain {

} // namespace ST_LIB

#endif // SPI2_HPP
#endif // SPI2_HPP
Loading