This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

DFU SDK v16 on Mac OS X

Hi,  I am trying to get DFU from SDK16 working on my Mac.(Mac Os Mojave).  I am following the instruction on https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fble_sdk_app_dfu_bootloader.html

I have tried first to build the micro-eco library by clicking on the build_all.bat file and got the following errors from the Terminal.app:

/**************************

SLMini-I5-172:~ slareau$ /Users/slareau/nrf52_development/nRF5_SDK_16/external/micro-ecc/build_all.bat ; exit;

/Users/slareau/nrf52_development/nRF5_SDK_16/external/micro-ecc/build_all.bat: line 1: @ECHO: command not found

/Users/slareau/nrf52_development/nRF5_SDK_16/external/micro-ecc/build_all.bat: l: command not found

/Users/slareau/nrf52_development/nRF5_SDK_16/external/micro-ecc/build_all.bat: line 3: syntax error near unexpected token `('

/Users/slareau/nrf52_development/nRF5_SDK_16/external/micro-ecc/build_all.bat: line 3: `:: This script will use git (must be in %PATH%) and arm-none-eabi tools 'n combination with GNU Make

logout

Saving session...

...copying shared history...

...saving history...truncating history files...

...completed.

/*************************

To solve that step, I have navigate to the micro.ecc folder in terminal.  I have open the build_all.bat file in TexEdit ,  copy and paste the following command directly in Terminal.app  

git clone https://github.com/kmackay/micro-ecc.git

and then

make -C nrf52hf_armgcc/armgcc      // I believe that  the only one that I need for my project

This work perfectly. 

I have tried to generate a public and private key with nrf_util.  I have done that without problem in SDK14.3

nrf_util ask me to upgrade to the latest version with I did. 

In Terminal.app  I have navigate to the dfu folder where I want the key to be generated and type the command :

nrfutil keys generate priv.perm

I have the following problems :

/*****************************

SLMini-I5-172:dfu slareau$ nrfutil keys generate priv.perm

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/nrfutil", line 11, in <module>

    load_entry_point('nrfutil==6.0.1', 'console_scripts', 'nrfutil')()

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point

    return get_distribution(dist).load_entry_point(group, name)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2853, in load_entry_point

    return ep.load()

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2444, in load

    return self.resolve()

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2450, in resolve

    module = __import__(self.module_name, fromlist=['__name__'], level=0)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nordicsemi/__main__.py", line 52, in <module>

    from nordicsemi.dfu.dfu_transport_serial import DfuTransportSerial

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 53, in <module>

    from nordicsemi.dfu.dfu_trigger import DFUTrigger

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nordicsemi/dfu/dfu_trigger.py", line 48, in <module>

    import usb1

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/usb1/__init__.py", line 61, in <module>

    from . import libusb1

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/usb1/libusb1.py", line 199, in <module>

    libusb = _loadLibrary()

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/usb1/libusb1.py", line 173, in _loadLibrary

    return dll_loader('libusb-1.0' + suffix, **loader_kw)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 364, in __init__

    self._handle = _dlopen(self._name, mode)

OSError: dlopen(libusb-1.0.dylib, 6): image not found

/*******

It seems to have found the /libusb1   but not the libusb library.

In Terminal.app I type :  pip install libusb

/**************

SLMini-I5-172:dfu slareau$ pip install libusb

Requirement already satisfied: libusb in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (1.0.22b9)

Requirement already satisfied: setuptools>=42.0.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from libusb) (45.1.0)

Requirement already satisfied: atpublic>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from libusb) (1.0)

/***********

and the package seems to be install correctly.

Here a creenshoot of the folder 

At this point, I am not sure what is the next step.

  • Hi,

    The installation instructions are general for all OS, but if you have multiple versions of Python installed in your system you need to check that you are using the right version. In the Installing instructions for nRFutil it's stated that you should use Python 3.7 or later. 

    The sudo requirement is probably because of local settings / install permissions settings in your computer.

    Could you double check your python enviroment for pip install using command 'pip --version'? It looks like you are using the python 2 enviroment instead of python 3. Try 'pip3' instead.

    Did you run 'pip install -U setuptools' before installing the requirements?

    Have you installed pyinstaller?

    Best regards,

    Marjeris

  • Hi Marjeris,

    i ran pip3 install -U setuptools and as you can see, it says Requirement already up-to-date..

    Notice that I also running python3.7, as indicate earlier in the post.   Also, NrfUtils 6.0.0 was working before the latest upgrade, few days ago.

    _____

    SLMini-I5-172:~ slareau$ pip3 install -U setuptools

    Requirement already up-to-date: setuptools in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (45.1.0)

    ________

    Pip -- version   give me: 

    _______

    SLMini-I5-172:~ slareau$ pip --version

    pip 19.3.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)

    ________

    I am using pip and python 3.7 for programming currently without problems.

    I have tried to download and go back to nrfutil version 6.0.0 and it don't work anymore - same error as V6.0.1.  

    I would like to erase everything and restart from scratch but I am not sure what file was installed. I don't want to accidentally delete file that are used with my other program that use python

  • I believe that I have found the solution.  I have just follow my idea above and found the pip uninstall command.

    What I have done  is:

    in mac terminal.app, uninstall nrfutil by typing:

    1.  pip3 uninstall nrfutil   //  use pip3 to specify python3, if permission denied, use sudo before and enter password.

    2.  retype:  pip3 uninstall nrfutil   // make sure that all the file are gone.  Delete those remaining manually if needed.

    3.  Follow the installation instruction from : https://infocenter.nordicsemi.com/pdf/nrfutil_v1.7.pdf,  but replace all installation pip  command by: sudo pip 3  .  This will avoid permission denied error and install the file in python3 folders.   You also have to replace python commands by: python3.

    I have used the installation procedure in section from the above document without difficulty :  2.2 Installing from sources.  :  Typing:   nrfutil --help    confirm that the program is now functional.

    I have tried the following command to create a self-contained executable version of nrfutil, without success. :  pyinstaller nrfutil.spec

    The installation log indicate that several missing module that could not be import.  The command have generate an non-functional installation package.  Here a partial list of the errors.  At this point I will just use the nrfutil with terminal command and report if I have problems later.  I want to use the DFU utilities.

    Partial log report for pyinstaller nrfutil.spec:

    ///21280 INFO:   Matplotlib backend "MacOSX": added

    21664 INFO:   Matplotlib backend "nbAgg": ignored

        No module named 'IPython'

    22264 INFO:   Matplotlib backend "Qt4Agg": ignored

        Failed to import any qt binding

    22645 INFO:   Matplotlib backend "Qt4Cairo": ignored

        cairo backend requires that pycairo>=1.11.0 or cairocffiis installed

    23224 INFO:   Matplotlib backend "Qt5Agg": ignored

        Failed to import any qt binding

    23604 INFO:   Matplotlib backend "Qt5Cairo": ignored

        cairo backend requires that pycairo>=1.11.0 or cairocffiis installed

    24180 INFO:   Matplotlib backend "TkAgg": added

    24764 INFO:   Matplotlib backend "TkCairo": ignored

        cairo backend requires that pycairo>=1.11.0 or cairocffiis installed

    25146 INFO:   Matplotlib backend "WebAgg": ignored

        Traceback (most recent call last):

      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_webagg.py", line 26, in <module>

        import tornado

    ModuleNotFoundError: No module named 'tornado'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

      File "<string>", line 12, in <module>

      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_webagg.py", line 28, in <module>

        raise RuntimeError("The WebAgg backend requires Tornado.")

    RuntimeError: The WebAgg backend requires Tornado.

    25680 INFO:   Matplotlib backend "WX": ignored

        No module named 'wx'

    26065 INFO:   Matplotlib backend "WXAgg": ignored

        No module named 'wx'

    26454 INFO:   Matplotlib backend "WXCairo": ignored

        No module named 'wx'

  • Hi,

     Have you installed pyinstaller using 'pip3 install pyinstaller' ? Did you verify the version using 'pyinstaller --version'?

    Maybe these links could be of help?

    https://pyinstaller.readthedocs.io/en/stable/installation.html

    https://pyinstaller.readthedocs.io/en/stable/installation.html#verifying-the-installation

  • I have pyinstaller version 3.6 and it using python 3.7.   

    I believe the problem is that some modules/libraries did not get installed properly - see above : 

       import tornado

      ModuleNotFoundError: No module named 'tornado'

    Likely, installing those module manually would solve the problem.  However, I dont have time for this for now.  I have others issues to solve before returning to that topic.

    nrfutil work fine with Terminal.app for DFU usage.    I have not tried the other feature yet.

    Thanks 

Related