<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53208/updating-nrf9160-modem-firmware-through-the-command-line</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 17 Oct 2019 09:14:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53208/updating-nrf9160-modem-firmware-through-the-command-line" /><item><title>RE: Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/thread/215445?ContentTypeID=1</link><pubDate>Thu, 17 Oct 2019 09:14:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75a2af99-f55a-4398-822f-0ae9dec8c7f2</guid><dc:creator>RonanB96</dc:creator><description>&lt;p&gt;Oh sorry, my python is as strong as I thought, I&amp;#39;m not sure how that made the internal logging start working but thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/thread/215438?ContentTypeID=1</link><pubDate>Thu, 17 Oct 2019 08:49:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55540a40-aeaf-4dbc-b753-7c72c04b9c5c</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="75225" url="~/f/nordic-q-a/53208/updating-nrf9160-modem-firmware-through-the-command-line/215435"]like in the nRF Connect Programmer when it gives the progress of the flashing and verifying[/quote]
&lt;p&gt;Yes, this is what INFO logging does.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here is how the output&amp;nbsp;from the script looks like:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1571302188498v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/thread/215435?ContentTypeID=1</link><pubDate>Thu, 17 Oct 2019 08:45:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4372e44-2e54-44f6-8210-05abb774e62a</guid><dc:creator>RonanB96</dc:creator><description>&lt;p&gt;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&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/thread/215357?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2019 14:50:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27396cfc-94ac-4a0a-b26e-2d88bf1fb173</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="75225" url="~/f/nordic-q-a/53208/updating-nrf9160-modem-firmware-through-the-command-line/214914"] is there a way to add some debug information during the flashing and verifying?[/quote]
&lt;p&gt;Yes.&lt;/p&gt;
&lt;p&gt;Take look at this file.&amp;nbsp;Logging level is set to INFO here.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#!/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(&amp;#39;modem_update&amp;#39;)


