nanopb compilation doesn't work

I am using zephyr_nanopb_sources to add some protobuf files to my app target, and this works fine in a normal build without mcuboot. However, when building with mcuboot it doesn't work. Here is the error I get:

Failed to import nanopb_pb2.py: type object 'FileOptions' has no attribute 'RegisterExtension'
Will automatically attempt to rebuild this.
Verify that python-protobuf and protoc versions match.
Using grpcio-tools protoc from /opt/nordic/ncs/toolchains/15b490767d/lib/python3.12/site-packages/grpc_tools/protoc.py
protoc builtin include path: ['/Users/nick/Documents/Repos/AirTurnWearable/application/build_rel_nrf52dk/application/src/proto/nanopb/generator/proto', '/opt/nordic/ncs/toolchains/15b490767d/lib/python3.12/site-packages/grpc_tools/_proto']
Python version 3.12.4 (main, Jun  7 2024, 04:28:19) [Clang 14.0.0 (clang-1400.0.29.202)]
Using python-protobuf from /opt/nordic/ncs/toolchains/15b490767d/lib/python3.12/site-packages/google/protobuf/__init__.py
Python-protobuf version: 5.27.1

This appears to be related to this issue: https://github.com/zephyrproject-rtos/zephyr/issues/72265

What's strange is that running the command that fails from a nRF toolchain terminal succeeds. So it appears something about the mcuboot build environment is causing the failure.

I'm using toolchain and SDK 2.8.0

Parents Reply Children
  • Thanks.

    My project is modified from the nRF desktop application. When using zephyr nanopb in that project, with the normal build, it builds fine. For some reason when building release configuration, it fails as above. This is unrelated to mcuboot. I was unable to narrow down what the difference between normal and release builds is that could cause it.

    As this issue is fixed in upstream zephyr on 8th May 24, I checked to see if the fix was merged into downstream nRF connect zephyr fork. However, I can't find the commit, so it looks like it hasn't been yet.

    Please could you ask internally how I can work around this issue until the fix is merged?

  • Could you try to use VS Code to compile it?

    I only can reproduce the issue with the west command. 

  • The nanopb sample does build correctly in VS Code, yes, but the release build in nRF Desktop application does not (when I've added `zephyr_nanopb_sources`). Presumably it builds differently (using west?).

  • The release build would use prj_release.conf under the nrf_desktop/configuration/*board_name. Maybe you can compare the .config file under build/nrf_desktop/zephyr from the release/ debug build to see what is missing. 

  • I looked at those, they were the same. So I deleted all _release suffix files in the board configuration directory, and it still didn't build. So I removed all .obj, .a, .h files from the debug build dir, then compared the two build dirs. I saw that the release build CMakeCache.txt file was missing 

    //No help, variable specified on the command line.
    NCS_TOOLCHAIN_VERSION:UNINITIALIZED=NONE

    I added that, and it built... And now when I remove it, it is immediately added back again when building. I have no idea how to break it again. I will keep going, hopefully this works well enough now. I'll mark as resolved in a few days if so.

Related