Skip to content

sample atecc_csr.py fails #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
CrabbyPete opened this issue Jun 24, 2021 · 5 comments
Open

sample atecc_csr.py fails #23

CrabbyPete opened this issue Jun 24, 2021 · 5 comments

Comments

@CrabbyPete
Copy link

Traceback (most recent call last):
File "atecc_csr.py", line 52, in
my_csr = csr.generate_csr()
File "/home/pi/atecc608/lib/python3.7/site-packages/adafruit_atecc/adafruit_atecc_cert_util.py", line 77, in generate_csr
csr = self._csr_end()
File "/home/pi/atecc608/lib/python3.7/site-packages/adafruit_atecc/adafruit_atecc_cert_util.py", line 127, in _csr_end
self._common,
File "/home/pi/atecc608/lib/python3.7/site-packages/adafruit_atecc/adafruit_atecc_asn1.py", line 97, in get_issuer_or_subject
get_name(country, 0x06, data)
File "/home/pi/atecc608/lib/python3.7/site-packages/adafruit_atecc/adafruit_atecc_asn1.py", line 125, in get_name
data.extend(name)
TypeError: 'str' object cannot be interpreted as an integer

@fabaff
Copy link

fabaff commented Jan 31, 2022

Works for me with CircuitPython 7.1.1.

Edit: On an ESP32-S2 not Pi though.

@dexterac
Copy link

dexterac commented Feb 7, 2022

python create_csr.py
ATECC Serial Number: 0123FB0CBC66584DEE
Writing default configuration to the device...
Wrote configuration, locking ATECC module...
ATECC locked!
Generating Certificate Signing Request...
Traceback (most recent call last):
File "/atecc608a/atecc608a/create_slot0_csr.py", line 64, in
my_csr = csr.generate_csr()
File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_atecc/adafruit_atecc_cert_util.py", line 76, in generate_csr
self._csr_begin()
File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_atecc/adafruit_atecc_cert_util.py", line 86, in _csr_begin
self._atecc.gen_key(self._key, self._slot, self.private_key)
File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_atecc/adafruit_atecc.py", line 438, in gen_key
self._get_response(key)
File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_atecc/adafruit_atecc.py", line 556, in _get_response
raise RuntimeError("CRC Mismatch")
RuntimeError: CRC Mismatch

lost 2 modules. Any help appreciated.

I am running this on RaspberryPi4 with 64bit Raspibian and the board is no longer visible with i2cdetect.

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: -- -- -- -- -- -- -- --

@dexterac
Copy link

dexterac commented Feb 7, 2022

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: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --    

occasionally shows up but it now errors with 👍
OSError: [Errno 121] Remote I/O error

@ladyada
Copy link
Member

ladyada commented Feb 7, 2022

the atecc has very weird wakeup requirements, it is not really compatible with linux because we cannot dynamically change the i2c speed. you can try setting the pi i2c speed to 50khz or 10khz, see if that helps

@dexterac
Copy link

dexterac commented Feb 8, 2022

the atecc has very weird wakeup requirements, it is not really compatible with linux because we cannot dynamically change the i2c speed. you can try setting the pi i2c speed to 50khz or 10khz, see if that helps

Thanks. When I set the dtparam=i2c_arm_baudrate=50000 or 10000 in /boot/config.txt the board is detected but simpletest python script fails.

python simpletest.py 
Traceback (most recent call last):
  File "/home/pi/simpletest.py", line 12, in <module>
    atecc = ATECC(i2c, address=0x60, debug=True)
  File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_atecc/adafruit_atecc.py", line 169, in __init__
    if (self.version() >> 8) not in (_ATECC_508_VER, _ATECC_608_VER):
  File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_atecc/adafruit_atecc.py", line 241, in version
    self.idle()
  File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_atecc/adafruit_atecc.py", line 195, in idle
    i2c.write(self._i2cbuf, end=1)
  File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 84, in write
    self.i2c.writeto(self.device_address, buf, start=start, end=end)
  File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/busio.py", line 165, in writeto
    return self._i2c.writeto(address, memoryview(buffer)[start:end], stop=stop)
  File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 49, in writeto
    self._i2c_bus.write_bytes(address, buffer[start:end])
  File "/atecc608a/.atecc608aenv/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
    self._device.write(buf)
OSError: [Errno 121] Remote I/O error


$ 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: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

$ i2cget 1 0x60 00
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will read from device file /dev/i2c-1, chip address 0x60, data address
0x00, using read byte data.
Continue? [Y/n] y
Error: Read failed

$ i2cdump 1 0x60
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1, address 0x60, mode byte
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
10: XX XX XX XX XX XX XX XX XX 11 33 43 04 11 33 43    XXXXXXXXX?3C??3C
20: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
30: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
40: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
50: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
60: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
70: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
80: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
90: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
a0: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
b0: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
c0: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
d0: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
e0: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C
f0: 04 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43    ??3C??3C??3C??3C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants