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

Update docker image, reduce binary sizes, and fix tests #335

Merged
merged 10 commits into from
Dec 14, 2024
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "STS1 COBC",
"image": "tuwienspaceteam/sts1-cobc:1.10.0",
"image": "tuwienspaceteam/sts1-cobc:1.12.0",
"customizations": {
"vscode": {
"extensions": [
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
jobs:
format-and-spell-check:
runs-on: ubuntu-latest
container: tuwienspaceteam/sts1-cobc:1.10.0-linux-x86
container: tuwienspaceteam/sts1-cobc:1.12.0-linux-x86

steps:
- uses: actions/checkout@v4
Expand All @@ -43,7 +43,7 @@ jobs:
needs: format-and-spell-check

runs-on: ubuntu-latest
container: tuwienspaceteam/sts1-cobc:1.10.0-linux-x86
container: tuwienspaceteam/sts1-cobc:1.12.0-linux-x86

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
needs: format-and-spell-check

runs-on: ubuntu-latest
container: tuwienspaceteam/sts1-cobc:1.10.0-linux-x86
container: tuwienspaceteam/sts1-cobc:1.12.0-linux-x86

steps:
- uses: actions/checkout@v4
Expand All @@ -97,7 +97,7 @@ jobs:
needs: format-and-spell-check

runs-on: ubuntu-latest
container: tuwienspaceteam/sts1-cobc:1.10.0
container: tuwienspaceteam/sts1-cobc:1.12.0

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
needs: format-and-spell-check

runs-on: ubuntu-latest
container: tuwienspaceteam/sts1-cobc:1.10.0-linux-x86
container: tuwienspaceteam/sts1-cobc:1.12.0-linux-x86

steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 3 additions & 5 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"name": "clang-tidy",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=${sourceDir}/*"
"CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=${sourceDir}/*;--extra-arg=-fsized-deallocation"
}
},
{
Expand Down Expand Up @@ -81,9 +81,7 @@
"hidden": true,
"inherits": "warnings-unix",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "$env{WARNINGS}",
"CMAKE_CXX_FLAGS_DEBUG": "-O0 -g -DDEBUG",
"CMAKE_CXX_FLAGS_RELEASE": "-Os"
"CMAKE_CXX_FLAGS": "$env{WARNINGS}"
}
},
{
Expand All @@ -95,7 +93,7 @@
"cpp-std"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_BUILD_TYPE": "MinSizeRel",
"USE_CCACHE": "OFF"
}
},
Expand Down
4 changes: 1 addition & 3 deletions Sts1CobcSw/CobcSoftware/CommandParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include <Sts1CobcSw/Edu/Edu.hpp>
#include <Sts1CobcSw/Edu/ProgramQueue.hpp>
#include <Sts1CobcSw/Serial/Serial.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>

#include <strong_type/type.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>

#include <cinttypes> // IWYU pragma: keep

Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/CobcSoftware/EduCommunicationErrorThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <Sts1CobcSw/Edu/Edu.hpp>
#include <Sts1CobcSw/FramSections/FramLayout.hpp>
#include <Sts1CobcSw/FramSections/PersistentVariables.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>

#include <strong_type/difference.hpp>
Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/CobcSoftware/EduHeartbeatThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Sts1CobcSw/CobcSoftware/TopicsAndSubscribers.hpp>
#include <Sts1CobcSw/Hal/GpioPin.hpp>
#include <Sts1CobcSw/Hal/IoNames.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>
#include <Sts1CobcSw/Utility/TimeTypes.hpp>

Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/CobcSoftware/EduPowerManagementThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <Sts1CobcSw/Edu/Edu.hpp>
#include <Sts1CobcSw/Hal/GpioPin.hpp>
#include <Sts1CobcSw/Hal/IoNames.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>
#include <Sts1CobcSw/Utility/TimeTypes.hpp>

Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/CobcSoftware/EduProgramQueueThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <Sts1CobcSw/Edu/Types.hpp>
#include <Sts1CobcSw/FramSections/RingArray.hpp>
#include <Sts1CobcSw/ProgramId/ProgramId.hpp> // IWYU pragma: keep
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/RealTime.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>
#include <Sts1CobcSw/Utility/TimeTypes.hpp>
Expand Down
5 changes: 3 additions & 2 deletions Sts1CobcSw/CobcSoftware/FlashStartupTestThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#include <Sts1CobcSw/FramSections/FramLayout.hpp>
#include <Sts1CobcSw/FramSections/PersistentVariables.hpp>
#include <Sts1CobcSw/Periphery/Flash.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>

#include <rodos_no_using_namespace.h>


namespace sts1cobcsw
{
constexpr auto stackSize = 100U;
// Running the SpiSupervisor HW test showed that the minimum required stack size is ~560 bytes
constexpr auto stackSize = 600;


class FlashStartupTestThread : public RODOS::StaticThread<stackSize>
Expand Down
5 changes: 3 additions & 2 deletions Sts1CobcSw/CobcSoftware/FramEpsStartupTestThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <Sts1CobcSw/FramSections/PersistentVariables.hpp>
#include <Sts1CobcSw/Periphery/Eps.hpp>
#include <Sts1CobcSw/Periphery/Fram.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/ErrorDetectionAndCorrection.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>

Expand All @@ -17,7 +17,8 @@

namespace sts1cobcsw
{
constexpr auto stackSize = 100U;
// Running the SpiSupervisor HW test showed that the minimum required stack size is ~800 bytes
constexpr auto stackSize = 850;


class FramEpsStartupTestThread : public RODOS::StaticThread<stackSize>
Expand Down
5 changes: 3 additions & 2 deletions Sts1CobcSw/CobcSoftware/RfStartupTestThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#include <Sts1CobcSw/FramSections/FramLayout.hpp>
#include <Sts1CobcSw/FramSections/PersistentVariables.hpp>
#include <Sts1CobcSw/Periphery/Rf.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>

#include <rodos_no_using_namespace.h>


namespace sts1cobcsw
{
constexpr auto stackSize = 100U;
// Running the SpiSupervisor HW test showed that the minimum required stack size is ~765 bytes
constexpr auto stackSize = 800;


class RfStartupTestThread : public RODOS::StaticThread<stackSize>
Expand Down
14 changes: 7 additions & 7 deletions Sts1CobcSw/CobcSoftware/SpiStartupTestAndSupervisorThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
#include <Sts1CobcSw/Hal/Spi.hpp>
#include <Sts1CobcSw/Periphery/Fram.hpp>
#include <Sts1CobcSw/Periphery/Spis.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/ErrorDetectionAndCorrection.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>
#include <Sts1CobcSw/Utility/TimeTypes.hpp>

#include <strong_type/affine_point.hpp>
Expand All @@ -25,11 +24,10 @@

namespace sts1cobcsw
{
// Running the integration test for the supervisor thread showed that at least 850 bytes are needed
constexpr auto stackSize = 900U + EXTRA_SANITIZER_STACK_SIZE;
constexpr auto initialSleepTime = 10 * ms;
// TODO: Measure how long the startup tests really take to determine the correct timeout
constexpr auto startupTestTimeout = 100 * ms;
// Running the golden test for the supervisor thread showed that at least 850 bytes are needed
constexpr auto stackSize = 900 + EXTRA_SANITIZER_STACK_SIZE;

inline constexpr auto initialSleepTime = 10 * ms;
// TODO: Think about how often the supervision should run
constexpr auto supervisionPeriod = 1 * s;

Expand Down Expand Up @@ -95,6 +93,8 @@ class SpiStartupTestAndSupervisorThread : public RODOS::StaticThread<stackSize>
DEBUG_PRINT("%s", errorMessage);
persistentVariables.template Store<"rfIsWorking">(false);
persistentVariables.template Increment<"nRfErrors">();
DEBUG_PRINT("Resetting and rebooting in 2 s\n");
// TODO: Add a named constant for this delay
SuspendFor(2 * s);
RODOS::hwResetAndReboot();
}
Expand Down
8 changes: 8 additions & 0 deletions Sts1CobcSw/CobcSoftware/SpiStartupTestAndSupervisorThread.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#pragma once


#include <Sts1CobcSw/Utility/RodosTime.hpp>

#include <strong_type/difference.hpp>


namespace sts1cobcsw
{
// TODO: Measure how long the startup tests really take to determine the correct timeouts
inline constexpr auto startupTestTimeout = 100 * ms;
inline constexpr auto totalStartupTestTimeout = 3 * startupTestTimeout + 50 * ms;
auto ResumeSpiStartupTestAndSupervisorThread() -> void;
}
2 changes: 1 addition & 1 deletion Sts1CobcSw/CobcSoftware/StartupTestThreadStubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <Sts1CobcSw/FramSections/FramLayout.hpp>
#include <Sts1CobcSw/FramSections/PersistentVariables.hpp>
#include <Sts1CobcSw/Periphery/Fram.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/ErrorDetectionAndCorrection.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>

Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/Edu/Edu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <Sts1CobcSw/Serial/Byte.hpp>
#include <Sts1CobcSw/Serial/Serial.hpp>
#include <Sts1CobcSw/Utility/Crc32Software.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/RodosTime.hpp>
#include <Sts1CobcSw/Utility/Span.hpp>

Expand Down
4 changes: 1 addition & 3 deletions Sts1CobcSw/Edu/EduMock.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include <Sts1CobcSw/Edu/Edu.hpp> // IWYU pragma: associated
#include <Sts1CobcSw/Edu/Types.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>

#include <strong_type/type.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>

#include <cinttypes> // IWYU pragma: keep

Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/FramSections/RingArray.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


#include <Sts1CobcSw/FramSections/RingArray.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>
#include <Sts1CobcSw/Utility/Span.hpp>


Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/HelloDummy.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Sts1CobcSw/Dummy.hpp>
#include <Sts1CobcSw/Utility/Debug.hpp>
#include <Sts1CobcSw/Utility/DebugPrint.hpp>

#include <rodos_no_using_namespace.h>

Expand Down
3 changes: 3 additions & 0 deletions Sts1CobcSw/Utility/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ target_link_libraries(
Sts1CobcSw_Utility PUBLIC etl::etl rodos::without_main_on_linux strong_type::strong_type
Sts1CobcSw_Serial
)
target_compile_definitions(
Sts1CobcSw_Utility PUBLIC $<$<CONFIG:Debug,RelWithDebInfo>:ENABLE_DEBUG_PRINT>
)

if(CMAKE_SYSTEM_NAME STREQUAL Generic)
target_sources(Sts1CobcSw_Utility PRIVATE Crc32Hardware.cpp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <cinttypes>


#ifdef DEBUG
#ifdef ENABLE_DEBUG_PRINT
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, *variadic-macro-arguments)
Expand Down
3 changes: 2 additions & 1 deletion Tests/GoldenTests/SpiSupervisor.test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <Sts1CobcSw/CobcSoftware/SpiStartupTestAndSupervisorThread.hpp>
#include <Sts1CobcSw/Hal/Spi.hpp>
#include <Sts1CobcSw/Hal/SpiMock.hpp>
#include <Sts1CobcSw/Periphery/Fram.hpp>
Expand Down Expand Up @@ -61,7 +62,7 @@ class SpiSupervisorTest : public RODOS::StaticThread<>

void run() override
{
SuspendFor(100 * ms);
SuspendFor(totalStartupTestTimeout);

PRINTF("\nSPI supervisor test\n\n");

Expand Down
31 changes: 28 additions & 3 deletions Tests/HardwareTests/Littlefs.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class LittlefsTest : public RODOS::StaticThread<stackSize>
{
EnableRfLatchupProtection();

PRINTF("\n\n");
PRINTF("littlefs test\n");
PRINTF("\n\nlittlefs test\n");

PRINTF("\n");
auto lfs = lfs_t{};
Expand All @@ -56,7 +55,6 @@ class LittlefsTest : public RODOS::StaticThread<stackSize>
PRINTF("Creating directory '%s' ...\n", directoryPath);
errorCode = lfs_mkdir(&lfs, directoryPath);
Check(errorCode == 0);

PRINTF("\n");
auto const * filePath = "MyFolder/MyFile";
PRINTF("Creating file '%s' ...\n", filePath);
Expand Down Expand Up @@ -92,6 +90,33 @@ class LittlefsTest : public RODOS::StaticThread<stackSize>
PRINTF("Closing file ...\n");
errorCode = lfs_file_close(&lfs, &file);
Check(errorCode == 0);

PRINTF("\n");
PRINTF("Removing the non-empty directory '%s' should fail ...\n", directoryPath);
errorCode = lfs_remove(&lfs, directoryPath);
PRINTF("Error code = %d == %d\n", errorCode, LFS_ERR_NOTEMPTY);
Check(errorCode == LFS_ERR_NOTEMPTY);
PRINTF("Removing the file '%s' ...\n", filePath);
errorCode = lfs_remove(&lfs, filePath);
Check(errorCode == 0);
PRINTF("Removing the empty directory '%s' ...\n", directoryPath);
errorCode = lfs_remove(&lfs, directoryPath);
Check(errorCode == 0);

PRINTF("\n");
PRINTF("Unmounting ...\n");
errorCode = lfs_unmount(&lfs);
Check(errorCode == 0);

PRINTF("\n");
if(AllChecksPassed())
{
PRINTF("ALL CHECKS PASSED :)\n");
}
else
{
PRINTF("SOME CHECKS FAILED :(\n");
}
}
} littlefsTest;
}
Loading
Loading