pynrfprog v19.0 modem update

Hi,

As part of our end of line test for our product we are updating the modem to a more recent version. We are using the pynrfprog library for this.

Previously we were running v17.3 of the pynrfprog and noticed an issue where repetive programming sessions would cause the following error.

NrfApplication.py", line 165, in flash_application
api.write(segment.address, segment.data, True)
File "C:\Users\Spike\AppData\Local\Programs\Python\Python311\Lib\site-packages\pynrfjprog\LowLevel.py", line 879, in write
raise APIError(result, error_data=self.get_errors())
pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -93 NOT_AVAILABLE_BECAUSE_TRUST_ZONE.

This would occur every other time (So it works correctly the first time, then would fail the next, then would work again etc.)

After updating to v19.0 it seemed to have fixed this issue but in the new software the modem updates no longer seem to work. We are using the following code: 

api = HighLevel.API()
api.open()
snr = api.get_connected_probes()
for s in snr:
    probe = HighLevel.IPCDFUProbe(api, s, HighLevel.CoProcessor.CP_MODEM)
    probe.program(".\provisioning-python-script\mfw_nrf9160_1.3.3.zip")
    probe.verify(".\provisioning-python-script\mfw_nrf9160_1.3.3.zip")
    probe.close()
    print("Done")
api.close()

This results in the following error:

probe.program(".\provisioning-python-script\mfw_nrf9160_1.3.3.zip")
File "C:\Users\Spike\AppData\Local\Programs\Python\Python311\Lib\site-packages\pynrfjprog\HighLevel.py", line 388, in program
raise APIError(result, error_data=self.get_errors(), log=self._logger.error)
pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -220 TIME_OUT.
[Probes.51025440] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
extra: [Probes.51025440] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
extra: [Probes.51025440] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
extra: [Probes.51025440] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
extra: [Probes.51025440] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
extra: [Probes.51025440] [DebugProbe] Failed while programming device.
extra: [HighLevel] Failed programming the device.
extra: [Probes.51025440] [nRF91] Timeout, operation used more than 10 sec
extra: [Probes.51025440] [nRF91] Failed in wait for ack
extra: [Probes.51025440] [nRF91] Failed while waiting for program operation to finish.
extra: [Probes.51025440] [nRF91] Failed to upload file
extra: [Probes.51025440] [nRF91] Failed while programming package .\provisioning-python-script\mfw_nrf9160_1.3.3.zip.

The exact same script works fine on version 17.3.

Is there anything changed in the latest version which could cause this problem?

Kind regards,

