summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-10-14 17:13:28 +0700
committerhathach <[email protected]>2025-10-14 17:13:28 +0700
commit47b13f6b102ea981b79588158dca436ebc21f1ae (patch)
treee435b6af711f0386daec3eb53313cf4c2c240735 /hw
parent9bf18d080b202e8e09bd76f32272b1dbfabfa3b9 (diff)
improve cmake warning flags, fix various warnings in examples
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/board.c6
-rw-r--r--hw/bsp/family_support.cmake61
2 files changed, 37 insertions, 30 deletions
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index e141664da..a51978479 100644
--- a/hw/bsp/board.c
+++ b/hw/bsp/board.c
@@ -180,9 +180,11 @@ uint32_t tusb_time_millis_api(void) {
// FreeRTOS hooks
//--------------------------------------------------------------------
#if CFG_TUSB_OS == OPT_OS_FREERTOS && !defined(ESP_PLATFORM)
+
#include "FreeRTOS.h"
#include "task.h"
+void vApplicationMallocFailedHook(void); // missing prototype
void vApplicationMallocFailedHook(void) {
taskDISABLE_INTERRUPTS();
TU_ASSERT(false, );
@@ -199,7 +201,7 @@ void vApplicationStackOverflowHook(xTaskHandle pxTask, char *pcTaskName) {
/* configSUPPORT_STATIC_ALLOCATION is set to 1, so the application must provide an
* implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
* used by the Idle task. */
-void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) {
+void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) {
/* If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be allocated on
* the stack and so not exists after this function exits. */
@@ -243,6 +245,8 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, Stack
}
#if CFG_TUSB_MCU == OPT_MCU_RX63X || CFG_TUSB_MCU == OPT_MCU_RX65X
+void vApplicationSetupTimerInterrupt(void);
+
#include "iodefine.h"
void vApplicationSetupTimerInterrupt(void) {
/* Enable CMT0 */
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index 9ec80df91..daabed81b 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -38,6 +38,35 @@ if (NOT DEFINED TOOLCHAIN)
set(TOOLCHAIN gcc)
endif ()
+set(WARN_FLAGS_GNU
+ -Wall
+ -Wextra
+ -Werror
+ -Wfatal-errors
+ -Wdouble-promotion
+ -Wstrict-prototypes
+ -Wstrict-overflow
+ -Werror-implicit-function-declaration
+ -Wfloat-equal
+ -Wundef
+ -Wshadow
+ -Wwrite-strings
+ -Wsign-compare
+ -Wmissing-format-attribute
+ -Wunreachable-code
+ -Wcast-align
+ -Wcast-function-type
+ -Wcast-qual
+ -Wnull-dereference
+ -Wuninitialized
+ -Wunused
+ -Wunused-function
+ -Wreturn-type
+ -Wredundant-decls
+ -Wmissing-prototypes
+ )
+set(WARN_FLAGS_Clang ${WARN_FLAGS_GNU})
+
# Optimization
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
@@ -48,8 +77,8 @@ endif ()
#-------------------------------------------------------------
if (NOT DEFINED FAMILY)
if (NOT DEFINED BOARD)
- message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, espressif).
- You can do this via -DFAMILY=xxx on the cmake command line")
+ message(FATAL_ERROR "You must set a BOARD variable for the build (e.g. metro_m4_express, raspberry_pi_pico).
+ You can do this via -DBOARD=xxx on the cmake command line")
endif ()
# Find path contains BOARD
@@ -226,33 +255,7 @@ function(family_configure_common TARGET RTOS)
endif ()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_compile_options(${TARGET} PRIVATE
- -Wall
- -Wextra
- #-Werror
- -Wfatal-errors
- -Wdouble-promotion
- -Wstrict-prototypes
- -Wstrict-overflow
- -Werror-implicit-function-declaration
- -Wfloat-equal
- -Wundef
- -Wshadow
- -Wwrite-strings
- -Wsign-compare
- -Wmissing-format-attribute
- -Wunreachable-code
- -Wcast-align
- -Wcast-function-type
- -Wcast-qual
- -Wnull-dereference
- -Wuninitialized
- -Wunused
- -Wunused-function
- -Wreturn-type
- -Wredundant-decls
- -Wmissing-prototypes
- )
+ target_compile_options(${TARGET} PRIVATE ${WARN_FLAGS_${CMAKE_C_COMPILER_ID}})
target_link_options(${TARGET} PUBLIC "LINKER:-Map=$<TARGET_FILE:${TARGET}>.map")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0
AND NO_WARN_RWX_SEGMENTS_SUPPORTED AND (NOT RTOS STREQUAL zephyr))