Hello everyone,
I am having trouble using the bt_nus_shell.py script and a NRF52840 development board to send shell commands. I am trying to follow the instructions mentioned here. I reverted to an older version of Python (3.7) because the BLE driver (pc-ble-driver-py) will not work with a new Python version. Right now I have installed pc-ble-driver-py v0.17.0, as well as all the dependencies of the bt_nus_shell.py script by typing:
pip install --user -r scripts/shell/requirements.txt
The issues start after I connect the NRF52840 development board to my PC. I connect it and then type the following command to run the script:
python bt_nus_shell.py --name BT_NUS_shell --com COM237 --family NRF52 --snr 1050278085
I get the following message:
PS C:\ncs\v2.3.0\nrf\scripts\shell> python bt_nus_shell.py --name BT_NUS_shell --com COM237 --family NRF52 --snr 1050278085 Flashing connectivity firmware... Connectivity firmware flashed. Socket created Socket bind complete Socket now listening
Then I open Putty, set the Connection Type to Raw and the Destination Address to 127.0.0.1:8889. Then I get the following error:
Starting BLESerial failed. Error: Failed to open. Error code: NRF_ERROR_SD_RPC_H5_TRANSPORT_STATE SOCKET CLOSED
This is my problem and I do not know how to get past this error.
While looking online for a possible solution, I found a forum topic that suggested to disable the mass storage class on J-Link. So, I opened the J-Link commander app and connected to the nRF52840 development board (Device: NRF52, Interface: SWD, Speed: 4000). I typed "MSDDisable" and the J-Link app responded that the command was accepted. However, when I power-cycled the development board, and tried to run the python script again, I got this error:
PS C:\ncs\v2.3.0\nrf\scripts\shell> python bt_nus_shell.py --name BT_NUS_shell --com COM237 --family NRF52 --snr 1050278085 Traceback (most recent call last): File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\pc_ble_driver_py\ble_driver.py", line 3207, in call_cmd return subprocess.check_output(argstr, stderr=subprocess.STDOUT, shell=True) File "C:\Users\Administrator\.pyenv\pyenv-win\versions\3.7.9\lib\subprocess.py", line 411, in check_output **kwargs).stdout File "C:\Users\Administrator\.pyenv\pyenv-win\versions\3.7.9\lib\subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command 'nrfjprog --snr 1050278085 --memrd 327680 --w 8 --n 24 --family nrf52' returned non-zero exit status 16. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "bt_nus_shell.py", line 222, in <module> flash_connectivity(args.com[0], args.snr[0]) File "bt_nus_shell.py", line 173, in flash_connectivity if flasher.fw_check(): File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\pc_ble_driver_py\ble_driver.py", line 3160, in fw_check fw_struct = Flasher.parse_fw_struct(self.read_fw_struct()) File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\pc_ble_driver_py\ble_driver.py", line 3183, in read_fw_struct data = self.call_cmd(args) File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\wrapt\decorators.py", line 470, in _synchronized return wrapped(*args, **kwargs) File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\pc_ble_driver_py\ble_driver.py", line 3212, in call_cmd raise RuntimeError(f"{e.__str__()}\n{e.output}") RuntimeError: Command 'nrfjprog --snr 1050278085 --memrd 327680 --w 8 --n 24 --family nrf52' returned non-zero exit status 16. b"[error] [ Client] - Encountered error -90: Command read_device_info executed for 15 milliseconds with result -90\r\n[error] [ Worker] - Access protection is enabled, can't read device version.\r\n[error] [ Client] - Encountered error -90: Command read_memory_descriptors executed for 15 milliseconds with result -90\r\n[error] [ Worker] - Can't read memory descriptors, ap-protection is enabled.\r\n[error] [ Client] - Encountered error -90: Command read executed for 370 milliseconds with result -90\r\n[error] [ Worker] - Access protection is enabled, can't access memory.\r\nERROR: The operation attempted is unavailable due to readback protection in\r\nERROR: your device. Please use --recover to unlock the device.\r\nNOTE: For additional output, try running again with logging enabled (--log).\r\nNOTE: Any generated log error messages will be displayed.\r\n"
As suggested by the error message, I ran:
nrfjprog --snr 1050278085 --memrd 327680 --w 8 --n 24 --family nrf52
Which suggests to run:
nrfjprog --snr 1050278085 --recover
The latter command re-establishes communication with the development board but negates the effects of "MSDDisable". So, I'm back where I started.
Any ideas? I am a beginner in development so any help will be appreciated.