Sebastiaan

  • Hi Sebastiann,

    Please install nRF Command Line Tools - Downloads - nordicsemi.com so JLink could also be updated.

    I just with python 3.8.10. Everything looks fine.

    PS C:\NCS\nrf9160_modem_update_script> pip uninstall pynrfjprog
    Found existing installation: pynrfjprog 10.17.3
    Uninstalling pynrfjprog-10.17.3:
      Would remove:
        c:\users\chs1\appdata\local\programs\python\python38\lib\site-packages\pynrfjprog-10.17.3.dist-info\*
        c:\users\chs1\appdata\local\programs\python\python38\lib\site-packages\pynrfjprog\*
    Proceed (y/n)? y
      Successfully uninstalled pynrfjprog-10.17.3
    PS C:\NCS\nrf9160_modem_update_script> pip install pynrfjprog
    Collecting pynrfjprog
      Using cached pynrfjprog-10.19.0.tar.gz (45.3 MB)
    Requirement already satisfied: future in c:\users\chs1\appdata\local\programs\python\python38\lib\site-packages (from pynrfjprog) (0.18.2)
    Requirement already satisfied: tomli-w in c:\users\chs1\appdata\roaming\python\python38\site-packages (from pynrfjprog) (1.0.0)
    Using legacy 'setup.py install' for pynrfjprog, since package 'wheel' is not installed.
    Installing collected packages: pynrfjprog
        Running setup.py install for pynrfjprog ... done
    Successfully installed pynrfjprog-10.19.0
    WARNING: You are using pip version 21.1.3; however, version 23.0 is available.
    You should consider upgrading via the 'c:\users\chs1\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command.
    PS C:\NCS\nrf9160_modem_update_script> python .\nrf9160_modem_update.py
    snr:%s 960061675
    programming...
    verifying...
    Done
    PS C:\NCS\nrf9160_modem_update_script> python --version
    Python 3.8.10
    PS C:\NCS\nrf9160_modem_update_script>

    #!/usr/bin/env python3
    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    
    
    from pynrfjprog import HighLevel
    api = HighLevel.API()
    api.open()
    snr = api.get_connected_probes()
    for s in snr:
        print("snr:%s",s)
        probe = HighLevel.IPCDFUProbe(api, s, HighLevel.CoProcessor.CP_MODEM)
        print("programming...")
        probe.program("mfw_nrf9160_1.3.4.zip")
        print("verifying...")
        probe.verify("mfw_nrf9160_1.3.4.zip")
        print("Done")
     
    api.close()

    Best regards,

    Charlie

  • I have the same problem

    - nRF command line tools 10.19.0

    - JLink software & documentation pack 7.86c

    - Python 3.10.9

    from pynrfjprog import HighLevel
    from sys import argv
    import logging
    
    logging.basicConfig(level=logging.INFO, format="%(message)s")
    
    # https://www.nordicsemi.com/Products/nRF9160/Download#infotabs
    fw_file = argv[1]
    
    with HighLevel.API() as api:
        snr = api.get_connected_probes()[0]
        with HighLevel.IPCDFUProbe(api, snr, HighLevel.CoProcessor.CP_MODEM) as probe:
            probe.program(
                fw_file,
                HighLevel.ProgramOptions(verify=HighLevel.VerifyAction.VERIFY_HASH),
            )

    [HighLevel] Creating new probe
    [HighLevel] Initialize new probe.
    [Probes.261008974] [DebugProbe] Load library at /usr/lib/python3.10/site-packages/pynrfjprog/lib_x64/libnrfjprogdll.so.
    [Probes.261008974] [DebugProbe] Library loaded, loading member functions.
    [Probes.261008974] [DebugProbe] Member functions succesfully loaded.
    [Probes.261008974] [Client] stdout: Jlinkarm nRF Worker ready. Handling sequence 7884f9e0-614e-4345-957c-882c48513a5a.
    [Probes.261008974] [SeggerBackend] Load library at /opt/SEGGER/JLink/libjlinkarm.so.
    [Probes.261008974] [SeggerBackend] Library loaded, loading member functions.
    [Probes.261008974] [SeggerBackend] Member functions succesfully loaded.
    [Probes.261008974] [SeggerBackend] Segger dll version 7.86.c loaded.
    [Probes.261008974] [DebugProbe] Connecting to device from NRF91 family.
    [HighLevel] Read Device Info.
    [Probes.261008974] [DebugProbe] Read device info
    [Probes.261008974] [DebugProbe] Update device info
    [Probes.261008974] [DebugProbe] Device info initialize returned error -90
    [Probes.261008974] [DebugProbe] DEVICE INFO: (INCOMPLETE)
    [Probes.261008974] [DebugProbe] =============================
    [Probes.261008974] [DebugProbe] device_type                = NRF9160_xxAA_REV2
    [Probes.261008974] [DebugProbe] device_family              = NRF91
    [Probes.261008974] [DebugProbe] pin_reset_enable_supported = false
    [Probes.261008974] [DebugProbe] device_protected           = true
    [Probes.261008974] [DebugProbe] =============================
    [Probes.261008974] [DebugProbe] Device memory information is unavailable due to readback protection.
    [Probes.261008974] [DebugProbe] PROGRAM OPTIONS:
    [Probes.261008974] [DebugProbe] =============================
    [Probes.261008974] [DebugProbe] verify            = VERIFY_HASH
    [Probes.261008974] [DebugProbe] chip_erase_mode   = ERASE_ALL
    [Probes.261008974] [DebugProbe] qspi_erase_mode   = ERASE_NONE
    [Probes.261008974] [DebugProbe] reset             = 1
    [Probes.261008974] [DebugProbe] =============================
    [Probes.261008974] [nRFXX] Discovered device from family NRF91.
    [Probes.261008974] [nRF91] Loading new coprocessor data.
    [Probes.261008974] [nRF91] Protection status for ahb-ap 1 read as ALL
    [Probes.261008974] [nRF91] Protection status for ahb-ap 1 read as ALL
    [Probes.261008974] [nRF91] Erasing package mfw_nrf9160_1.3.4.zip
    [Probes.261008974] [nRF91] Programming package mfw_nrf9160_1.3.4.zip
    [Probes.261008974] [nRF91] {"amountOfSteps":4,"description":"Finding image components","duration":0,"message":"Detecting package components","operation":"confirm_image","progressPercentage":25,"step":1}
    [Probes.261008974] [nRF91] {"amountOfSteps":4,"description":"Finding image components","duration":0,"message":"Verifying that package is complete","operation":"confirm_image","progressPercentage":50,"step":2}
    [Probes.261008974] [nRF91] {"amountOfSteps":4,"description":"Finding image components","duration":0,"message":"Detecting bootloader version","operation":"confirm_image","progressPercentage":75,"step":3}
    [Probes.261008974] [nRF91] {"amountOfSteps":4,"description":"Finding image components","duration":0,"message":"Finished","operation":"confirm_image","progressPercentage":100,"result":"success","step":4}
    [Probes.261008974] [nRF91] {"amountOfSteps":5,"description":"Upload segments","duration":0,"message":"Prepare modem for upload","operation":"enter_programming_state","progressPercentage":20,"step":1}
    [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":0,"message":"Configure hw.","operation":"enter_programming_state","progressPercentage":11,"step":1}
    [Probes.261008974] [nRF91] Loading new coprocessor data.
    [Probes.261008974] [nRF91] Protection status for ahb-ap 0 read as NONE
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":30,"message":"Check and fix UICR data.","operation":"enter_programming_state","progressPercentage":22,"step":2}
    [Probes.261008974] [nRF91] Protection status for ahb-ap 0 read as NONE
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":101,"message":"Configure IPC","operation":"enter_programming_state","progressPercentage":33,"step":3}
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":108,"message":"Configure SPU","operation":"enter_programming_state","progressPercentage":44,"step":4}
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":140,"message":"Clear IPC events","operation":"enter_programming_state","progressPercentage":55,"step":5}
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":143,"message":"Send IPC DFU indication","operation":"enter_programming_state","progressPercentage":66,"step":6}
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":146,"message":"Reset modem","operation":"enter_programming_state","progressPercentage":77,"step":7}
    [Probes.261008974] [nRF91] Protection status for ahb-ap 0 read as NONE
    [Probes.261008974] [nRF91] Protection status for ahb-ap 0 read as NONE
    [Probes.261008974] [nRF91] Protection status for ahb-ap 0 read as NONE
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":170,"message":"Wait for modem bootup","operation":"enter_programming_state","progressPercentage":88,"step":8}
    [Probes.261008974] [nRF91] {"amountOfSteps":9,"description":"Initialize modem","duration":225,"message":"Modem started and ready for bootloader","operation":"enter_programming_state","progressPercentage":100,"result":"success","step":9}
    [Probes.261008974] [nRF91] {"amountOfSteps":5,"description":"Upload segments","duration":1742,"message":"Upload bootloader","operation":"enter_programming_state","progressPercentage":40,"step":2}
    [Probes.261008974] [nRF91] {"amountOfSteps":2,"description":"Starting modem boot loader","duration":0,"message":"72B3D7C.ipc_dfu.signed_1.1.0.ihex","operation":"enter_programming_state","progressPercentage":50,"step":1}
    [Probes.261008974] [nRF91] Extracting 13416 bytes from 72B3D7C.ipc_dfu.signed_1.1.0.ihex.
    [Probes.261008974] [nRF91] Extracting 13416 bytes from 72B3D7C.ipc_dfu.signed_1.1.0.ihex.
    [Probes.261008974] [nRF91] {"amountOfSteps":3,"description":"Start modem bootloader","duration":228,"message":"Upload bootloader","operation":"enter_programming_state","progressPercentage":33,"step":1}
    [Probes.261008974] [nRF91] Allocate program buffers.
    [Probes.261008974] [nRF91] Check program file
    [Probes.261008974] [nRF91] {"amountOfSteps":3,"description":"Program file","duration":0,"message":"Checking image","operation":"upload_image","progressPercentage":33,"step":1}
    [Probes.261008974] [nRF91] {"amountOfSteps":5,"description":"Check image validity","duration":0,"message":"Initialize device info","operation":"confirm_image","progressPercentage":20,"step":1}
    [Probes.261008974] [nRF91] {"amountOfSteps":5,"description":"Check image validity","duration":0,"message":"Check region 0 settings","operation":"confirm_image","progressPercentage":40,"step":2}
    [Probes.261008974] [nRF91] {"amountOfSteps":5,"description":"Check image validity","duration":0,"message":"block 1 of 3","operation":"confirm_image","progressPercentage":60,"step":3}
    [Probes.261008974] [nRF91] {"amountOfSteps":5,"description":"Check image validity","duration":0,"message":"Finished","operation":"confirm_image","progressPercentage":100,"result":"success","step":5}
    [Probes.261008974] [nRF91] {"amountOfSteps":3,"description":"Program file","duration":0,"message":"Programming","operation":"upload_image","progressPercentage":66,"step":2}
    [Probes.261008974] [nRF91] Program RAM.
    [Probes.261008974] [nRF91] Protection status for ahb-ap 0 read as NONE
    [Probes.261008974] [nRF91] {"amountOfSteps":3,"description":"Programming image","duration":0,"message":"block 1 of 2","operation":"upload_image","progressPercentage":33,"step":1}
    [Probes.261008974] [nRF91] {"amountOfSteps":3,"description":"Programming image","duration":0,"message":"Write successful","operation":"upload_image","progressPercentage":100,"result":"success","step":3}
    [Probes.261008974] [nRF91] {"amountOfSteps":3,"description":"Program file","duration":54,"message":"Done programming","operation":"upload_image","progressPercentage":100,"result":"success","step":3}
    [Probes.261008974] [nRF91] {"amountOfSteps":3,"description":"Start modem bootloader","duration":284,"message":"Bootloader uploaded","operation":"enter_programming_state","progressPercentage":66,"step":2}
    [Probes.261008974] [nRF91] {"amountOfSteps":3,"description":"Start modem bootloader","duration":521,"message":"Bootloader started","operation":"enter_programming_state","progressPercentage":100,"result":"success","step":3}
    [Probes.261008974] [nRF91] {"amountOfSteps":2,"description":"Starting modem boot loader","duration":2038,"message":"Finished","operation":"enter_programming_state","progressPercentage":100,"result":"success","step":2}
    [Probes.261008974] [nRF91] {"amountOfSteps":5,"description":"Upload segments","duration":2038,"message":"Modem ready for upload","operation":"enter_programming_state","progressPercentage":60,"step":3}
    [Probes.261008974] [nRF91] {"amountOfSteps":5,"description":"Upload segments","duration":0,"message":"segment 1 of 2","operation":"upload_image","progressPercentage":80,"step":4}
    [Probes.261008974] [nRF91] Extracting 6480 bytes from firmware.update.image.segments.0.hex.
    [Probes.261008974] [nRF91] {"amountOfSteps":1,"description":"Uploading modem image","duration":0,"message":"segment 1 of 2","operation":"upload_image","progressPercentage":100,"result":"success","step":1}
    [Probes.261008974] [DebugProbe] Failed while programming device.
    [HighLevel] Failed programming the device.
    [Probes.261008974] [nRF91] Timeout, operation used more than 10 sec
    [Probes.261008974] [nRF91] Failed in wait for ack
    [Probes.261008974] [nRF91] Failed while waiting for program operation to finish.
    [Probes.261008974] [nRF91] {"amountOfSteps":0,"description":"Uploading modem image","message":"Failed while waiting for program operation to finish.","operation":"upload_image","progressPercentage":0,"result":"fail","step":0}
    [Probes.261008974] [nRF91] Failed to upload file
    [Probes.261008974] [nRF91] {"amountOfSteps":0,"description":"Upload segments","message":"Failed to upload file","operation":"upload_image","progressPercentage":0,"result":"fail","step":0}
    [Probes.261008974] [nRF91] Failed while programming package mfw_nrf9160_1.3.4.zip.
    [Probes.261008974] b'An error was reported by NRFJPROG DLL: -220 TIME_OUT. \n[Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".\n\textra: [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".\n\textra: [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".\n\textra: [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".\n\textra: [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".\n\textra: [Probes.261008974] [DebugProbe] Failed while programming device.\n\textra: [HighLevel] Failed programming the device.\n\textra: [Probes.261008974] [nRF91] Timeout, operation used more than 10 sec\n\textra: [Probes.261008974] [nRF91] Failed in wait for ack\n\textra: [Probes.261008974] [nRF91] Failed while waiting for program operation to finish.\n\textra: [Probes.261008974] [nRF91] Failed to upload file\n\textra: [Probes.261008974] [nRF91] Failed while programming package mfw_nrf9160_1.3.4.zip.'
    [Probes.261008974] [DebugProbe] Uninitializing probe with serial number 261008974.
    [HighLevel] Done.
    [HighLevel] Closing and freeing sub dlls.
    Traceback (most recent call last):
      File "/home/neye/dev/cas_industrie_40_labs/Lab_1_with_thingy/Firmware/./update_modem_fw.py", line 23, in <module>
        probe.program(
      File "/usr/lib/python3.10/site-packages/pynrfjprog/HighLevel.py", line 388, in program
        raise APIError(result, error_data=self.get_errors(), log=self._logger.error)
    pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -220 TIME_OUT.
    [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    	extra: [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    	extra: [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    	extra: [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    	extra: [Probes.261008974] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
    	extra: [Probes.261008974] [DebugProbe] Failed while programming device.
    	extra: [HighLevel] Failed programming the device.
    	extra: [Probes.261008974] [nRF91] Timeout, operation used more than 10 sec
    	extra: [Probes.261008974] [nRF91] Failed in wait for ack
    	extra: [Probes.261008974] [nRF91] Failed while waiting for program operation to finish.
    	extra: [Probes.261008974] [nRF91] Failed to upload file
    	extra: [Probes.261008974] [nRF91] Failed while programming package mfw_nrf9160_1.3.4.zip.

      

  • I just realized that this works:

    nrfjprog --verify --program mfw_nrf9160_1.3.4.zip

  • I have the very same problem.

    - nRF command line tools 10.21.0

    - JLink software & documentation pack 7.86h

    - Python 3.10.6

    - pynrfjprog-10.19.0-py3-none-any.whl

    Device a: nRF9160 DK connected via its USB port -> works perfectly with any method

    Device b: nRF9160 SiP in our device connected via Segger JLink on its SWDIO/SWDCLK pins -> no way

    (One device connected at a time, of course)

    Both devices have the same version of SLM app installed. (Well, with blanked app it should do as well)
    The DK had MFW 1.3.3 installed before I tried and upgraded it to 1.3.4
    The SiP, since the MFW was never flashed successfully (while the app does), identifies with mfw-pti_nrf9160_1.1.5

    a) Using nrfjprog

    lamm@fonb038:~$ nrfjprog --log --verify --program mfw_nrf9160_1.3.4.zip
    [ #################### ] 0.000s | Finding image components - Finished
    [error] [ Client] - Encountered error -220: Command program_file executed for 10091 milliseconds with result -220
    [error] [ nRF91] - Failed to install bootloader
    [error] [ nRF91] - Failed to program bootloader file
    Timeout, operation used more than 10 seconds
    [error] [ Worker] - Timeout, operation used more than 10 seconds
    ERROR: Operation failed due to timeout. Check the log messages for more details.

    b) Using pynrfprog script like above

    lamm@fonb038:~$ ./mfw_prog.py mfw_nrf9160_1.3.4.zip
    Traceback (most recent call last):
      File "/home/lamm/mfw_prog.py", line 17, in <module>
        probe.program(firmware)
      File "/home/lamm/.local/lib/python3.10/site-packages/pynrfjprog/HighLevel.py", line 388, in program
        raise APIError(result, error_data=self.get_errors(), log=self._logger.error)
    pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -220 TIME_OUT.
    [Probes.51022075] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
        extra: [Probes.51022075] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
        extra: [Probes.51022075] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
        extra: [Probes.51022075] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
        extra: [Probes.51022075] [SeggerBackend] JLinkARM.dll reported "-261", "Could not find supported CPU.".
        extra: [Probes.51022075] [DebugProbe] Failed while programming device.
        extra: [HighLevel] Failed programming the device.
        extra: [Probes.51022075] [nRF91] Timeout, operation used more than 10 sec
        extra: [Probes.51022075] [nRF91] Failed in wait for ack
        extra: [Probes.51022075] [nRF91] Failed while waiting for program operation to finish.
        extra: [Probes.51022075] [nRF91] Failed to upload file
        extra: [Probes.51022075] [nRF91] Failed while programming package /home/lamm/FB/nRF91/mfw_nrf9160_1.3.4.zip.

    c) nRF Connect Programmer v3.0.8:

  • Update: After trying 20 times with mfw 1.3.4 and 1.3.3, I could flash mfw 1.3.2 on first try and then upgrade to 1.3.4 without problems.

Related