This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Thingy:91 | Building and flashing from the command line

Hi! 

I had some time with the Thingy:91 and was able to get my own application running on the device using the nRF Connect Programmer application. 
To eliminate the need for clicking around I'd like to be able to flash the device using the CLI. 

I've tried to find information on this but I can only find documentation referencing a dedicated debugger, like nRF9160 DK. 

But I do not own one of those, and knowing that the nRF Programmer uses nrfjprog under the hood I was convinced it should be able to work on the CLI somehow. 
Unfortunately I wasn't able to figure it out myself, `nrfjprog --ids` doesn't show any IDs, even though the Thingy:91 is connected and it actually is showing up in the nRF Programmer application. 

And - as expected - running `nrfjprog -f nrf91 --program build/zephyr/app_signed.hex --sectorerase -r` results in an error:

"ERROR: There is no debugger connected to the PC."

I hope I'm on the right track...

Is there any way I could flash the device from the CLI?

Thanks!

  • Hello, 

    The Thingy:91 does not have an onboard debugger as the nRF9160DK does. This is why it relies on using the debugger from the nRF9160DK or mcuboot serial recovery. Have a look at this blog post on how the Thingy:91 was programmed earlier.

    Below is an example of how a script could handle this for you. 

    echo "Please set child_image/mcuboot.conf CONFIG_MCUBOOT_SERIAL=y and CONFIG_BOOT_SERIAL_DETECT_PIN to a corresponding button on your development kit!"
    echo "Hold down the button you chose, then reset the nRF to enter mcuboot serial recovery mode"
    
    mcumgr --conntype=serial --connstring='dev=/dev/ttyACM2,baud=115200' image upload -e build/zephyr/app_update.bin
    mcumgr --conntype=serial --connstring='dev=/dev/ttyACM2,baud=115200' reset

    Kind regards,
    Øyvind

  • Hi Øyvind,

    Thanks for your answer! 

    I had issues getting `mcumgr` to work (it only spits out segfault errors, even without any commands/arguments Shrug).

    But I read that mcumgr is a wrapper for newtmgr, which I was able to install without any problems.

    And since their commands are pretty much analogous, I was able to use your example script with newtmgr to flash my Thingy:91.

    I've been successful in flashing my device by running this code:

    newtmgr --conntype=serial --connstring='dev=/dev/tty.usbserial,baud=115200' image upload -e build/zephyr/app_update.bin
    newtmgr --conntype=serial --connstring='dev=/dev/tty.usbserial,baud=115200' reset

    It seems noticeably slower than flashing with the nRF Connect Programmer application, but it's consistent and works great, so I'm very thankful for your help. (slow speeds might be related to this GitHub issue)

    Just out of curiosity; 
    Is there any special reason why the CLI command require a .BIN file, while the nRF Connect Programmer needs a .HEX file? I'd expect the nRF Connect Programmer to run a very similar command to the CLI command I'm using now, is that not the case? 

    Thanks again for your assistance, I'm very glad I'm finally able to flash the device from the CLI!

  • Hey, 

    Happy to hear we found the solution!

    Tim Visser said:
    Just out of curiosity; 
    Is there any special reason why the CLI command require a .BIN file, while the nRF Connect Programmer needs a .HEX file? I'd expect the nRF Connect Programmer to run a very similar command to the CLI command I'm using now, is that not the case? 

    No other than simplicity is what I'm informed. 

    Kind regards,
    Øyvind

Related