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

Resetting device via python bindings

I am developing a tool that will be using the existing NRF51 dongle to run the S130 SD and it is being written in Python. There is no way to change any of these parameters since dev has been going for years on the tool chain via a different chip supplier for BLE. Even if I close the device I cannot reconnect to it since it's already running in a state that I cannot guess since I have multiple tools. If I just power through things I run afoul of already registered base UUIDs and other things that take resources.

Is there any way from python to clear out the state of the SD back to the one from a fresh boot. I saw a thread there a SD call can be made to reset the entire device (which would be fine with me) however in 0.5.0 python swig bindings I do not see it in there. Unless there is some way to get the JLINK serial number from the python bindings I cannot simply call the nrfjprog --reset command since I have multiple jlink pods/dongles on the system and I need to target the one that I have currently selected (which is done via the COMX port number)

-Jim

Parents
  • Hi Jim,

    Thanks for the clarification. Sorry that I wasn't sure you were using the BLE driver or the Master Emulator. But you were right, you mentioned v0.5.0 and python.

    On the BLE connectivity set-up we use an extra GPIO pin to do physical pin reset on the connectivity chip. We are actually working to implement the sd_nvic_SystemReset() in the future release of the serialization firmware.

    What you can do for now if you don't plan to wait for the release that has the soft reset API provided is either:

    • Implement your own soft reset API on both the connectivity firmware on the nRF51 and the python bindings.

    • Use nrfjprog --reset with the Jlink serial number match with the COM port that you are connected to. You can find the corresponding Jlink serial number for the COM port using Windows Registry. The solution is described here. The registry section you should look into is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB. You would need to use the ParentIdPrefix to match them.

Reply
  • Hi Jim,

    Thanks for the clarification. Sorry that I wasn't sure you were using the BLE driver or the Master Emulator. But you were right, you mentioned v0.5.0 and python.

    On the BLE connectivity set-up we use an extra GPIO pin to do physical pin reset on the connectivity chip. We are actually working to implement the sd_nvic_SystemReset() in the future release of the serialization firmware.

    What you can do for now if you don't plan to wait for the release that has the soft reset API provided is either:

    • Implement your own soft reset API on both the connectivity firmware on the nRF51 and the python bindings.

    • Use nrfjprog --reset with the Jlink serial number match with the COM port that you are connected to. You can find the corresponding Jlink serial number for the COM port using Windows Registry. The solution is described here. The registry section you should look into is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB. You would need to use the ParentIdPrefix to match them.

Children
  • Thanks for the response. I'll probably use nrfjprog as long as I can link the com port to the serial number via the registry. That was the part that was missing for me. I'll look forward to seeing the updated python bindings with the API exposed to do the reset as that would be the cleanest way for me to use. I have other questions that I will be posting about the com ports. Windows often renumerates USB serial devices and moves port numbers around while keeping power on the device. My old system would chase the port around and reconfigure the port to allow the retry manager to start working again. With moving over to the S130/Python stack the com port management is different and I want to know what Nordic is recommending as the correct way to keep chasing windows. Can I just setup the serial connection again while leaving the stack alone and will it keep working?

  • Hi Jim,

    I haven't seen the Segger COM port being changed when being in-use. Sometimes, I saw it changed when I unplug and plug it into another USB port. But there maybe different behaviour on other machine.

    From my point of view there are some situations when Windows remunerates the USB-COM port that can cause the issue:

    • When BLE is active and waiting for a reply call from the application. Then a time-out can happens.

    • When the stack throw events, but the application fail to get the event out (because of the COMport switching), most likely again end up with a procedure timeout on the connection.

    I can't think of anything other than these.

  • when this happens my app callback for log messages gets hammered with serial error messages. Windows can and will yank port assignments around. Normally there are reservations so that the same device will always get the same number. The problem occurs if the port is yanked and the app still is connected. In come cases the port is listed in the registry still and windows sees that the reservation cannot be honored and it advances the port number by one. The other case is that the port goes down do to a hub reunumeration (ESD, etc) and the reervation is honored, however the app now has a stale handle to the port that gets errors. I have a port chaser app that keeps tabs on things and restarts various parts of my system with the new or old com port number as needed. When this happens what is going on with the S130 stack running on the dongle? Can I just re-register without restart

  • From the nRF51 point of view, what happens on the other side, the COM port on Windows should be out of sight.

    What the nRF51 can probably see is that the UART peer (the Segger chip) stop responding or HWFC line stopping it from transmit more data. The stack will keep normal operation, and time out may occurs as I mentioned above.

    However potential issue could be some events go missing, if the HWFC is not controlled properly. So the nRF51 keeps transmitting on the UART line when there is no control over it.

    I think it's better to have a fresh start for the S130. That's safer.

Related