Skip to content

Reimplement wakeup() #18

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

Merged
merged 3 commits into from
Jan 15, 2021
Merged

Conversation

caternuson
Copy link
Contributor

This is a potential solution for: adafruit/Adafruit_Blinka#262

With the current implementation, the MCP2221 apparently does not output something that works, so the subsequent I2C comms fail. See logic traces in issue thread above. This reimplementation takes a different approach for generating the ATECC wakeup signal. Instead of using a scan it tries to address something at 0x00 and relies on 8 clock cycles of a 100kHz bus. So this hack will not work for I2C clock frequencies higher than 100kHz.

NOTE: the other big change is that wakeup() no longer returns a boolean. But that appears to have only been needed by the previous implementation. It's not used anywhere else in the driver.

It now works with MCP2221:

(blinka) user@linux:~$ export BLINKA_MCP2221=1
(blinka) user@linux:~$ python3 atecc_simpletest.py 
ATECC Serial:  0123A3B16C97546FEE
Random Value:  1016
ATECC Counter #1 Value:  bytearray(b'\x01\x00\x00\x00')
Appending to the digest...
Appending to the digest...
SHA Digest:  bytearray(b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7\xfd\xdf\xf7\xbcN\x84:\xa6\xaf\x0c\x95\x0fK\x94\x06')

and still works with native CP:

Adafruit CircuitPython 6.0.1 on 2020-12-28; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import atecc_simpletest
ATECC Serial:  0123A3B16C97546FEE
Random Value:  1016
ATECC Counter #1 Value:  bytearray(b'\x03\x00\x00\x00')
Appending to the digest...
Appending to the digest...
SHA Digest:  bytearray(b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7\xfd\xdf\xf7\xbcN\x84:\xa6\xaf\x0c\x95\x0fK\x94\x06')
>>> 

@caternuson caternuson requested a review from brentru January 15, 2021 18:27
@brentru
Copy link
Member

brentru commented Jan 15, 2021

@caternuson before you merge - CI is still failing.

@caternuson
Copy link
Contributor Author

Thanks. Yah, looks like new stuff I'm not familiar with yet. So trying to trace in and figure it all out.

@caternuson
Copy link
Contributor Author

Adding a trace of what the new wakeup() function ends up looking like on the MCP2221:
Screenshot from 2021-01-15 11-31-01
Note that the contents, also 0x00 but could be anything, never actually get written out since it NACKS on the write start. But it's the ~100us SDA low time that the ATECC sees and wakes up. It's the use of 0x00 for the address that's important. At least that's my theory :)

@caternuson
Copy link
Contributor Author

Looks like #17 will fix most of these. Still not sure why I'm failing black, since it's passing locally.

@caternuson caternuson merged commit 8436e76 into adafruit:master Jan 15, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jan 16, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_ATECC to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_ATECC#18 from caternuson/blinka_iss262
  > Merge pull request adafruit/Adafruit_CircuitPython_ATECC#17 from adafruit/REUSE
  > Added pre-commit-config file
  > Added pre-commit and SPDX copyright
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

Successfully merging this pull request may close these issues.

2 participants