nRF54L15 protobuf error

Hello, I'm running an example of channel sounding using nRF54L15.

The build is fine, but the following error occurs during flash.

Python is using 3.12.4 version.
As you can see, we're using protobuf version 3.19.6 as well. (The same error occurred in 3.20.0 version)

But I keep getting protobuf errors, how do I fix it?

-------------------------------------------------------------------------

I solved this problem, but another problem occurred.

ModuleNotFoundError: No module named 'constants'

Parents
  • Hello,

    Sorry for the late reply. I was assigned your ticket, but was out of office yesterday. 

    I solved this problem, but another problem occurred.

    ModuleNotFoundError: No module named 'constants'

    Is there any way I can reproduce this issue? If so, can you please give some instructions on how to do it? If it is at all related to your initial issue, it seems like it is a toolchain issue. From the build log (probably from when you are flashing) it seems like it tries to use your default python installation, instead of the python version provided in the toolchain. Did you install a toolchain using VS Code? If so, which one do you use?

    Best regards,
    Edvin

  • Hello, thank you for your answer.

    Initially, I encountered a version-related error with protobuf, so I ran the following command:
    C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install protobuf==3.20.3
    After that, I started getting a 'constants' error.

    ModuleNotFoundError: No module named 'constants'

    I am using SDK v3.0.0, which I downloaded via nRF Connect for Desktop. and I'm using Python 3.12

    I'll be waiting for your reply.

    +

    I referred to the following post on Nordic DevZone:
    RE: nrfutil ModuleNotFoundError: No module named 'constants' 

    I did some research and found that issues occur with Python 3.10 and above because some outdated packages reference attributes like collections.Hashable, which no longer exist.
    Does this mean that SDK v3.0.0 cannot run on Python 3.12?

  • Are you trying to build a sample of ours? 

    kim_mj said:
    Does this mean that SDK v3.0.0 cannot run on Python 3.12?

    If so, are you using the toolchain that comes with NCS v3.0.0?

  • Yes, I have downloaded and currently using both the SDKs and Toolchains v3.0.0, and I am building and flashing the channel_sounding_ras_initiator example.

    The reason I mentioned the Python version is because I encountered an error (related to protobuf) during the build and flash process.

    ...
    TypeError: Descriptors cannot be created directly.
    If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
    If you cannot immediately regenerate your protos, some other possible workarounds are:
     1. Downgrade the protobuf package to 3.20.x or lower.
     2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

    To resolve the protobuf issue, I ran the following command:
    C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install nrfutil

    After that, I started seeing consecutive errors related to constants and collections.

    ...
    ModuleNotFoundError: No module named 'constants'

    ...
    AttributeError: module 'collections' has no attribute 'Hashable'

    After searching online, I found that these types of errors could be related to the Python version, which led me to ask whether the Python version might be the cause of the problem.

    If I made any mistakes, could you please let me know?

    1) Even though I am using both the SDKs and Toolchain version 3.0.0, why am I getting these errors and unable to flash the program?

    (I'm not completely sure, but I think that when I run the flash, it uses the Python installed on my computer instead of the toolchain's Python.
    As you can see, the path follows C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Scripts\nrfutil.exe (my computer path), rather than the toolchain path like C:\ncs\toolchains\....)

    More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Scripts\nrfutil.exe\__main__.py", line 4, in <module>
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\__main__.py", line 50, in <module>
        from nordicsemi.dfu.bl_dfu_sett import BLDFUSettings
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\bl_dfu_sett.py", line 52, in <module>
        from nordicsemi.dfu.package import Package
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\package.py", line 54, in <module>
        from nordicsemi.dfu.init_packet_pb import *
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\init_packet_pb.py", line 38, in <module>
        from . import dfu_cc_pb2 as pb
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\dfu_cc_pb2.py", line 32, in <module>
        _descriptor.EnumValueDescriptor(
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\google\protobuf\descriptor.py", line 920, in __new__
        _message.Message._CheckCalledFromGeneratedFile()
    TypeError: Descriptors cannot be created directly.
    If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
    If you cannot immediately regenerate your protos, some other possible workarounds are:
     1. Downgrade the protobuf package to 3.20.x or lower.
     2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
    
    More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

    2)  Also, how can I resolve the issues that appear after fixing the protobuf version by running
    C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install nrfutil?

    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts\west.exe\__main__.py", line 7, in <module>
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 1085, in main
        app.run(argv or sys.argv[1:])
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 236, in run
        self.load_manifest()
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 254, in load_manifest
        self.manifest = Manifest.from_topdir(topdir=self.topdir,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 1207, in from_topdir
        return Manifest(topdir=topdir, config=config,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 1499, in __init__
        current_data=validate(self._ctx.current_data))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 541, in validate
        as_dict = _load(data)
                  ^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 207, in _load
        return yaml.safe_load(data)
               ^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\__init__.py", line 94, in safe_load
        return load(stream, SafeLoader)
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\__init__.py", line 72, in load
        return loader.get_single_data()
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 37, in get_single_data
        return self.construct_document(node)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 46, in construct_document
        for dummy in generator:
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 398, in construct_yaml_map
        value = self.construct_mapping(node)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 204, in construct_mapping
        return super().construct_mapping(node, deep=deep)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 126, in construct_mapping
        if not isinstance(key, collections.Hashable):
                               ^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'collections' has no attribute 'Hashable'

    after C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install PyYAML=6.0.1 ,   

    -- west flash: using runner nrfutil
    -- runners.nrfutil: reset after flashing requested
    -- runners.nrfutil: Flashing file: C:\ncs\channel_sounding_ras_initiator\build\merged.hex
    Traceback (most recent call last):
    File "<frozen runpy>", line 198, in _run_module_as_main
    File "<frozen runpy>", line 88, in _run_code
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts\nrfutil.exe\__main__.py", line 4, in <module>
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\__main__.py", line 53, in <module>
    from nordicsemi.dfu.dfu_transport_serial import DfuTransportSerial
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 52, in <module>
    from nordicsemi.lister.device_lister import DeviceLister
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\lister\device_lister.py", line 39, in <module>
    from nordicsemi.lister.windows.lister_win32 import Win32Lister
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\lister\windows\lister_win32.py", line 43, in <module>
    from constants import DIGCF_PRESENT, DEVPKEY, DIGCF_DEVICEINTERFACE
    ModuleNotFoundError: No module named 'constants'

    In the end, it says that nrfutil does not recognize the --json option. How can I resolve this issue?

    ...
    -- west flash: using runner nrfutil
    -- runners.nrfutil: reset after flashing requested
    -- runners.nrfutil: Flashing file: C:\ncs\channel_sounding_ras_initiator\build\merged.hex
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    -- runners.nrfutil: Board with serial number 1057756188 flashed successfully.

  • I see. I just tested building the channel_sounding_ras_initiator with both NCS v3.0.0 and v3.0.1 (I recommend that you move to 3.0.1), and none of them triggered any protobuf issues. I do see from your build log that it was, for some reason, trying to use your local version of python, located in "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Scripts\..." rather than the one from your toolchain.

    Also, after you "fixed it" by installing PyYAML, I am not sure what effect that will have on the toolchain. I suggest you remove the toolchain and reinstall it.

    After you do that, try the following. Make sure that the active build is the application that you are trying to build, and then click:

    Make sure that the toolchain listed is the one you are trying to use. Now, in that terminal, navigate to the root folder for the application:

    cd ..\..\

    and use this command to build:

    west build -b nrf54l15dk/nrf54l15/cpuapp -d build_2

    Does that build without any errors?

    Best regards,

    Edvin

  • Hello,

    Unfortunately, as shown in the image, I tried using the Build and Flash buttons in the nRF Connect SDK Toolchain v3.0.1, but the same error kept occurring.

    However, I was able to resolve the issue and successfully flash the device.

    I tried several methods:

    • Downloaded Python 3.10 and configured both the interpreter and system PATH to use it.

    • I downloaded nrfutil from www.nordicsemi.com/.../nrf-util, manually moved it to the folder C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts, and ran the command C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts\nrfutil.exe install device

Reply
  • Hello,

    Unfortunately, as shown in the image, I tried using the Build and Flash buttons in the nRF Connect SDK Toolchain v3.0.1, but the same error kept occurring.

    However, I was able to resolve the issue and successfully flash the device.

    I tried several methods:

    • Downloaded Python 3.10 and configured both the interpreter and system PATH to use it.

    • I downloaded nrfutil from www.nordicsemi.com/.../nrf-util, manually moved it to the folder C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts, and ran the command C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts\nrfutil.exe install device

Children
  • According to google translate, this is what you wrote:

    Hi,

    Unfortunately, I tried using the Build and Flash buttons of the nRF Connect SDK Toolchain v3.0.1 as shown in the image, but I kept getting the same error.

    However, I was able to fix the issue and successfully run the flash.

    I tried several methods:

    Download Python 3.10 and configure the interpreter and system PATH to use it.

    Download nrfutil from www.nordicsemi.com/.../nrf-util and manually place it and run the command nrfutil.exeC:\ncs\toolchains\0b393f9e1b\opt\bin\Scriptsnrfutil.exe install devic

    If you got it working, it is fine, I guess. But you may still run into other issues, if your toolchain is not being correctly set up when building your applications.

    Try building using this terminal and the command "west build -b <board_name> -d build_2"

    But if you have changed things inside the toolchain, I would recommend that you uninstall that toolchain and re-install it again. Building with the toolchain enabled should never try to access your "personal" python instance outside the toolchain.

    Best regards,

    Edvin

  • Hello,


    As you mentioned, I ran the following command:

    west build -b nrf54l15dk/nrf54l15/cpuapp -d C:\ncs\channel_sounding_ras_initiator\build

     
    -- west build: generating a build system
    CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build 
    tool.
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' -DWEST_PYTHON=C:/Users/SJIT/AppData/Local/Programs/Python/Python310/python.exe '-BC:\ncs\channel_sounding_ras_initiator\build' -GNinja -DBOARD=nrf54l15dk/nrf54l15/cpuapp '-SC:\ncs\v3.0.1\zephyr\share\sysbuild' '-DAPP_DIR:PATH=C:\ncs\channel_sounding_ras_initiator'

    However, I encountered an issue with Ninja,
    but I was able to resolve it by adding the following to the PATH:

    set PATH=C:\ncs\toolchains\0b393f9e1b\opt\bin;%PATH%

    and the build was successful.

    However, when I first tried to flash using this command:

    C:\ncs\v3.0.1>west flash -d C:\ncs\channel_sounding_ras_initiator\build

    an error occurred.

    At that time, after I moved the downloaded nrfutil.exe file into C:\ncs\toolchains\0b393f9e1b\opt\bin,
    the flashing worked correctly. 
    Thank you for your respons
  • A new error has occurred.

    After my colleague installed a new (=nothing touched) toolchain and SDK version v3.0.1, they tried to run the build using the command

    west build -b nrf54l15dk/nrf54l15/cpuapp -d build

    but encountered the following error message:
    'west' is not recognized as an internal or external command, operable program, or batch file.

Related