• Support
  • Using newtmgr for common west builds?

I used to make builds (also) from the cli, e.g.

west build -d build_feather_nrf9160_ns -b circuitdojo_feather_nrf9160_ns --pristine -- -DOVERLAY_CONFIG="60min0-prj.conf" 

in order to chose some configuration profiles. That works with “west flash -d build_feather_nrf9160_ns” and a jlink.
Is it possible to use “newtmgr” from cli without VS?

For me, there is a gap.
I use Ubuntu 20.04. I don’t use the examples, I use a project (https://github.com/boaks/zephyr-coaps-client), which is working so far with VS or “west flash” using Jlink, or the serial mcuboot with nRF Connect for Desktop.
Using jlink still works (the nRF9160-DK must be switch to 3V).
Using nRF Connect for Desktop (v3.1.2), Programmer (v3.0.4) seems to reject the feather with “Unsupported device. The detected device could not be recognized as neither JLink device nor Nordic USB device.” Open /dev/ttyUSB0 works, so I’m not sure, if the Nordic Programmer just don’t support it any more.

If I use newtmgr with VS task (Step 3), then it reports “Binary not found. Build project before loading.”
Checking the file system, with

ls -l build/zephyr/app_*
-rw-rw-r– 1 achim achim 1382622 Jan 14 14:12 build/zephyr/app_moved_test_update.hex
-rw-rw-r– 1 achim achim 679676 Jan 14 14:12 build/zephyr/app_signed.hex
-rw-rw-r– 1 achim achim 679732 Jan 14 14:12 build/zephyr/app_test_update.hex
-rw-rw-r– 1 achim achim 246460 Jan 14 14:12 build/zephyr/app_to_sign.bin
-rw-rw-r– 1 achim achim 247124 Jan 14 14:12 build/zephyr/app_update.bin

so the file is there. The project was there before I installed the zephyr tools. Maybe I need to add the tools to the existing project?

If I enter newtmgr on the CLI (Ubuntu), it reports “cmd not found”.
The SDK setup describes, how to install the VS extensions. But it seems, that this doesn’t add that tool to the OS path.

So:
Do I need to “add the zephyr tools” somehow to the VS project?
Is it possible to install the newtmgr in the OS to be used directly by the OS CLI?

    I’m one step further ;-).

    Using the VS internal bash, newtmgr is available:

    "
    newtmgr -c vscode-zephyr-tools image upload build_feather_nrf9160_ns/zephyr/app_update.bin
    0 B / 241.33 KiB [——————————————————————–] 0.00%
    Error: NMP timeout

    I use the new v5 feather. I get the same error, if I use “newtmgr -c vscode-zephyr-tools reset”

      @AchimKraus how are you building your project? You need to build with the VSCode commands for the extension to know where to look. If you, at the very least, set the project Zephyr Tools : Change Project to the project you’re building it should be able to find the app_update.bin.

        I setup VS with the example projects on a other Ubuntu 20.04 machine.
        My results: It only works, if the boot mode is manually enabled, even with v5.
        (With that, it works also on the other.)
        I will try to set it up on Windows 10 to see, if it works without pressing buttons there.

          AchimKraus while capable, Windows doesn’t work due to a driver incompatibility.

          As for Ubuntu, you need to issue the zephyr-tools -b command in the command line to get the device into bootloader. This is not handled by newtmgr

            Thanks!

            zephyr-tools -b
            Device found but failed to open: Access denied (insufficient permissions)
            Could not open device 10c4:ea60

            My user is member of “dialout” and “ttyUSB0” also belongs to that group.
            Any other groups to add?

            Using

            sudo zephyr-tools -b
            sudo: zephyr-tools: cmd not found

            fails as well.

              I was also able to try it on Windows 10. It fails there also with some errors.

              Device found but failed to open: Operation not supported or unimplemented on this platform
              Could not open device 10c4:ea60

              I used https://www.silabs.com/documents/public/software/CP210x_Windows_Drivers.zip for download, and “CP210xVCPInstaller_x64.exe” for installation.

              (Using https://www.silabs.com/documents/public/software/CP210x_Universal_Windows_Driver.zip fails as well.)

                On Ubuntu I’ve added a udev ruleset for the device as well: (looks like the same as yours)

                SUBSYSTEM=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60" GROUP="users", MODE="0666"

                I named the file 50-nrf9160-feather.rules and put it in /etc/udev/rules.d

                Windows unfortunately doesn’t work with the auto bootloader feature due to how the raw commands are sent to the device. So you’ll need to enable manually still when you use Windows.

                a year later

                I’m struggling to apply this to Ubuntu 22.04.
                Has someone done this with success?

                  After using “sudo <path>/zephyr-tools -b” once, it works now without sudo. Not sure, if this is related or something else was mixed up. But now it works with Ubuntu 22.04, great.

                    @AchimKraus you probably need to add udev rules and/or add your user to the dialout group. Using it here daily without issue on Linux.

                    Also make sure to restart when you do add those rules if you’re just doing it now

                    I did both. Adding the rule, add the user to the dailout group (serial terminal was OK), I tried to sudo udevadm control --reloadand I restarted the PC. But all in vain. Then I tried to check, if there is a different root cause as the permission using “sudo”. That worked. And magically, afterwards it worked also without sudo. Anyway, I’m not that sure, what exactly happens. Maybe I check it, when I setup the next new system.

                    Alternatively of using the zephyr-tools I use following python script to switch bootmode on and off.
                    To set the target in bootmode use ‘./scriptname -b’ , to set it in run mode use ‘scriptname’ (without argument).

                    #! /usr/bin/python3
                    
                    import usb.core	# needs PyUsb which could be installed on Debian/Ubuntu by 'sudo apt install python3-usb'
                    import usb.util
                    import sys
                    import time
                    
                    PID = 0xea60
                    VID = 0x10c4
                    
                    dev = usb.core.find(idVendor=VID, idProduct=PID)
                    if not dev:
                            print("Error: CP2104 not found!")
                            exit(1)
                    
                    reqType = 0x41
                    bReq = 0xFF
                    wVal = 0x37E1
                    
                    RESET = 0x02ff	# /Reset (GPIO.0) is bit 8 active low
                    MD = 0x01ff	# /MD (GPIO.1) is bit 9 active low
                    NONE = 0x03ff	# bit 8 & 9 inactive (hi)
                    
                    def clrl_transfer(wIndex, duration):
                            dev.ctrl_transfer(reqType, bReq, wVal, wIndex, [])
                            time.sleep(duration)
                    
                    if len(sys.argv) == 1 or sys.argv[1]=='-r':
                        print('Set in run mode.')
                        clrl_transfer(RESET, 0.1)
                        clrl_transfer(NONE, 0.1)
                    elif sys.argv[1] == '-b':
                        print('Set in bootmode.')
                        clrl_transfer(RESET & MD, 0.1)
                        clrl_transfer(MD, 1.0)
                        clrl_transfer(NONE, 0.1)
                    else:
                        print(f'Usage: {sys.argv[0]} [-b|-r]   (where -b is bootmode; -r or no argument is run mode)')
                    Terms and Conditions | Privacy Policy