sparkfun / SparkFun_ATECCX08a_Arduino_Library

An Arduino library to use with the Microchip ATECCX08a Cryptographic Co-processors.
https://www.sparkfun.com
Other
36 stars 18 forks source link

Problem with Example1_Configuration using a Heltec CubeCell #6

Closed bshambaugh closed 4 years ago

bshambaugh commented 4 years ago

This is confusing for me to explain, so I will paste a transcript of a conversation I recently had with someone. Maybe there is some idea over here?


bshambaugh 2:20 PM Does anyone know much about IIC or I2C connections? I am trying to get a Heltec CubeCell to work with a SparkFun Cryptographic Co-Processor (ATECC508A breakout). It seems like each new device needs to be configured for the Cubecell. The ESP32 seemed more plug and play. The Wire.h library and a few other things are different for the ESP32 and the Heltec CubeCell.

bshambaugh 2:27 PM supposedly it works differently since it is a different chip (checking the forum) (edited)

{removed:someotherguy} Today at 2:31 PM The question above a little bit vague. There are usually masters and slaves in I2C

34 replies bshambaugh 1 hour ago I think the CubeCell is a master by default.

{removed:someotherguy} 1 hour ago so theoretically logic from https://github.com/sparkfun/SparkFun_ATECCX08a_Arduino_Library will apply to CubeCell sparkfun/SparkFun_ATECCX08a_Arduino_Library An Arduino library to use with the Microchip ATECCX08a Cryptographic Co-processors. Website https://github.com/sparkfun/SparkFun_ATECCX08a_Arduino_Library|sparkfun/SparkFun_ATECCX08a_Arduino_Library

bshambaugh 1 hour ago Messages from the program like, "Failure to generate This device's Public Key" were not especially helpful for debugging. However I did find that the inputBuffer was different depending on whether the public key was generated or not.

bshambaugh 1 hour ago when it succeeded: "inputBuffer: 43,F9,C3,6F,89,64,62,33,78,BD,C0,68,D4,BC,E0,7E,D1,7C,8F,A4,86,F9,AC,C,26,13,CA,3C,8C,30,6D,7B,B6,1C,D3,67,17,B8,AC,5E,4F,EA,8A,D2,3D,C8,D0,78,3C,23,18,EE,4A,D7,A8,D,B6,E0,2,6A,D0,B0,72,A2,4F,D8,64,"

bshambaugh 1 hour ago when it failed: "inputBuffer: 43,F9,C3,6F,89,64,62,33,78,BD,C0,68,D4,BC,E0,7E,D1,7C,8F,A4,86,F9,AC,C,26,13,CA,3C,8C,30,6D,7B,1C,D3,67,17,B8,AC,5E,4F,EA,8A,D2,3D,C8,D0,78,3C,23,18,EE,4A,D7,A8,D,B6,E0,2,6A,D0,B0,72,A2,4F,64,FF,FF,"

