Merge pull request #1933 from kilograham/rp2040_llvm_tweaks

make rp2040 code compile cleanly with LLVM embedded toochain for ARM.
This commit is contained in:
Ha Thach 2023-03-06 15:24:51 +07:00 committed by GitHub
commit 3387c86108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -413,7 +413,7 @@ void cli_cmd_cat(EmbeddedCli *cli, char *args, void *context)
{
for(UINT c = 0; c < count; c++)
{
const char ch = buf[c];
const uint8_t ch = buf[c];
if (isprint(ch) || iscntrl(ch))
{
putchar(ch);

View File

@ -152,6 +152,9 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
if (NOT PICO_TINYUSB_NO_EXAMPLE_WARNINGS)
family_add_default_example_warnings(${TARGET})
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(${TARGET} PRIVATE -Wno-unreachable-code)
endif()
suppress_tinyusb_warnings()
endfunction()
@ -172,8 +175,8 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
# For rp2040 enable pico-pio-usb
if (TARGET tinyusb_pico_pio_usb)
# code does not compile with GCC 12+
if (NOT (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.3))
# code does not compile with non GCC, or GCC 11.3+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.3)
family_add_pico_pio_usb(${PROJECT})
endif()
endif()
@ -278,7 +281,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
COMPILE_FLAGS "-Wno-conversion")
endforeach()
endif()
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
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")
@ -310,6 +313,17 @@ if (NOT TARGET _rp2040_family_inclusion_marker)
PROPERTIES
COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual -Wno-attributes")
endif()
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set_source_files_properties(
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
COMPILE_FLAGS "-Wno-unreachable-code")
set_source_files_properties(
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_host.c
COMPILE_FLAGS "-Wno-unreachable-code-fallthrough")
set_source_files_properties(
${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
PROPERTIES
COMPILE_FLAGS "-Wno-cast-qual")
endif()
endfunction()
endif()

View File

@ -297,7 +297,7 @@ static void __tusb_irq_path_func(dcd_rp2040_irq)(void)
if ( status & USB_INTS_SETUP_REQ_BITS )
{
handled |= USB_INTS_SETUP_REQ_BITS;
uint8_t const * setup = (uint8_t const*) &usb_dpram->setup_packet;
uint8_t const * setup = remove_volatile_cast(uint8_t const*, &usb_dpram->setup_packet);
// reset pid to both 1 (data and ack)
reset_ep0_pid();