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

Device not found. Check wiring. #10

Closed davidnnaji closed 3 years ago

davidnnaji commented 3 years ago

Hello Pete,

I'm using this library with the ATECC608a and I configured my device using the Microchip ACES software before integrating it with my microcontroller. I'm running into an issue where "Example1_Configuration.ino" can perform a successful wake-up of a blank (unconfigured) ATECC608a chip but fails to connect to my configured and locked chip.

The program returns the phrase "Device not found. Check wiring." which under normal circumstances would be appropriate. However, given the exact same wiring was used on the blank one (I merely swapped chips from my SOIC8 socket) I don't think there's a problem with my wiring. I'm also able to access the chip information fine when I connect with ACES.

Chapter 7 of the datasheet states:

A simple way to generate a wake pulse is to send a byte of 0x00 at 100 kHz. Subsequent commands can be run at a higher frequency.

Here is the section of code of interest in ssrc/SparkFun_ATECCX08a_Arduino_Library.cpp:

boolean ATECCX08A::begin(uint8_t i2caddr, TwoWire &wirePort, Stream &serialPort)
{
  //Bring in the user's choices
  _i2cPort = &wirePort; //Grab which port the user wants us to use

  _debugSerial = &serialPort; //Grab which port the user wants us to use

  _i2caddr = i2caddr;

  return ( wakeUp() ); // see if the IC wakes up properly, return responce.
}

/** \brief
    wakeUp()
    This function wakes up the ATECCX08a IC
    Returns TRUE if the IC responds with correct verification
    Message (0x04, 0x11, 0x33, 0x44)
    The actual status byte we are looking for is the 0x11.
    The complete message is as follows:
    COUNT, DATA, CRC[0], CRC[1].
    0x11 means that it received the wake condition and is goat to goo.
    Note, in most SparkFun Arduino Libraries, we would use a different
    function called isConnected(), but because this IC will ACK and
    respond with a status, we are gonna use wakeUp() for the same purpose.
*/

boolean ATECCX08A::wakeUp()
{
  _i2cPort->beginTransmission(0x00); // set up to write to address "0x00",
  // This creates a "wake condition" where SDA is held low for at least tWLO
  // tWLO means "wake low duration" and must be at least 60 uSeconds (which is acheived by writing 0x00 at 100KHz I2C)
  _i2cPort->endTransmission(); // actually send it

  delayMicroseconds(1500); // required for the IC to actually wake up.
  // 1500 uSeconds is minimum and known as "Wake High Delay to Data Comm." tWHI, and SDA must be high during this time.

  // Now let's read back from the IC and see if it reports back good things.
  countGlobal = 0;

  if (!receiveResponseData(RESPONSE_COUNT_SIZE + RESPONSE_SIGNAL_SIZE + CRC_SIZE))
    return false;

  if (!checkCount() || !checkCrc())
    return false;

  // If we hear a "0x11", that means it had a successful wake up.
  if (inputBuffer[RESPONSE_SIGNAL_INDEX] != ATRCC508A_SUCCESSFUL_WAKEUP)
    return false;

  return true;
}

Do you know of a way to ensure that _i2cPort->beginTransmission(0x00); is being sent at a low enough speed? Or could I be having an issue that's unrelated?

Thanks for your help!

Best,

David N.

davidnnaji commented 3 years ago

Looks like I resolved my own issue. My configuration byte for "I2C Address" was 0x6C. The actual address resides in bits [1:7] thus, the I2C address is 0x36 which varies from the default provided in the library (I believe is address 0x60). So the solution is to pass 0x36 to atecc.begin() or simply change my "I2C Address" byte to the default 0xC0.

Information on how these bytes operate can be found in the documentation here. I'm going to set this issue as resolved. Given this isn't a real issue with the library, please feel free to delete it if you wish or keep it in case someone makes the same mistake.

Best,

David