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

Updating nrf9160 modem firmware through the command line

We are producing a batch of nrf9160 based devices and will need to upgrade the modem firmware, this will be much easier if we could do this through the command but I saw on modem firmware version 1.0.0  and after, you no longer provide a flashing tool and recommend nRF Programmer.

Can the old nrf9160_mdm_dfu be used with the newer modem firmware or how would you recommend upgrading modems through the command line?

Parents
  • Hi,

    It's possible to use a python script with pynrfjprog to flash the modem. 

    Simple example:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    #!/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:
    probe = HighLevel.IPCDFUProbe(api, s, HighLevel.CoProcessor.CP_MODEM)
    probe.program("mfw_nrf9160_1.0.1.zip")
    probe.verify("mfw_nrf9160_1.0.1.zip")
    print("Done")
    api.close()
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    With threading[experimental]

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #!/usr/bin/env python3
    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    from pynrfjprog import HighLevel
    import threading
    class myThread (threading.Thread):
    def __init__(self, threadID, name, counter):
    threading.Thread.__init__(self)
    self.threadID = threadID
    self.name = name
    self.counter = counter
    def run(self):
    print ("Starting " + self.name)
    update_fw(self.name)
    print ("Exiting " + self.name)
    def update_fw(snr):
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I'm having issues with the DLL file on "HighLevel.IPCDFUProbe(...)", I'm on Linux so guessing it means the .so file

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    import argparse
    import os
    from pynrfjprog import HighLevel
    def main():
    parser = argparse.ArgumentParser(description='Update modem firmware of nrf9160 devices.')
    parser.add_argument('-f', '--firmware', dest='firmware', type=str, help='Absolute path to modem firmware zip')
    args = parser.parse_args()
    if args.firmware is None:
    print("ERROR: Path to firmware was not given")
    return -1
    if not os.path.exists(args.firmware):
    print("ERROR: {} does not exist".format(args.firmware))
    return -1
    api = HighLevel.API()
    api.open()
    snr = api.get_connected_probes()
    for s in snr:
    probe = HighLevel.IPCDFUProbe(api, s, HighLevel.CoProcessor.CP_MODEM, jlink_arm_dll_path="/opt/nrfjprog")
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I get -100 JLINKARM_DLL_NOT_FOUND when I point to a folder containing some .so files. I also tried pointing to /opt/SEGGER/Jlink

    I get -151 NRFJPROG_SUB_DLL_COULD_NOT_BE_OPENED if don't specify the path

  • What version of nrfjprog and pynrfjprog are you using ?

    There are some reported issues with nrfjrpog 10.4.0 on Linux, so at the moment you should try to use 10.3.0 on linux for nrfjprog and pynrfjprog.

    It could be that you have an older pynrfjprog installed. Try to run this:

    pip3 install pynrfjprog==10.3.0 -U

  • Ok that seemed to work, is there a way to add some debug information during the flashing and verifying?

    I see within IPCDFUProbe, logging is enabled by default but I don't see any logging

  • Hi,

    is there a way to add some debug information during the flashing and verifying?

    Yes.

    Take look at this file. Logging level is set to INFO here.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #!/usr/bin/env python3
    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    import os
    import time
    import argparse
    import subprocess
    import logging
    from tempfile import TemporaryDirectory, mkstemp
    from pynrfjprog import HighLevel
    logging.basicConfig(level=logging.INFO)
    log = logging.getLogger('modem_update')
    def flash_modem_pkg(modem_zip, verify):
    start = time.time()
    with HighLevel.API(True) as api:
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    (Using f-Strings(introduced in python 3.6))

  • Thanks, I have put in prints before and after all of the probe commands as well but I was wondering if there was any logging during the actual verify and program command, like in the nRF Connect Programmer when it gives the progress of the flashing and verifying

  • like in the nRF Connect Programmer when it gives the progress of the flashing and verifying

    Yes, this is what INFO logging does. 

    Here is how the output from the script looks like:

Reply Children