Skip to content

Commit

Permalink
[nrfconnect] Fix pigweed/protobuf compiler flags (#14876)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Damian-Nordic authored and pull[bot] committed Jun 27, 2023
1 parent 9cf7691 commit 1157399
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
9 changes: 3 additions & 6 deletions examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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($<BUILD_INTERFACE:zephyr_interface>)

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)
Expand Down Expand Up @@ -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)
5 changes: 1 addition & 4 deletions examples/lighting-app/nrfconnect/rpc.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,4 +45,4 @@ CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_BACKEND_RTT=n

# Increase zephyr tty rx buffer
CONFIG_CONSOLE_GETCHAR_BUFSIZE=128
CONFIG_CONSOLE_GETCHAR_BUFSIZE=128
5 changes: 3 additions & 2 deletions examples/pigweed-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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($<BUILD_INTERFACE:zephyr_interface>)

include(${PIGWEED_ROOT}/pw_build/pigweed.cmake)
include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake)

Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion examples/pigweed-app/nrfconnect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions examples/pigweed-app/nrfconnect/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1157399

Please sign in to comment.