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

Trying to build with Ninja results nrfjprog.py in an AttributeError.

I am able to build my project, but when I try to flash it to the board via ninja flash_<target> I can select the device in nrfjprog.py, I know, that I have to use "'0'" as input, so that the script doesn't result in an error, but then I get the following error:

nrf5_SDK_for_Mesh_v4.0.0_src/CMake/nrfjprog.py", line 93, in main
with multiprocessing.Pool(len(devices)) as p:
AttributeError: __exit__

Is there a way to fix this?

Parents
  • Hi Tilltheman, 

    Could you explain a little bit of the issue you have ? I'm not sure I understand this part " I know, that I have to use "'0'" as input, so that the script doesn't result in an error," 

    When you have multiple boards connected the script will ask you to input which board you want to program then you can enter "0" or other number or "a" for all. 

    Could you point to where you have the trouble ? 

    Note that you can also use nrfjprog.exe to flash directly. 

  • Hi Hung,

    thank you for your reply. I am using the SDK for mesh on an Ubuntu machine. When I try to flash the boards with cmake/ninja, it uses the python script nrfjprog.py to flash the hexfile to the boards. When I'm using just the character "0" Python interprets it as a number, which leads to an Attribute error, saying, that  0 as a number has no attribute "lower" which is correct. Lower is used to make a character which is Uppercase Lowercase. So, you have to use "'0'" as input. Then, the zero is interpretet as a character, the lowercase of character 0 is 0 so it works. Also the script uses a string when it compares "q" as input. I know all that. I just don't know where the error from the multiprocessing part is coming from. If I now want to flash more than one board with my workaround, it will fail because of this error. So, why does the multiprocessing part result in an error? Can someone reproduce that?

    So I am able to flash the board with the workaround, it is more a general question/bug report because I will have to flash more than one boards in my further project.

  • So I think I found the solution to this problem. I am using the SDK on an Ubuntu machine, as I said. On this machine I have two versions of python installed. Python2.7 and python3.6. cmake version is 3.10. When I try to build my project, cmake searches for the PythonInterpreter by calling

     

    find_package(PythonInterp)

    This for whatever reason does not return the interpreter for python3 but for python2.7. But the required one is Python3, because in Python3 the input-function always returns a String, instead of like in python2, where it returns an int if you enter 0. So in the CMakeLists.txt I changed the code to

    # Needed tools for generating documentation and serial PyACI
    if(CMAKE_VERSION VERSION_LESS 3.12)
            find_package(PythonInterp 3 REQUIRED)
    else ()
            find_package(Python3)
    endif()
    find_package(Doxygen)

    in order to use at least Python3 and from cmake version 3.12 on FindPythonInterp is deprecated. I did not test it with a cmake version higher than 3.12 yet, I hope it helps some people anyways.

  • Hello Hung,

    I just testet this on a machine with higher cmake package. We also have to actually set PYTHON_EXECUTABLE in the else-Part, because when searching for package Python3, cmake will set Python3_EXECUTABLE, where in the cmake-scripts it is checked for the existance of PYTHON_EXECUTABLE. So the code has to be the following:

    # Needed tools for generating documentation and serial PyACI
    if(CMAKE_VERSION VERSION_LESS 3.12)
        find_package(PythonInterp 3 REQUIRED)
    else ()
        find_package(Python3)
        SET(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")
    endif()

Reply
  • Hello Hung,

    I just testet this on a machine with higher cmake package. We also have to actually set PYTHON_EXECUTABLE in the else-Part, because when searching for package Python3, cmake will set Python3_EXECUTABLE, where in the cmake-scripts it is checked for the existance of PYTHON_EXECUTABLE. So the code has to be the following:

    # Needed tools for generating documentation and serial PyACI
    if(CMAKE_VERSION VERSION_LESS 3.12)
        find_package(PythonInterp 3 REQUIRED)
    else ()
        find_package(Python3)
        SET(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")
    endif()

Children
No Data
Related