From 5a56ce394fc2832eae9b8a8a577eee1228540abf Mon Sep 17 00:00:00 2001 From: "Jasper v. Blanckenburg" Date: Tue, 23 May 2023 02:51:40 +0200 Subject: [PATCH] Make simulator compile --- Core/Inc/util.h | 8 +++++++- Core/Src/leds.c | 4 ++-- STM32-for-VSCode.config.yaml | 12 +++++++++++- STM32Make.make | 4 ++-- TouchGFX/App/app_touchgfx.c | 2 ++ TouchGFX/config/gcc/app.mk | 2 +- .../gui/src/driverview_screen/DriverViewView.cpp | 2 +- .../src/vehicleconfig_screen/VehicleConfigView.cpp | 2 +- TouchGFX/steering-wheel.touchgfx | 2 ++ 9 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Core/Inc/util.h b/Core/Inc/util.h index c7e76b4..899cb2d 100644 --- a/Core/Inc/util.h +++ b/Core/Inc/util.h @@ -4,8 +4,14 @@ // This is wacky preprocessor magic that allows us to count the number of // members of an enum. Unfortunately, it doesn't work with enum classes, so we // have to use C-style enums. + +// The preprocessor magic is so wacky we have to prevent GCC from failing with a +// -Werror=pedantic when compiling the simulator +#pragma GCC diagnostic ignored "-Wpedantic" + #define CountedEnum(NAME, TYPE, ...) \ typedef enum { __VA_ARGS__ } NAME; \ - static const size_t NAME##_COUNT = sizeof((int[]){__VA_ARGS__}) / sizeof(int); + static const size_t NAME##_COUNT = \ + sizeof(__extension__(int[]){__VA_ARGS__}) / sizeof(int); #endif // INC_UTIL_H diff --git a/Core/Src/leds.c b/Core/Src/leds.c index 4b56859..0fe8b83 100644 --- a/Core/Src/leds.c +++ b/Core/Src/leds.c @@ -230,7 +230,7 @@ void led_anim_blinker(uint8_t r, uint8_t g, uint8_t b, colors[i][1] = g * i / (brightness_steps - 1); colors[i][2] = b * i / (brightness_steps - 1); } - size_t simultaneous_leds = brightness_steps / next_led_steps; + int32_t simultaneous_leds = brightness_steps / next_led_steps; if (simultaneous_leds * next_led_steps != brightness_steps) { simultaneous_leds++; } @@ -239,7 +239,7 @@ void led_anim_blinker(uint8_t r, uint8_t g, uint8_t b, int32_t furthest = 0; size_t color_idx = 0; while (furthest < 5 + simultaneous_leds) { - for (size_t offset = 0; offset < simultaneous_leds; offset++) { + for (int32_t offset = 0; offset < simultaneous_leds; offset++) { int32_t diff = furthest - offset; size_t led_color_idx = color_idx + offset * next_led_steps; if (diff < 0 || diff > 4 || led_color_idx >= brightness_steps) { diff --git a/STM32-for-VSCode.config.yaml b/STM32-for-VSCode.config.yaml index 89f1f62..84b7685 100644 --- a/STM32-for-VSCode.config.yaml +++ b/STM32-for-VSCode.config.yaml @@ -41,9 +41,19 @@ cxxDefinitionsFile: asDefinitionsFile: # Compiler flags -cFlags: [] +cFlags: + - -Wall + - -Wextra + - -Werror + - -Wno-unused-parameter + - -Wno-missing-field-initializers cxxFlags: - -fno-rtti + - -Wall + - -Wextra + - -Werror + - -Wno-unused-parameter + - -Wno-missing-field-initializers assemblyFlags: [] linkerFlags: - -specs=nosys.specs diff --git a/STM32Make.make b/STM32Make.make index 84e1f56..36679e3 100644 --- a/STM32Make.make +++ b/STM32Make.make @@ -535,9 +535,9 @@ CXXFLAGS += -g -gdwarf -ggdb endif # Add additional flags -CFLAGS += +CFLAGS += -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter ASFLAGS += -CXXFLAGS += -fno-rtti +CXXFLAGS += -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -fno-rtti # Generate dependency information CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" diff --git a/TouchGFX/App/app_touchgfx.c b/TouchGFX/App/app_touchgfx.c index ba105c9..73cdf93 100644 --- a/TouchGFX/App/app_touchgfx.c +++ b/TouchGFX/App/app_touchgfx.c @@ -33,7 +33,9 @@ /* USER CODE BEGIN PD */ // Redefine here so it doesn't get overwritten on code generation +#undef TOUCHGFX_STACK_SIZE #define TOUCHGFX_STACK_SIZE (8160) +#undef TOUCHGFX_BYTE_POOL_SIZE #define TOUCHGFX_BYTE_POOL_SIZE (8192) /* USER CODE END PD */ diff --git a/TouchGFX/config/gcc/app.mk b/TouchGFX/config/gcc/app.mk index 44f7edb..1b0337d 100644 --- a/TouchGFX/config/gcc/app.mk +++ b/TouchGFX/config/gcc/app.mk @@ -5,4 +5,4 @@ touchgfx_path := ../Middlewares/ST/touchgfx # Location of the TouchGFX Environment touchgfx_env := C:/TouchGFX/4.21.2/env # Optional additional compiler flags -user_cflags := -DUSE_BPP=16 +user_cflags := -DUSE_BPP=16 -std=gnu++1z -Wno-cast-qual -Wno-missing-declarations diff --git a/TouchGFX/gui/src/driverview_screen/DriverViewView.cpp b/TouchGFX/gui/src/driverview_screen/DriverViewView.cpp index ae43d82..2d5a6bb 100644 --- a/TouchGFX/gui/src/driverview_screen/DriverViewView.cpp +++ b/TouchGFX/gui/src/driverview_screen/DriverViewView.cpp @@ -59,7 +59,7 @@ void DriverViewView::tearDownScreen() { DriverViewViewBase::tearDownScreen(); } void DriverViewView::fieldTypeSelectionUpdateItem( DriverViewFieldSelection &item, int16_t itemIndex) { item.setName(dataFieldDescs[itemIndex].title); - item.setSelected(itemIndex == selectedFieldType); + item.setSelected(itemIndex == (int)selectedFieldType); } void DriverViewView::setFieldType(size_t i, DataFieldType type) { diff --git a/TouchGFX/gui/src/vehicleconfig_screen/VehicleConfigView.cpp b/TouchGFX/gui/src/vehicleconfig_screen/VehicleConfigView.cpp index 7d59da8..c5ccd1d 100644 --- a/TouchGFX/gui/src/vehicleconfig_screen/VehicleConfigView.cpp +++ b/TouchGFX/gui/src/vehicleconfig_screen/VehicleConfigView.cpp @@ -92,7 +92,7 @@ void VehicleConfigView::updateSelectedParam(int select) { } if (firstWanted < 0) { firstWanted = 0; - } else if (firstWanted > ParamType_COUNT - 1) { + } else if (firstWanted > (int16_t)(ParamType_COUNT - 1)) { firstWanted = ParamType_COUNT - 1; } params.animateToItem(firstWanted, 0); diff --git a/TouchGFX/steering-wheel.touchgfx b/TouchGFX/steering-wheel.touchgfx index 01ee4a2..df27ebd 100644 --- a/TouchGFX/steering-wheel.touchgfx +++ b/TouchGFX/steering-wheel.touchgfx @@ -1542,10 +1542,12 @@ } }, "GenerateAssetsCommand": "make -f simulator/gcc/Makefile assets -j8", + "GenerateAssetsCommandOverride": "make -f simulator/gcc/Makefile assets -j2", "PostGenerateCommand": "touchgfx update_project --project-file=simulator/msvs/Application.vcxproj", "PostGenerateTargetCommand": "touchgfx update_project", "PostGenerateTargetCommandOverride": "", "CompileSimulatorCommand": "make -f simulator/gcc/Makefile -j8", + "CompileSimulatorCommandOverride": "make -f simulator/gcc/Makefile -j2", "RunSimulatorCommand": "build\\bin\\simulator.exe", "LandscapeSkinX": 0, "LandscapeSkinY": 0,