nRFCloud / utils

Utility code/scripts for working with nRF Cloud
Other
5 stars 14 forks source link

claim_and_provision_device.py: Serial Timeout, %ATTESTTOKEN not detected in line b' #42

Closed 6less closed 6 days ago

6less commented 1 week ago

I've been following the guide for this repository to get my Thingy91 reprovisioned to generate JWT signed with a device key. All steps were successful up until I ran the claim_and_provision_device.py where I encountered the following issue:

`C:\Users\x\Nordic\cell-fund\utils-master\python\modem-firmware-1.3+>python ./claim_and_provision_device.py --api_key redacted --ca ./redacted_ca.pem --ca_key ./redacted_prv.pem

Loading CA and key... Opening serial port... Available ports: 1: COM8 Thingy:91 Selected serial port: COM8

Disabling modem... -> at AT+CFUN=4

Serial timeout -> at AT%ATTESTTOKEN String b'%ATTESTTOKEN: ' not detected in line b'ERROR\r\r\n' ATTESTTOKEN command failed`

The Thingy91 firmware is mfw_nrf9160_1.3.5, nRF SDK v2.6.1, python 3.12.6. The Thingy91 is programed with the Device Provisioning Sample code and built with prj.conf settings specified in this repo. API keys were hand-typed and copy pasted, paths to certs were autocompleted, and I tried cert arguments with and without the equal sign as shown in the example code. None resolved the issue.

plskeggs commented 1 week ago

Hi @6less. The serial timeouts indicate trouble communicating with the Thingy:91 on COM8.

Please verify if you connect to COM8 using a serial terminal program, such as the nRF Connect for Desktop Serial Terminal, that you can interact with the device provisioning sample's shell commands. (NOTE: you need to disconnect any serial terminal program when running this script).

In Serial Terminal, it is helpful to select Shell mode under Terminal Mode, located on the left side of the window.

You should be able to hit and get a uart:~$ prompt. will show a list of shell commands, like this:

uart:~$ 
  at                clear             date              device
  devmem            help              history           kernel
  lte               nrf_provisioning  rem               resize
  retval            shell

If you cannot issue commands, you should try a different USB port on your computer.

If that does not help, then you may need to update the firmware on the nRF52840 on the Thingy:91 with the latest Connectivity Bridge: https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/device_guides/nrf91/thingy91_updating_fw_programmer.html#updating_the_firmware_in_the_nrf52840_soc

EDIT: A colleague pointed out the most obvious problem, however. The nRF Cloud device provisioning service does not support the nRF9160, but only the nRF9151 and nRF9161. See: https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/cellular/nrf_provisioning/README.html#requirements.

But, the device_credentials_installer.py script does support all nRF91 families running modem firmware >= 1.3.0, and will use a securely generated device private key which is locked inside the modem and is not vulnerable to extraction. The JWT will then be signed by the private key.