def flash_modem_pkg(modem_zip, verify):
    start = time.time()
    with HighLevel.API(True) as api:
        snr = api.get_connected_probes()
        for s in snr:
            log.info(&amp;quot;Establish board connection&amp;quot;)
            log.info(f&amp;quot;Flashing &amp;#39;{modem_zip}&amp;#39; to board {s}&amp;quot;)
            with HighLevel.IPCDFUProbe(api, s, HighLevel.CoProcessor.CP_MODEM) as probe:
                log.info(f&amp;quot;Programming &amp;#39;{modem_zip}&amp;#39;&amp;quot;)
                probe.program(modem_zip)
                log.info(&amp;quot;Programming complete&amp;quot;)
                if verify:
                    log.info(&amp;quot;Verifying&amp;quot;)
                    probe.verify(modem_zip)
                    log.info(&amp;quot;Verifying complete&amp;quot;)
        api.close()
        log.info(f&amp;quot;Completed in {time.time() - start} seconds&amp;quot;)

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(&amp;quot;modem_pkg&amp;quot;)
    args = parser.parse_args()
    log.info(&amp;quot;Modem firmware upgrade&amp;quot;)
    flash_modem_pkg(args.modem_pkg,True)

if __name__ == &amp;#39;__main__&amp;#39;:
    main()&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;(Using f-Strings(introduced in python 3.6))&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/thread/214914?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 15:29:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a31e557-fb3a-46d6-aeb8-005cf144bde1</guid><dc:creator>RonanB96</dc:creator><description>&lt;p&gt;Ok that seemed to work, is there a way to add some debug information during the flashing and verifying?&lt;/p&gt;
&lt;p&gt;I see within&amp;nbsp;&lt;span&gt;IPCDFUProbe, logging is enabled by default but I don&amp;#39;t see any logging&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/thread/214911?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 15:17:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50a52174-a2f1-4a0f-b6dc-8dae40b455f9</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;What version of nrfjprog and&amp;nbsp;&lt;span&gt;pynrfjprog are you using ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;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&amp;nbsp;nrfjprog and&amp;nbsp;pynrfjprog. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It could be that you have an older&amp;nbsp;pynrfjprog&amp;nbsp;installed. Try to run this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;pip3 install pynrfjprog==10.3.0 -U&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/thread/214907?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 15:00:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bffb393b-e3ec-458a-b981-af3212f6bc2a</guid><dc:creator>RonanB96</dc:creator><description>&lt;p&gt;I&amp;#39;m having issues with the DLL file on &amp;quot;HighLevel.IPCDFUProbe(...)&amp;quot;, I&amp;#39;m on Linux so guessing it means the .so file&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;import argparse
import os
from pynrfjprog import HighLevel


def main():
    parser = argparse.ArgumentParser(description=&amp;#39;Update modem firmware of nrf9160 devices.&amp;#39;)
    parser.add_argument(&amp;#39;-f&amp;#39;, &amp;#39;--firmware&amp;#39;, dest=&amp;#39;firmware&amp;#39;, type=str, help=&amp;#39;Absolute path to modem firmware zip&amp;#39;)
    args = parser.parse_args()
    if args.firmware is None:
        print(&amp;quot;ERROR: Path to firmware was not given&amp;quot;)
        return -1
    if not os.path.exists(args.firmware):
        print(&amp;quot;ERROR: {} does not exist&amp;quot;.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=&amp;quot;/opt/nrfjprog&amp;quot;)
        probe.program(args.firmware)
        probe.verify(args.firmware)
        print(&amp;quot;Done&amp;quot;)

    api.close()
    return 0


if __name__ == &amp;quot;__main__&amp;quot;:
    main()
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I get&amp;nbsp;-100 JLINKARM_DLL_NOT_FOUND when I point to a folder containing some .so files. I also tried pointing to /opt/SEGGER/Jlink&lt;/p&gt;
&lt;p&gt;I get -151 NRFJPROG_SUB_DLL_COULD_NOT_BE_OPENED if don&amp;#39;t specify the path&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating nrf9160 modem firmware through the command line</title><link>https://devzone.nordicsemi.com/thread/214830?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2019 12:25:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0836570a-4bf0-47b0-b68c-c1197513d438</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It&amp;#39;s possible to use a python script with&amp;nbsp;&lt;/span&gt;&lt;span&gt;pynrfjprog to flash the modem.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simple example:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#!/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(&amp;quot;mfw_nrf9160_1.0.1.zip&amp;quot;)
    probe.verify(&amp;quot;mfw_nrf9160_1.0.1.zip&amp;quot;)
    print(&amp;quot;Done&amp;quot;)
 
api.close()&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;With threading[experimental]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#!/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 (&amp;quot;Starting &amp;quot; + self.name)
      update_fw(self.name)
      print (&amp;quot;Exiting &amp;quot; + self.name)
 
def update_fw(snr):
    print(&amp;quot;updating FW in {}&amp;quot;.format(snr))
    probe = HighLevel.IPCDFUProbe(api, int(snr), HighLevel.CoProcessor.CP_MODEM)
    print(&amp;quot;{} probe initialized&amp;quot;. format(snr))
    probe.program(&amp;quot;mfw_nrf9160_1.0.1.zip&amp;quot;)
    print(&amp;quot;{} programmed&amp;quot;.format(snr))
    probe.verify(&amp;quot;mfw_nrf9160_1.0.1.zip&amp;quot;)
    print(&amp;quot;{} verified&amp;quot;.format(snr))
 
# Create new threads
api = HighLevel.API()
api.open()
devices = api.get_connected_probes()
threads = list()
for idx, device in enumerate(devices):
    threads.append(myThread(idx, device, idx))
 
# Start new Threads
for thread in threads:
    thread.start()
 
print(&amp;quot;waiting for all threads to complete&amp;quot;)
#wait for threads to finish
for t in threads:
    t.join()
 
api.close()
print(&amp;quot;Exiting Main Thread&amp;quot;)&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>