Add support for both I2C busses
* When using the dev board without an enviro, the crypto is on bus 0. In
any other scenario it would be on 1.
* Enumerating this way (ordered by the tuples) ensures that on a dev
board the dev board crypto will always be used.
Change-Id: I5a8c330e5f442bdb4bca2296b267c3c0bfb685f2
diff --git a/python/coral-cloudiot/coral/cloudiot/ecc608.py b/python/coral-cloudiot/coral/cloudiot/ecc608.py
index 9346428..33cdfab 100644
--- a/python/coral-cloudiot/coral/cloudiot/ecc608.py
+++ b/python/coral-cloudiot/coral/cloudiot/ecc608.py
@@ -50,11 +50,11 @@
return public_key_pem
-def _ecc608_check_address(address):
+def _ecc608_check_address(bus, address):
cfg = cfg_ateccx08a_i2c_default()
# Cryptolib uses 8-bit address.
cfg.cfg.atcai2c.slave_address = address << 1
- cfg.cfg.atcai2c.bus = 1 # ARM I2C
+ cfg.cfg.atcai2c.bus = bus # ARM I2C
cfg.devtype = 3 # ECC608
status = atcab_init(cfg)
if status == 0:
@@ -65,10 +65,12 @@
def ecc608_find_chip():
"""Returns the I2C address of the crypto chip or None if chip is not installed."""
- for addr in (0x30, 0x60, 0x62):
- if _ecc608_check_address(addr):
- logger.info('Found crypto chip at 0x%x', addr)
- return addr
+ # Bus and address can change for Pi/Dev Board as well as if using enviro.
+ for bus in (0, 1):
+ for addr in (0x30, 0x60, 0x62):
+ if _ecc608_check_address(addr):
+ logger.info('Found crypto chip at 0x%x', addr)
+ return addr
logger.warning('No crypto detected, using SW.')
return None