Open evaherrada opened 2 years ago
After running the code I tried running it again and get the following output:
code.py output:
Traceback (most recent call last):
File "code.py", line 35, in <module>
File "adafruit_atecc/adafruit_atecc.py", line 169, in __init__
File "adafruit_atecc/adafruit_atecc.py", line 241, in version
File "adafruit_atecc/adafruit_atecc.py", line 195, in idle
OSError: [Errno 19] No such device
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
@evaherrada After attempting to run the CSR example if you set lock=True the chip becomes permanently locked with the settings in the configuration portion of the script. This should come with an extreme warning as it's permanent.
Immediately after locking the chip it will only respond to a wakeup ping. Then and ONLY then will the I2C address reappear and connect for communication (takes milliseconds). If you do not send it a wakeup ping the I2C device will appear as if it's completely gone with the No such device
. Normally that error is associated with attempting to communicate with an unplugged I2C device or one you've specified the incorrect I2C address for.
Part of the security of this chip is that it can be programmed with any I2C address of your choosing. 0x60 is just the default address. You must know the exact I2C address to send the wakeup ping to... it will not show itself in a conventional I2C scan. So the No such device
is actually part of its security. You would have to send a wakeup ping to every possible I2C address to find it (if you didn't know the exact address).
Once locked the ATECC I2C address doesn't exist unless first pinged with a wakeup command, then the I2C address will magically appear and you can communicate with the module. This is completely outside the normal operation we're accustomed to in Circuit Python with I2C devices.
I have yet to figure out more but I hope that sheds some light on what I've learned about this chips behavior. So far I haven't been able to get it to produce a certificate once. Most of the issues I believe are simply timing related. This chip is extremely temperamental about precise timing for reading & writing commands.
The way the chip behaves prior to locking the configuration is different than after you lock it. Prior to locking it will respond like any normal I2C device. The 0x60 address is always available and ready to play nicely. Afterwards it turns into something different.
Traceback (most recent call last):
File "code.py", line 52, in <module>
File "/lib/adafruit_atecc/adafruit_atecc.py", line 192, in __init__
File "/lib/adafruit_atecc/adafruit_atecc.py", line 264, in version
File "/lib/adafruit_atecc/adafruit_atecc.py", line 218, in idle
OSError: [Errno 19] No such device
Triple quote comment out this section of code on line 192 of adafruit_atecc.py
"""
if (self.version() >> 8) not in (_ATECC_508_VER, _ATECC_608_VER):
raise RuntimeError(
"Failed to find 608 or 508 chip. Please check your wiring."
)
"""
It will now pass outside of the library and run code.py!
i2c = busio.I2C(board.SCL, board.SDA, frequency=70000)
atecc = ATECC(i2c_bus=i2c, debug=False)
print("WE MADE IT OUT OF THE LIBRARY LOOP!")
# Initialize the SHA256 calculation engine
atecc.sha_start()
However it immediately runs into the next error which is sha_start related.
code.py output:
WE MADE IT OUT OF THE LIBRARY LOOP!
Traceback (most recent call last):
File "code.py", line 55, in <module>
File "/lib/adafruit_atecc/adafruit_atecc.py", line 417, in sha_start
File "/lib/adafruit_atecc/adafruit_atecc.py", line 604, in _send_command
OSError: [Errno 19] No such device
Code done running.
This is progress. I can at least verify that the wake ping is working, the device wakes up, I2C address works, and the module responds.
Tested on a Feather RP2040