On the command line I am able to nc <devid>.agent.particle.io 5683 and it does connect and spew some encrypted data as I would expect (likely asking for a handshake). I think this whole issue has something to do with the build toolchain or âsystem firmwareâ for Pi; the firmware itself doesnât seem to be resolving DNS. My guess (not knowing too much about the cloud claiming system) is that the device needs to be reachable by the cloud before it can be claimed⌠and if the firmware isnât connecting, then it canât contact the âdeviceâ (firmware) and thus cannot âclaimâ it⌠correct me if Iâm wrong.
Okay, just a flip from the way I interpreted it. Because the device cannot contact the cloud, the cloud has no record of it being a valid device⌠so it cannot be claimed. Does that make sense?
Iâm digging through the source of the firmware (raspberry-pi-0.6.0 branch) and comparing with the Photon code see that it uses a different mechanism to resolve hostnames.
Is there a way to compile tinker for Raspberry Pi with the firmware-level debug/trace statements enabled? I think this could offer a more telling story. I donât have a full local toolchain set up for this.
0000000005 system: INFO: Cloud: connecting
terminate called after throwing an instance of 'boost::exception_detail::clone_impl >'
what(): resolve: Host not found (non-authoritative), try again later
Firmware exited with status pid 682 SIGABRT (signal 6)
Mine does not include ANY of the lines between âCloud: connectingâ and âCloud socket connectedâ. No successful DNS lookup, no âconnected to cloudâ⌠nothing. Itâs strange because I have been reviewing the code and the process should throw some sort of error before it even hits âCloud socket connectedâ if it canât resolve the host.
I did some digging; In firmware/hal/src/photon/inet_hal.cpp, inet_gethostbyname(), thereâs a code path that essentially allows inet_gethostbyname to fail but still set the IP address to 0.0.0.0. The only way this would be caught is if the caller checks the return value, which it does:
Thereâs no code path past this step without generating at least one of those two log lines. How in the world is it skipping this on my Pi?
I think Iâm getting closer⌠I found a way for those lines to be skipped.
When the cloud connection is initialized in system_cloud_internal.cpp, it âinitializesâ the server address with whatever it can pull from deviceConfig.server_key.
As we can see in my previous logs, the server_key is being interpreted as entirely zeros. This results in a âserver addressâ of 0 (0.0.0.0), this will then be interpreted as a valid IP address in parseServerAddressData():
where IP_ADDRESS has been defined as 0 in ota_flash_hal.h, so if the first byte of the server_key at the specified offset is 0, it is interpreted as an IP address - containing entirely 0s.
This is then checked by determine_server_address and because only the port is validated it passes this check.
At this point the system believes it has a totally valid IP address and attempts connecting to it, without bothering to check the DNS records.
All of this would not happen if one thing were different: the server key. Why is the server_key being read as all-zeros?
I fixed it. Somehow, through all of the installs and reinstalls of the Particle agent, it never once copied a valid server_key.der to /var/lib/particle/devices/<device_id>/server_key.der - it was a completely empty file. Once I copied it from /usr/share/particle/keys/server_key.der to that location and restarted the particle agent service, it connected instantly!
I was then able to re-run particle-agent setup and claim my device.
I have known Raspberry Pis to take quite a while (seconds) to properly sync their filesystems to SD card once filesystem changes are made. Keep this in mind â RPi 1âs are especially vulnerable to this.
Install fresh Raspbian to SD card.
Boot on an old RPi 1 B
Install particle-agent. This provisions a device_id and copies files into the proper directory in /var/lib/particle/devices.
When the USB bus fails (as detailed in my other thread), unplug power within seconds. At this point, an inode has been created for /var/lib/particle/devices/<devid>/server_key.der, but no data was actually synced to the SD card!
Now, move that SD card into a RPi 2 B which is not vulnerable to the USB bus weirdness, and boot.
The Particle firmware silently accepts the zero-length server_key, and extrapolates a 0.0.0.0 IP address from it, causing the behaviour detailed in this thread.
Hi there,
I am pretty newbie can you please help me.
I have a raspberry pi 4b with raspbian GNU/Linux 10 (buster) installed (Linux 5.10.103-v7l+
).
I also use this device as a unifi server controller and the pirelay appltication. So installing a fresh raspbian is no option.
I tried installing the particlepi and also get the problem âError claiming the device. Could not claim the device to your accountâ.
I tried updating & upgrade the raspbian and all applications.
What am i doing wrong or am i missing something?
If you need more information please let me know.