NordicPlayground / nrf-docker

Dockerfile example for building nRF Connect SDK applications with GitHub Actions
BSD 3-Clause "New" or "Revised" License
70 stars 34 forks source link

`nrfutil` fails to run in at least `v1.8-branch`? #7

Closed fgervais closed 2 years ago

fgervais commented 2 years ago

It looks like there might be a problem with nrfutil.

I only tested with v1.8-branch for now as this is what I'm using in my current project.

fgervais@fgervais-System-Product-Name:~/personal/project-nrf-thread-switch_west/application$ docker pull nordicplayground/nrfconnect-sdk:v1.8-branch
v1.8-branch: Pulling from nordicplayground/nrfconnect-sdk
Digest: sha256:cb484e62d605c2edb8be030496d12df5f4b29da838c86de3f7c1357769ca25d5
Status: Image is up to date for nordicplayground/nrfconnect-sdk:v1.8-branch
docker.io/nordicplayground/nrfconnect-sdk:v1.8-branch

fgervais@fgervais-System-Product-Name:~/personal/project-nrf-thread-switch_west/application$ docker run --rm nordicplayground/nrfconnect-sdk:v1.8-branch nrfutil
Traceback (most recent call last):
  File "/usr/local/bin/nrfutil", line 5, in <module>
    from nordicsemi.__main__ import cli
  File "/usr/local/lib/python3.8/dist-packages/nordicsemi/__main__.py", line 49, in <module>
    from nordicsemi.dfu.bl_dfu_sett import BLDFUSettings
  File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/bl_dfu_sett.py", line 51, in <module>
    from nordicsemi.dfu.package import Package
  File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/package.py", line 53, in <module>
    from nordicsemi.dfu.init_packet_pb import InitPacketPB, DFUType, CommandTypes, ValidationTypes, SigningTypes, HashTypes
  File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/init_packet_pb.py", line 38, in <module>
    from . import dfu_cc_pb2 as pb
  File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/dfu_cc_pb2.py", line 32, in <module>
    _descriptor.EnumValueDescriptor(
  File "/usr/local/lib/python3.8/dist-packages/google/protobuf/descriptor.py", line 755, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not 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

As a comparaison, this is working with the nrfassettracker/nrfconnect-sdk:v1.8-branch:

fgervais@fgervais-System-Product-Name:~/personal/project-nrf-thread-switch_west/application$ docker images --no-trunc --quiet nrfassettracker/nrfconnect-sdk:v1.8-branch
sha256:8bfa2ca95b7f645af6a49a9cff12a3203adbe12460e0e24c9fee0171fafd57d2

fgervais@fgervais-System-Product-Name:~/personal/project-nrf-thread-switch_west/application$ docker run --rm nrfassettracker/nrfconnect-sdk:v1.8-branch nrfutil
Usage: nrfutil [OPTIONS] COMMAND [ARGS]...

Options:
  -v, --verbose            Increase verbosity of output. Can be specified more
                           than once (up to -v -v -v -v).
  -o, --output <filename>  Log output to file
  --help                   Show this message and exit.

Commands:
  dfu       Perform a Device Firmware Update over serial, BLE, Thread, Zigbee
            or ANT transport given a DFU package (zip file).
  keys      Generate and display private and public keys.
  pkg       Display or generate a DFU package (zip file).
  settings  Generate and display Bootloader DFU settings.
  version   Display nrfutil version.
  zigbee    Zigbee-related commands and utilities.
coderbyheart commented 2 years ago

Thanks for reporting. It seems the move to Zephyr SDK broke nrfutil. I'll investigate.

fgervais commented 2 years ago

I looked a bit more into this today and I think that nrfutil might be broken for everybody since last May 27.

Pretty unlikely bold statement I know but nrfutil is complaining that it wants protobuf package to 3.20.x or lower and there was actually nothing newer since May 27: https://pypi.org/project/protobuf/#history

If this is correct, I think it would be on nrfutil side to either update de pb file or add a requirement on the max version of it's protobuf dependency.

coderbyheart commented 2 years ago

Yes, there is a commit that fixes it in nrfutil, but a new release is not available. So manually downgrading protobuf fixes this problem.