• AVR Freaks

Helpful ReplyHot!ATECC608A trouble with I2C

Page: 12 > Showing page 1 of 2
Author
esanchez
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/03/04 11:01:08
  • Location: 0
  • Status: offline
2019/03/04 14:43:31 (permalink)
0

ATECC608A trouble with I2C

Hi, 
 
I'm having trouble communicating with the ATECC608A through I2C and I'm not sure if my issue is hardware or software.
I'm using the cryptoauthlib to initialize the chip and to grab a random number like this:
 
     atcab_init(&cfg_ateccx08a_i2c_default); //I2C interface
     atcab_random(&random_number); // get a random number from the chip
 
The problem is that I always get a status response of ATCA_TOO_MANY_COMM_RETRIES, and from my analyzer trace, it looks like the ATECC608A never ACKs anything. I can see the library tries to wake up the chip by writing 0x00 and then waits ~1.9ms and performs a twi_master_read() to address 0xC1 to see if the device woke up, but this always fails for me.
 
Is the I2C address of 0xC0 correct for the ATECCC608A? Should I be getting an ACK like any other I2C device? 
 
Thank you
#1
esanchez
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/03/04 11:01:08
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/03/05 09:42:03 (permalink)
4 (1)
I think I found my issue. It looks like I have the 1-Wire version of this chip instead of the I2C version. My part number is ATECC608A-SSHCZ-T, where the "CZ" indicates 1-Wire according to the "Product Identification System" on the datasheet.
#2
JavierPascual
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/05/10 01:52:33
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/05/20 10:27:24 (permalink)
0
Hi!
 
I have a problem with the ATECC608A running with a ESP32. I think it's a bug of the library. I have the I2C version and it's detected correctly (with i2c scanner), but always return error 240 (atcab_read_bytes_zone() failed with ret=0x000000F0).
 
ATCAIfaceCfg *gCfg = &cfg_ateccx08a_i2c_default;
ATCA_STATUS status = ATCA_GEN_FAIL;
uint8_t random_number[32];
uint8_t serial_number[9];
 
gCfg->iface_type = ATCA_I2C_IFACE,
gCfg->devtype = ATECC608A,
gCfg->atcai2c.slave_address = 0x76;
gCfg->atcai2c.bus = 1;
gCfg->atcai2c.baud = 400000;
gCfg->wake_delay = 1500;
gCfg->rx_retries = 20;
 
status = atcab_init(gCfg);
 
if (status == ATCA_SUCCESS)
{
   status = atcab_random(random_number);}
else
{
   ESP_LOGE(DEV_TAG, "\t- ERROR: %i", status);
}
 
 
 
 
 
post edited by JavierPascual - 2019/05/20 10:35:40
#3
esanchez
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/03/04 11:01:08
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/05/23 13:20:05 (permalink)
3 (1)
Where do you get the error? Inside atcab_init() or inside atcab_random()?
 
Did you #define ATCA_HAL_I2C and ATCA_NO_HEAP?
 
My configuration is this:
ATCAIfaceCfg cfg_ateccx08a_i2c_default = {
.iface_type = ATCA_I2C_IFACE,
.devtype = ATECC608A,
.atcai2c.slave_address = 0xC0,
.atcai2c.bus = 1,
.atcai2c.baud = 400000,
//.atcai2c.baud = 100000,
.wake_delay = 1500,
.rx_retries = 20
};
 
atcab_init(&cfg_ateccx08a_i2c_default);
 
 
My call to atcab_init() returns success but for some reason when I call atcab_random(), the ATECC608A always sends the same value of 0xFF00...FF00 and the call also returns success. I'm sort of stuck trying to get a random number.
 
#4
JavierPascual
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/05/10 01:52:33
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/05/23 14:20:33 (permalink)
0
I have not defined ATCA_NO_HEAP (ATCA_HAL_I2C yes), i'm going to try it...
 
The error is returned by atcab_init().
 
About the "baud" config, inside the cryptoauthlib always is setted to 100000 bauds (ignore user parameter).
 
