Closed
Description
I used the following Adafruit sample code in order to initialize the ATECC608A chip connected to a Pi0 via I2C using GPIO 3 and 5.
import board
import busio
from adafruit_atecc.adafruit_atecc import ATECC, _WAKE_CLK_FREQ, CFG_TLS
import adafruit_atecc.adafruit_atecc_cert_util as cert_utils
# -- Enter your configuration below -- #
# Lock the ATECC module when the code is run?
LOCK_ATECC = True
# 2-letter country code
MY_COUNTRY = "DE"
# State or Province Name
MY_STATE = "Bavaria"
# City Name
MY_CITY = "Munich"
# Organization Name
MY_ORG = "Rottmann.IT"
# Organizational Unit Name
MY_SECTION = "Crypto"
# Which ATECC slot (0-4) to use
ATECC_SLOT = 0
# Generate new private key, or use existing key
GENERATE_PRIVATE_KEY = True
# -- END Configuration, code below -- #
# Initialize the i2c bus
i2c = busio.I2C(board.SCL, board.SDA, frequency=_WAKE_CLK_FREQ)
# Initialize a new atecc object
atecc = ATECC(i2c)
print("ATECC Serial Number: ", atecc.serial_number)
if not atecc.locked:
if not LOCK_ATECC:
raise RuntimeError(
"The ATECC is not locked, set LOCK_ATECC to True in code.py."
)
print("Writing default configuration to the device...")
atecc.write_config(CFG_TLS)
print("Wrote configuration, locking ATECC module...")
# Lock ATECC config, data, and otp zones
atecc.lock_all_zones()
print("ATECC locked!")
print("Generating Certificate Signing Request...")
# Initialize a certificate signing request with provided info
csr = cert_utils.CSR(
atecc,
ATECC_SLOT,
GENERATE_PRIVATE_KEY,
MY_COUNTRY,
MY_STATE,
MY_CITY,
MY_ORG,
MY_SECTION,
)
# Generate CSR
my_csr = csr.generate_csr()
print("-----BEGIN CERTIFICATE REQUEST-----\n")
print(my_csr.decode("utf-8"))
print("-----END CERTIFICATE REQUEST-----")
Basic tests like accessing the serial, the random number generator or the counter were successful.
However generating the CSR failed:
ATECC Serial Number: 01235AC6DE96E396EE
Writing default configuration to the device...
Wrote configuration, locking ATECC module...
ATECC locked!
Generating Certificate Signing Request...
Traceback (most recent call last):
File "code.py", line 61, in <module>
my_csr = csr.generate_csr()
File "/home/pi/atecc608a/venv/lib/python3.7/site-packages/adafruit_atecc/adafruit_atecc_cert_util.py", line 91, in generate_csr
self._csr_begin()
File "/home/pi/atecc608a/venv/lib/python3.7/site-packages/adafruit_atecc/adafruit_atecc_cert_util.py", line 101, in _csr_begin
self._atecc.gen_key(self._key, self._slot, self.private_key)
File "/home/pi/atecc608a/venv/lib/python3.7/site-packages/adafruit_atecc/adafruit_atecc.py", line 424, in gen_key
self._get_response(key)
File "/home/pi/atecc608a/venv/lib/python3.7/site-packages/adafruit_atecc/adafruit_atecc.py", line 542, in _get_response
raise RuntimeError("CRC Mismatch")
RuntimeError: CRC Mismatch
Since then I have no connection to the module anymore. i2cdetect recognizes an i2c device on 0x10 but every other call the device disappears again. Before the device was recognized as 0x60. There are no other I2C devices connected.
(venv) pi@raspberrypi:~/atecc608a $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
(venv) pi@raspberrypi:~/atecc608a $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Does anyone have an idea what happened here? Is there any chance to revive the ATECC608A?