summaryrefslogtreecommitdiff
path: root/hw/bsp/rp2040
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-10-27 17:11:42 +0700
committerhathach <[email protected]>2025-10-27 17:11:42 +0700
commitd55e074a36de0331006fca1a19a241e98f9bd7e1 (patch)
tree6d829653eaef1ffffdcbb34b6167c79373a2cb67 /hw/bsp/rp2040
parent8865ec47814628ba1c50e52f09b7ef2fe10d463d (diff)
improve warnings with rp2040 family
Diffstat (limited to 'hw/bsp/rp2040')
-rw-r--r--hw/bsp/rp2040/family.c2
-rw-r--r--hw/bsp/rp2040/family.cmake66
2 files changed, 40 insertions, 28 deletions
diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c
index 989140e02..35e5fc923 100644
--- a/hw/bsp/rp2040/family.c
+++ b/hw/bsp/rp2040/family.c
@@ -92,7 +92,7 @@ static uart_inst_t *uart_inst;
//
// This doesn't work if others are trying to access flash at the same time,
// e.g. XIP streamer, or the other core.
-bool __no_inline_not_in_flash_func(get_bootsel_button)(void) {
+static bool __no_inline_not_in_flash_func(get_bootsel_button)(void) {
const uint CS_PIN_INDEX = 1;
// Must disable interrupts, as interrupt handlers may be in flash, and we
diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake
index 3bec5bf70..5d6d8b40e 100644
--- a/hw/bsp/rp2040/family.cmake
+++ b/hw/bsp/rp2040/family.cmake
@@ -184,6 +184,43 @@ endif()
#------------------------------------
# Functions
#------------------------------------
+function(family_add_default_example_warnings TARGET)
+ # Apply warnings to all TinyUSB interface library sources as well as examples sources
+ # we cannot set compile options for target since it will not propagate to INTERFACE sources then picosdk files
+ foreach(TINYUSB_TARGET IN ITEMS tinyusb_common_base tinyusb_device_base tinyusb_host_base tinyusb_host_max3421 tinyusb_bsp)
+ get_target_property(TINYUSB_SOURCES ${TINYUSB_TARGET} INTERFACE_SOURCES)
+ set_source_files_properties(${TINYUSB_SOURCES} PROPERTIES COMPILE_OPTIONS "${WARN_FLAGS_${CMAKE_C_COMPILER_ID}}")
+ endforeach()
+
+ # Also apply to example sources, but filter out any source files from lib/ (e.g. fatfs)
+ get_target_property(EXAMPLE_SOURCES ${TARGET} SOURCES)
+ set(FILTERED_SOURCES "")
+ foreach(SOURCE_FILE IN LISTS EXAMPLE_SOURCES)
+ string(FIND "${SOURCE_FILE}" "${TOP}/lib" FOUND_POS)
+ if(FOUND_POS EQUAL -1)
+ list(APPEND FILTERED_SOURCES ${SOURCE_FILE})
+ endif()
+ endforeach()
+ set_source_files_properties(${FILTERED_SOURCES} PROPERTIES COMPILE_OPTIONS "${WARN_FLAGS_${CMAKE_C_COMPILER_ID}}")
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND NO_WARN_RWX_SEGMENTS_SUPPORTED)
+ target_link_options(${TARGET} PRIVATE "LINKER:--no-warn-rwx-segments")
+ endif()
+
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
+ target_compile_options(${TARGET} PRIVATE -Wconversion)
+ endif()
+
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
+ target_compile_options(${TARGET} PRIVATE -Wcast-function-type -Wstrict-overflow)
+ endif()
+
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
+ target_compile_options(${TARGET} PRIVATE -Wno-strict-aliasing)
+ endif()
+ endif()
+endfunction()
function(family_configure_target TARGET RTOS)
if (RTOS STREQUAL noos OR RTOS STREQUAL "")
@@ -204,7 +241,7 @@ function(family_configure_target TARGET RTOS)
pico_enable_stdio_uart(${TARGET} 1)
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_board${RTOS_SUFFIX} tinyusb_additions)
- family_flash_openocd(${TARGET})
+ family_flash_openocd(${TARGET})
family_flash_jlink(${TARGET})
endfunction()
@@ -359,34 +396,9 @@ function(suppress_tinyusb_warnings)
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
)
foreach(SOURCE_FILE IN LISTS CONVERSION_WARNING_FILES)
- set_source_files_properties(
- ${SOURCE_FILE}
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion")
+ set_source_files_properties(${SOURCE_FILE} PROPERTIES COMPILE_FLAGS "-Wno-conversion")
endforeach()
endif()
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
- COMPILE_FLAGS "-Wno-stringop-overflow -Wno-array-bounds")
- endif()
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual")
-
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/lib/lwip/src/core/tcp_in.c
- ${PICO_TINYUSB_PATH}/lib/lwip/src/core/tcp_out.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion")
-
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/lib/networking/dnserver.c
- ${PICO_TINYUSB_PATH}/lib/networking/dhserver.c
- ${PICO_TINYUSB_PATH}/lib/networking/rndis_reports.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion -Wno-sign-conversion")
if (TARGET tinyusb_pico_pio_usb)
set_source_files_properties(