Thanks!!
#5
JavierPascual
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/05/10 01:52:33
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/05/24 14:37:39 (permalink)
0
It fails with ATCA_NO_HEAP defined too... :-(
#6
esanchez
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/03/04 11:01:08
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/05/28 11:29:37 (permalink)
0
I'm not familiar with "I2C scanner", is that a separate program?
 
Using a logic analyzer, can you confirm that the ESP32 is sending out I2C commands when it calls atcab_init()? Maybe your I2C configuration is wrong. Maybe a wrong "gCfg->atcai2c.bus" value or something. You can check the "hal_esp32_i2c.c" file to see if you have to adapt anything. I'm not using the ESP32, so I'm not sure...
#7
cobusve
Super Member
  • Total Posts : 493
  • Reward points : 0
  • Joined: 2012/04/02 16:15:40
  • Location: Chandler
  • Status: offline
Re: ATECC608A trouble with I2C 2019/05/28 13:51:48 (permalink) ☄ Helpfulby esanchez 2019/05/28 13:53:50
0
The ECC608 I believe will always return the same result for a random number when the device has not been provisioned yet, this makes it possible to test.
 
Also once you have provisioned the device you cannot undo it, and depending what you set up you may not be able to change it again, so be careful.

Also take a look at https://www.microforum.cc/ - a great resource for information on PIC and AVR microcontrollers and embedded programming in general. You can also post questions to the experts there.
#8
mrpackethead
packet mangler
  • Total Posts : 967
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/06/06 00:49:15 (permalink)
0
"Thanks" for this post. I made the exact same mistake. and ordered the one wire part.  I am not sure why but the way i read the datasheet was that the device could be used in etiher mode.  Hopefully tommorrow the new parts will arrive, and we can have a another turn. 

In order to truely work out how this device works, i've attached mine to a MCP2221A which is an USB/I2C converter, and i am able to write code in Python very quickly. 

Did you confirm that the way to wake it up is by writing 0x00?
 
 
 
#9
esanchez
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/03/04 11:01:08
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/06/06 08:47:23 (permalink)
0
Glad it helped.
 
Yeah, from what I remember, every time I call an API from the cryptoauthlib, it first wakes up the device by writing a 0x00 (which will have a NACK), and then writes the device address (this will have an ACK). I tried not using the library and just writing to the address, but it always NACKed unless I first woke the device with 0x00.
#10
mrpackethead
packet mangler
  • Total Posts : 967
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/06/10 14:39:41 (permalink)
0
What address did you write that 0x00 to?      I've tryed sending it to the Crytpo (0x60) and 0x00,  but it doe'snt seem to want to wake it up. 

What do you do to verify its awake. ( this is a brand new chip, thats not been written too before, so is not locked. )
#11
ric
Super Member
  • Total Posts : 23207
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: ATECC608A trouble with I2C 2019/06/10 15:47:28 (permalink)
4 (1)
As I read post#10, he means "write to I2C address zero", and this will be NAKed (as there is nothing there), then you can talk to the device via its own address.

What do you do to verify its awake. ( this is a brand new chip, thats not been written too before, so is not locked. )

I would assume you would receive an ACK as soon as you send the correct I2C address.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#12
mrpackethead
packet mangler
  • Total Posts : 967
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/06/12 02:16:56 (permalink)
0
Unforuantly i've not been able to get to the workshop to have a look at the I2C bus direclty with the LA. I'm using the Pymcp2221A ( USB/I2C bus ) to connect to the i2c where the 608 is.

I'm just not getting any progress on this.  anybody got any clues
 


from PyMCP2221A import PyMCP2221A
import time
mcp2221 = PyMCP2221A.PyMCP2221A()
mcp2221.Reset()
mcp2221 = PyMCP2221A.PyMCP2221A()
print('-'*20)
print('ATECC608A on MCP2221A, via Python test')
print('-'*20)
print(" CTRL+C keys to exit.")
mcp2221.I2C_Init()
ATECC608A_addr = 0xC0
zero_addr = 0x00
# Wake up the crytpo
data=[0]*3
data[0] = 0x00
data[1] = 0x00
data[2] = 0x00
mcp2221.I2C_Write(zero_addr,data)
# Probe the device
time.sleep(0.005) # wait for 2ms
if(mcp2221.I2C_Read(ATECC608A_addr,0x30) != -1):
print('Found')
else:
print('Not on bus')
 

Attached Image(s)

#13
mrpackethead
packet mangler
  • Total Posts : 967
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/06/12 02:58:48 (permalink)
0
I've just been re-reading the datasheet;    I wonder how fast my I2C is rnning.
 

The Wake condition requires that either the system processor manually drives the SDA pin low for tWLO,
or a data byte of 0x00 be transmitted at a clock rate sufficiently slow so that SDA is low for a minimum
period of tWLO. When the device is awake, the normal processor I2C hardware and/or software can be
used for device communications up to and including the I/O sequence required, thus putting the device
back into low-power (i.e. sleep) mode.

When there are multiple ATECC608A devices on the bus, and the I2C interface is run at 133 KHz or
slower, the transmission of certain data patterns (such as 0x00) will cause all the ATECC608A devices
on the bus to wake-up. Because subsequent device addresses transmitted along the bus will only match
the desired devices, the unused devices will remain idle and not cause any bus conflicts
#14
esanchez
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/03/04 11:01:08
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/06/18 10:59:58 (permalink)
0
I currently don't have my LA, but I remember it was just writing 1 byte 0x00 with no address (this byte would NACK), then about ~2ms it would start sending the command to the device at address 0xC0. The address byte would ACK and so would the rest of the bytes in the command (and the device would respond). But if I didn't send the wake-up first, all the bytes in the command would NACK.
post edited by esanchez - 2019/06/18 11:01:11
#15
esanchez
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/03/04 11:01:08
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/06/26 11:20:29 (permalink)
0
@cobusve, is it possible to purchase the ATECC608A already provisioned by Microchip? Or would I need to purchase a provisioning kit and do it myself?
 
Thank you
#16
mrpackethead
packet mangler
  • Total Posts : 967
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/07/07 14:37:21 (permalink)
0
wakeup and read. 

This is the 'wakeup' i'm sending, but it does not appear to want to wake up the IC, When i try to read from it ( to addr 0xC0 ) i dont' get any ACK.
 
Is my Wakeup suitable?    I have 2k2 resistors on my I2C,  and its all running at 5V.
 
post edited by mrpackethead - 2019/07/07 14:39:43

Attached Image(s)

#17
mrpackethead
packet mangler
  • Total Posts : 967
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/07/10 00:10:56 (permalink)
0
I got the dev board out ( Microchip Crypto Pro ) and hooked it up to my i2C host and boom it works just fine. 

I have noticed in the datasheets, that there is no reference to the Expanded Pad being tied to gnd.  SO on my design it was not.     However on the dev board it is.. 

I'm wondering if this could be an issue?
#18
mrpackethead
packet mangler
  • Total Posts : 967
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/07/15 17:07:09 (permalink)
0
Hi,  I'm making progress ( of sorts ) i am able to connect to the device, but have got stuck. 

(1) Attached is a scope trace of wakeup.   This is done by Writing 0x00 to address 0x00
(2) I then can send a read to address 0x60 with the value 0x04.   This returns four bytes.   
"0x04 0x11 0x33 0x43"

From the datasheet, i understand this is telling me that 

0x04 - count four bytes
0x11 - Indication that the ATECC608A has received a proper wake token
0x33  0x43 are a CRC-16, input reflected, polynominal 0x8005        ( LSB ordered )

THis seems sensible. 

(3) I have not set any config on this device, so I try to send it an Info command, 

0x06, 0x30, 0x00, 0x00, 0xE1, 0x00

THe 608 Acks each byte, but doesnt respond within anything.  (* this is sent to address 0x60 as a write )

0x06 - 6bytes count
0x30 - op code
0x00 - Param 1 
0x00 - Param 2 
0xE1  / 0x00    ( CRC )

(info.jpg )

What am i doing wrong? why doesnt it respond.






 
 
 
 
post edited by mrpackethead - 2019/07/15 17:35:28

Attached Image(s)

#19
mrpackethead
packet mangler
  • Total Posts : 967
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
Re: ATECC608A trouble with I2C 2019/07/15 18:04:09 (permalink)
0
I've released that param 2 is always two bytes.   I've modified what i'm sending but it makes no difference 


> I2C Write, Address = 00, Data: 00 Delay = 3
Address NACK received. Error code: -23

> I2C Read, Address = 60, Read 4 bytes, Delay = 0
OK
< 04 11 33 43
 
> I2C Write, Address = 60, Data: 07 1B 00 00 00 27 71 Delay = 0
OK
 
> I2C Write, Address = 00, Data: 00 Delay = 3
Address NACK received. Error code: -23
 
> I2C Write, Address = 60, Data: 07 30 00 00 00 03 4D Delay = 0
OK
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5