From 8d1378dcd29e4726f504ac9b8b5fd9a6a088ad9b Mon Sep 17 00:00:00 2001 From: Peter Harper <77111776+peterharperuk@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:29:34 +0000 Subject: [PATCH] Remove Segger RTT from pico-btstack (#1995) * Remove btstack Segger RTT from pico-btstack We now have this in the SDK so adding it again in pico-btstack leads to link errors. But it's possible to use the btstack RTT functionality by defining ENABLE_SEGGER_RTT=1, and if we're not using pico_stio_rtt we still need to add the btstack RTT source. * Fix build issues when RTT is enabled Fixes https://github.com/raspberrypi/pico-examples/issues/565 --- src/rp2_common/pico_btstack/CMakeLists.txt | 8 +++++++- src/rp2_common/pico_stdio_rtt/SEGGER/RTT/SEGGER_RTT.c | 5 +++++ src/rp2_common/pico_stdio_rtt/stdio_rtt.c | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/rp2_common/pico_btstack/CMakeLists.txt b/src/rp2_common/pico_btstack/CMakeLists.txt index 35c615b83..d21eabf90 100644 --- a/src/rp2_common/pico_btstack/CMakeLists.txt +++ b/src/rp2_common/pico_btstack/CMakeLists.txt @@ -28,7 +28,6 @@ if (EXISTS ${PICO_BTSTACK_PATH}/${BTSTACK_TEST_PATH}) target_sources(pico_btstack_base INTERFACE ${PICO_BTSTACK_PATH}/3rd-party/micro-ecc/uECC.c ${PICO_BTSTACK_PATH}/3rd-party/rijndael/rijndael.c - ${PICO_BTSTACK_PATH}/3rd-party/segger-rtt/SEGGER_RTT.c ${PICO_BTSTACK_PATH}/3rd-party/segger-rtt/SEGGER_RTT_printf.c ${PICO_BTSTACK_PATH}/platform/embedded/btstack_tlv_flash_bank.c ${PICO_BTSTACK_PATH}/platform/embedded/hci_dump_embedded_stdout.c @@ -60,6 +59,13 @@ if (EXISTS ${PICO_BTSTACK_PATH}/${BTSTACK_TEST_PATH}) ${PICO_BTSTACK_PATH}/3rd-party/yxml/yxml.c ${CMAKE_CURRENT_LIST_DIR}/btstack_stdin_pico.c ) + # pico-sdk now supports RTT using pico_enable_stdio_rtt in your cmake file or -DPICO_STDIO_RTT=1 on the command line + # Then the output of printf goes to RTT. But if you define ENABLE_SEGGER_RTT=1 it will use the btstack functionality to use RTT + # and we'll have to add the source file it requires. + target_sources(pico_btstack_base INTERFACE + $,>,${PICO_STDIO_RTT},$>>,,${PICO_BTSTACK_PATH}/3rd-party/segger-rtt/SEGGER_RTT.c> + ) + target_include_directories(pico_btstack_base_headers SYSTEM INTERFACE ${PICO_BTSTACK_PATH}/ ${PICO_BTSTACK_PATH}/3rd-party/md5 diff --git a/src/rp2_common/pico_stdio_rtt/SEGGER/RTT/SEGGER_RTT.c b/src/rp2_common/pico_stdio_rtt/SEGGER/RTT/SEGGER_RTT.c index f35540417..c69fca7d0 100644 --- a/src/rp2_common/pico_stdio_rtt/SEGGER/RTT/SEGGER_RTT.c +++ b/src/rp2_common/pico_stdio_rtt/SEGGER/RTT/SEGGER_RTT.c @@ -78,6 +78,11 @@ Additional information: #include // for memcpy +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wcast-qual" +#pragma GCC diagnostic ignored "-Wcast-align" +#endif + /********************************************************************* * * Configuration, default values diff --git a/src/rp2_common/pico_stdio_rtt/stdio_rtt.c b/src/rp2_common/pico_stdio_rtt/stdio_rtt.c index 2dc75579a..2af1f7028 100644 --- a/src/rp2_common/pico_stdio_rtt/stdio_rtt.c +++ b/src/rp2_common/pico_stdio_rtt/stdio_rtt.c @@ -26,11 +26,11 @@ void stdio_rtt_deinit(void) { } static void stdio_rtt_out_chars(const char *buf, int length) { - SEGGER_RTT_Write(0, buf, length); + SEGGER_RTT_Write(0, buf, (unsigned)length); } static int stdio_rtt_in_chars(char *buf, int length) { - return SEGGER_RTT_Read(0, buf, length); + return (int)SEGGER_RTT_Read(0, buf, (unsigned)length); } stdio_driver_t stdio_rtt = {