bshambaugh 1 hour ago image.png image.png (image in the gist: https://gist.github.com/bshambaugh/07fc95c7b129a2614c6bbc2288f124b5)

bshambaugh 1 hour ago it is hard to see without clicking on it, but the above image shows the difference between the two. {removed:someotherguy} 1 hour ago so extra byte(s) there

bshambaugh 1 hour ago Yes, I am running, https://github.com/sparkfun/SparkFun_ATECCX08a_Arduino_Library/tree/master/examples/Example1_Configuration

bshambaugh 1 hour ago FF, FF is bad

bshambaugh 1 hour ago message CRC error. https://gist.github.com/bshambaugh/07fc95c7b129a2614c6bbc2288f124b5 (added comment: this gist describes the error. I'm also asking at: http://community.heltec.cn/t/debugging-faulty-cubecell-i2c-connection-to-cryptographic-authentication-chip-atecc508a/2300)

{removed:someotherguy} 1 hour ago yes, weird.. how long is wires?

bshambaugh 1 hour ago for the Ardunio MCU they have several sensor examples written. https://github.com/HelTecAutomation/ASR650x-Arduino/tree/master/libraries/SensorBasic/examples bshambaugh 1 hour ago pretty short

bshambaugh 1 hour ago no longer than 6 inches

bshambaugh 1 hour ago I am getting some data

bshambaugh 1 hour ago but it messes up when I send a public key (64 bytes) and a random number (32 bytes)

bshambaugh 1 hour ago Single bytes come through, serial numbers come through. (from the cryptographic co processor) (edited) {removed:someotherguy} 1 hour ago is it intermittent or consistent failures?

bshambaugh 1 hour ago consistent {removed:someotherguy} 1 hour ago so the dumps above from esp32 and CubeCell

bshambaugh 1 hour ago yes, I show the dumping of the public key from the esp32, and the error with FF,FF from the CubeCell {removed:someotherguy} 1 hour ago is inputBuffer the same each time, no variation? (edited)

bshambaugh 1 hour ago yes,

bshambaugh 1 hour ago I went flopping around thinking of the cryptochip as a sensor that somehow needs to be included. https://github.com/CryptoThings/AtCryptoAuthLib (maybe helpful) .. suggest I might go beyond 128, maybe 160? ... need to find out the units of this, https://github.com/HelTecAutomation/ASR650x-Arduino/tree/master/libraries/Sensor_ThirdParty/src (Cubecell vendor library)the https://github.com/sparkfun/SparkFun_ATECCX08a_Arduino_Library just runs on the esp32 (edited)

bshambaugh 43 minutes ago hrm...from the sparkfun github issues for an Ardunio zero, "If configuration is working, then I'm assuming that most I2C communications are working properly. Do you happen to know what the I2C buffer length is when using that board? It needs to be at least 128 bytes, and so the standard Wire library for most Arduinos is 32 Bytes, and this needs to be modified in the wire.h header file." (edited) {removed:someotherguy} 40 minutes ago noticed that too, that it drops a byte after 32 bytes

bshambaugh 40 minutes ago yes {removed:someotherguy} 37 minutes ago Sometimes it is possible to read i2c registers in chunks

bshambaugh 32 minutes ago interesting

{removed:someotherguy} 30 minutes ago also noticed comment at https://github.com/sparkfun/SparkFun_ATECCX08a_Arduino_Library/blob/7cd0579efd5550634f098a9af7f70ebc3d2cfb3b/src/SparkFun_ATECCX08a_Arduino_Library.cpp#L449-L452 src/SparkFun_ATECCX08a_Arduino_Library.cpp:449-452

// pull in data 32 bytes at at time. (necessary to avoid overflow on atmega328) // if length is less than or equal to 32, then just pull it in. // if length is greater than 32, then we must first pull in 32, then pull in remainder. // lets use length as our tracker and we will subtract from it as we pull in data.

https://github.com/sparkfun/SparkFun_ATECCX08a_Arduino_Library|sparkfun/SparkFun_ATECCX08a_Arduino_Librarysparkfun/SparkFun_ATECCX08a_Arduino_Library | Added by GitHub

bshambaugh 25 minutes ago Is it responsible to fidget with that? I could try. It is curious that it works just fine on a different architecture, an ESP32 {removed:someotherguy} 11 minutes ago maybe there is a difference how requestFrom works, e.g. start/stop {removed:someotherguy} 8 minutes ago (I would try to add some nano-delays before requestFrom just to see if something changes, but right way is to hook the oscilloscope-like tool to find real reason)

bshambaugh 2:20 PM Does anyone know much about IIC or I2C connections? I am trying to get a Heltec CubeCell to work with a SparkFun Cryptographic Co-Processor (ATECC508A breakout). It seems like each new device needs to be configured for the Cubecell. The ESP32 seemed more plug and play. The Wire.h library and a few other things are different for the ESP32 and the Heltec CubeCell.

bshambaugh 2:27 PM supposedly it works differently since it is a different chip (checking the forum) (edited)

bshambaugh commented 4 years ago

https://heltec-automation-docs.readthedocs.io/en/latest/ (tried on CubeCell failed) and ESP32+LoRa(succeeded))

and Atmel328P U (succeeded)

bshambaugh commented 4 years ago

I changed ATRCC508A_MAX_REQUEST_SIZE in the header file from 32 to 96 and I was able to run the first two examples.

bshambaugh commented 4 years ago

For the time being I am unable to get Example 3 to work, but this is a separate issue. From past experience, when I got Example 2 to work I could verify the signature when imported into a Node.js library. Example 3 is not needed for my use case as far as I know. I'm going to close this. Thanks.