From 36996060ae701262d3ed6da48ce885977e8891af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Tue, 8 Feb 2022 16:24:42 +0100 Subject: [PATCH] [nrfconnect] Fix pigweed/protobuf compiler flags (#14876) Enhance the way Zephyr flags are passed to Pigweed and Protobuf components. It happened in the past that some MCU-related flags were not passed correctly causing crashes or build failures (e.g. with FPU enabled). --- examples/lighting-app/nrfconnect/CMakeLists.txt | 9 +++------ examples/lighting-app/nrfconnect/rpc.overlay | 5 +---- examples/pigweed-app/nrfconnect/CMakeLists.txt | 5 +++-- examples/pigweed-app/nrfconnect/README.md | 2 +- examples/pigweed-app/nrfconnect/prj.conf | 3 --- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 027ab711955a05..381af2dad59761 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -114,14 +114,13 @@ endif() if (CONFIG_CHIP_PW_RPC) +# Make all targets created below depend on zephyr_interface to inherit MCU-related compilation flags +link_libraries($) + set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") include(${PIGWEED_ROOT}/pw_build/pigweed.cmake) include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake) -# TODO: Remove this temporary fix needed to get RPC builds working. -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-m4 -mthumb" CACHE INTERNAL "") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=cortex-m4 -mthumb" CACHE INTERNAL "") - pw_set_backend(pw_log pw_log_basic) pw_set_backend(pw_assert pw_assert_log) pw_set_backend(pw_sys_io pw_sys_io.nrfconnect) @@ -223,6 +222,4 @@ target_link_options(app "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" ) -target_link_libraries(pw_build INTERFACE zephyr_interface) - endif(CONFIG_CHIP_PW_RPC) diff --git a/examples/lighting-app/nrfconnect/rpc.overlay b/examples/lighting-app/nrfconnect/rpc.overlay index aee22afb4a39c5..f9f7c10f0b0954 100644 --- a/examples/lighting-app/nrfconnect/rpc.overlay +++ b/examples/lighting-app/nrfconnect/rpc.overlay @@ -26,9 +26,6 @@ CONFIG_CHIP_PW_RPC=y CONFIG_STD_CPP14=n CONFIG_STD_CPP17=y -# Disable HW floating point, as libprotobuf nano doesn't support building with it -CONFIG_FPU=n - # Add support for Zephyr console component to use it for Pigweed console purposes CONFIG_CONSOLE_SUBSYS=y CONFIG_CONSOLE_GETCHAR=y @@ -48,4 +45,4 @@ CONFIG_LOG_BACKEND_UART=n CONFIG_LOG_BACKEND_RTT=n # Increase zephyr tty rx buffer -CONFIG_CONSOLE_GETCHAR_BUFSIZE=128 \ No newline at end of file +CONFIG_CONSOLE_GETCHAR_BUFSIZE=128 diff --git a/examples/pigweed-app/nrfconnect/CMakeLists.txt b/examples/pigweed-app/nrfconnect/CMakeLists.txt index e05628bcfd8af5..e5df573ad830ab 100644 --- a/examples/pigweed-app/nrfconnect/CMakeLists.txt +++ b/examples/pigweed-app/nrfconnect/CMakeLists.txt @@ -43,6 +43,9 @@ include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake) # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 target_compile_options(app PRIVATE -Werror -Wno-error=maybe-uninitialized) +# Make all targets created below depend on zephyr_interface to inherit MCU-related compilation flags +link_libraries($) + include(${PIGWEED_ROOT}/pw_build/pigweed.cmake) include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake) @@ -86,6 +89,4 @@ target_link_libraries(app PUBLIC pw_rpc.server ) -target_link_libraries(pw_build INTERFACE zephyr_interface) - include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) diff --git a/examples/pigweed-app/nrfconnect/README.md b/examples/pigweed-app/nrfconnect/README.md index a66f536180480b..d226db40338513 100644 --- a/examples/pigweed-app/nrfconnect/README.md +++ b/examples/pigweed-app/nrfconnect/README.md @@ -326,7 +326,7 @@ to read more about flashing on the nRF52840 Dongle. Run the following command to start an interactive Python shell, where the Echo RPC commands can be invoked: - python -m pw_hdlc.rpc_console --device /dev/ttyACM0 -b 115200 $CHIP_ROOT/third_party/pigweed/repo/pw_rpc/echo.proto -o /tmp/pw_rpc.out + python -m pw_hdlc.rpc_console --device /dev/ttyACM0 -b 115200 --proto-globs $CHIP_ROOT/third_party/pigweed/repo/pw_rpc/echo.proto -o /tmp/pw_rpc.out To send an Echo RPC message, type the following command, where the actual message is the text in quotation marks after the `msg=` phrase: diff --git a/examples/pigweed-app/nrfconnect/prj.conf b/examples/pigweed-app/nrfconnect/prj.conf index 0895493dcc8f72..58a0fe63277b34 100644 --- a/examples/pigweed-app/nrfconnect/prj.conf +++ b/examples/pigweed-app/nrfconnect/prj.conf @@ -30,9 +30,6 @@ CONFIG_CHIP_PW_RPC=y CONFIG_STD_CPP14=n CONFIG_STD_CPP17=y -# Disable HW floating point, as libprotobuf nano doesn't support building with it -CONFIG_FPU=n - # Add support for Zephyr console component to use it for Pigweed console purposes CONFIG_CONSOLE_SUBSYS=y CONFIG_CONSOLE_GETCHAR=y