Edukit ATECC608B & AWS IOT & UiFlow
-
Sorry, I wasn't aware there were blocks for the ATECC
OK just tried it my self and getting
Core 1 register dump: PC : 0x4009a973 PS : 0x00060633 A0 : 0x80099799 A1 : 0x3ffd6d50 A2 : 0x0000001d A3 : 0x00060623 A4 : 0x3ffbd560 A5 : 0x00000001 A6 : 0x000000fe A7 : 0x00000035 A8 : 0x00000000 A9 : 0x00000001 A10 : 0x0000abab A11 : 0x00000000 A12 : 0x3f7760c4 A13 : 0x3f775e7f A14 : 0x000000fe A15 : 0x00000036 SAR : 0x0000000a EXCCAUSE: 0x0000001c EXCVADDR: 0x00000021 LBEG : 0x40093aa4 LEND : 0x40093ad2 LCOUNT : 0xffffffff ELF file SHA256: 0000000000000000 Backtrace: 0x4009a970:0x3ffd6d50 0x40099796:0x3ffd6d70 0x40097763:0x3ffd6d90 0x4017d699:0x3ffd6dd0 0x400faa7f:0x3ffd6e20 0x40250e2b:0x3ffd6e50 0x400f2b1e:0x3ffd6e80 0x400e44a2:0x3ffd6ea0 0x400e01dd:0x3ffd6ec0 0x400e032e:0x3ffd6ee0 0x400ee903:0x3ffd6f00 0x400e4642:0x3ffd6fa0 0x400e01dd:0x3ffd6ff0 0x400e032e:0x3ffd7010 0x400ee903:0x3ffd7030 0x400e4642:0x3ffd70d0 0x400e01dd:0x3ffd7140 0x400e032e:0x3ffd7160 0x400ea318:0x3ffd7180 0x400e97f9:0x3ffd71d0 0x400e01dd:0x3ffd71f0 0x400e032e:0x3ffd7210 0x400ee903:0x3ffd7230 0x400e4642:0x3ffd72d0 0x400e01dd:0x3ffd7330 0x400e0206:0x3ffd7350 0x400e028a:0x3ffd7370 0x400ebc0d:0x3ffd7400 0x400ebc1d:0x3ffd7430 0x400e4576:0x3ffd7450 0x400e01dd:0x3ffd7480 0x400ee845:0x3ffd74a0 0x400e4642:0x3ffd7540 0x400e01dd:0x3ffd7570 0x400e032e:0x3ffd7590 0x400ee903:0x3ffd75b0 0x400e4642:0x3ffd7650 0x400e01dd:0x3ffd7680 0x400e0206:0x3ffd76a0 0x400e028a:0x3ffd76c0 0x400ebc0d:0x3ffd7750 0x400ebc2d:0x3ffd7780 0x400e4576:0x3ffd77a0 0x400e01dd:0x3ffd77d0 0x400ee845:0x3ffd77f0 0x400e4642:0x3ffd7890 0x400e01dd:0x3ffd78c0 0x400e032e:0x3ffd78e0 0x400ee903:0x3ffd7900 0x400e4642:0x3ffd79a0 0x400e01dd:0x3ffd7a10 0x400e032e:0x3ffd7a30 0x400ee903:0x3ffd7a50 0x400e4642:0x3ffd7af0 0x400e01dd:0x3ffd7b60 0x400e032e:0x3ffd7b80 0x400ee903:0x3ffd7ba0 0x400e4642:0x3ffd7c40 0x400e01dd:0x3ffd7ca0 0x400e032e:0x3ffd7cc0 0x400ee903:0x3ffd7ce0 0x400e4642:0x3ffd7d80 0x400e01dd:0x3ffd7db0 0x400e032e:0x3ffd7dd0 0x400ee903:0x3ffd7df0 0x400e4642:0x3ffd7e90 0x400e01dd:0x3ffd7ee0 0x400e0206:0x3ffd7f00 0x40170980:0x3ffd7f20 0x40170c49:0x3ffd7fb0 0x400f7fe4:0x3ffd7fe0 0x40097d55:0x3ffd8020 Rebooting... ets Jul 29 2019 12:21:46 rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:5228 load:0x40078000,len:13424 load:0x40080400,len:3568 entry 0x4008063c
When the terminal is open and running.
-
@ajb2k3 Thank you for validating it, now the question is where could I find the documents that explain how to use this blocks to connect to aws iot core, instead of downloading the certificates from amazon console.
-
Look me up on Amazon (Adam Bryant), I have a crappy getting started book about AWS and UIFlow
-
@ajb2k3 Thank you, I found your book at amazon store, but in the description it doesn't say anything regarding how to use the ATECC608B with UiFlow. I have done examples subscribing my edukit to aws iot core, but I have downloaded the certificates directly from AWS, the question is how to use ATECC608B with uiflow. Do you have a book that I could buy with this topic?
Regards -
Ah no, I'm actually working on adding that to V2 of the book at the moment following your request.
-
@ajb2k3 Great! Thank you!, please let me know when it is done.
Regards -
-
Hello guys
I did some tests with the AWS bottom:
- When I stack the AWS bottom to an M5Core2 (using @gabrielgc75 trick with the ID unit and custom pins 21/22) I get a crash - something about I2C master not being initialized.
- However when I stack the AWS bottom to an M5Stack Basic (again using an ID unit but this time with default Port A) it works and I can access the ATECC608.
Thanks
Felix -
@ajb2k3 It's super buggy. I tried getting this ATECC608 chip working with Arduino code and had very inconsistent results, kernel panics and crashes. The only way I've seen it run consistently is by running the RTOS code in the AWS edukit tutorials.
-
@felmue @greenleaf I've reached out to M5Stack to see if they have a solution.
-
Interesting, It seams that the I2C master bus is not being initialised.
E (71690) i2c: /home/m5/M5-Workspace/esp-idf-for-m5/components/driver/i2c.c:1273 (i2c_master_cmd_begin):i2c driver not installed E (71692) i2c: /home/m5/M5-Workspace/esp-idf-for-m5/components/driver/i2c.c:1273 (i2c_master_cmd_begin):i2c driver not installed Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled. Core 0 register dump: PC : 0x400d29ea PS : 0x00060230 A0 : 0x800dffe5 A1 : 0x3ffd3450 A2 : 0x3f9530c0 A3 : 0x3f76a89d A4 : 0x3f953070 A5 : 0x00000000 A6 : 0x000000fe A7 : 0x3ffc4c40 A8 : 0x800d29ea A9 : 0x3ffd3430 A10 : 0x00000000 A11 : 0x00000001 A12 : 0x3f953150 A13 : 0x3ffd3440 A14 : 0x0000000c A15 : 0xff000000 SAR : 0x0000001a EXCCAUSE: 0x0000001c EXCVADDR: 0x00000010 LBEG : 0x40093aa4 LEND : 0x40093ad2 LCOUNT : 0xffffffff ELF file SHA256: 0000000000000000 Backtrace: 0x400d29e7:0x3ffd3450 0x400dffe2:0x3ffd3470 0x400e0bcc:0x3ffd3490 0x4016d781:0x3ffd34b0 0x4016d7b1:0x3ffd34d0 0x40097d55:0x3ffd3500 Rebooting... ets Jul 29 2019 12:21:46 rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:5228 load:0x40078000,len:13424 load:0x40080400,len:3568 entry 0x4008063c _ __ _ _ _(_)/ _| | _____ __ | | | | | |_| |/ _ \ \ /\ / / | |_| | | _| | (_) \ V V / \__,_|_|_| |_|\___/ \_/\_/
-
OK getting somewhere, every time you get a guru or kernel panic you need to hard shut down the core two for 5 seconds or the bug remains in memory.
-
-
1 Step Forward!
from m5stack_ui import * from uiflow import * import i2c_bus import machine i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21), freq=133000) screen = M5Screen() screen.clean_screen() screen.set_screen_bg_color(0xFFFFFF) label0 = M5Label('label0', x=15, y=43, color=0x000, font=FONT_MONT_14, parent=None) print('Scan i2c bus...') addresses = i2c.scan() print(i2c.scan()) label0.set_text(str(i2c.scan()))
So the code get run out of order and crashes the i2c bus.
-
Hello @ajb2k3
are you doing multiple
i2c.scan()
calls on purpose? When I try that I only get an empty list. However doing only one scan works for me.I went through older M5Core2 UIFlow firmware versions and all of them crash on me when using the ID unit with custom values for I2C (e.g. 21, 22) in order to access the ATECC608 in the AWS bottom. And UIFlow firmware 1.7.5 doesn't support the ID unit.
BTW: The ATECC608B has a sleep mode and when it is in that mode it will not show up during an I2C scan.
Thanks
Felix -
@felmue I'm doing multi scans because I'm not sure how do make one and pass the results to both the Label and print functions.
Yeh found out about the sleep mode, you have to hard reset the base plate to wake it up before running an i2C scan.
I'm running 1.10.2 and found the issue is in the i2C setup function.addresses = i2c.scan()
Is just a left over function of what I was testing earlier. -
And more progress!
I have stable access to the Core2 AWS' ATECC608b>>> help(_ID.ID) object <class 'ID'> is of type type receiveResponseData -- <function receiveResponseData at 0x3f95ce00> read_output -- <function read_output at 0x3f95d1d0> publicKey64Bytes -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') verifySignature -- <function verifySignature at 0x3f95d260> wakeup -- <function wakeup at 0x3f95cc90> dataOTPLockStatus -- False createNewKeyPair -- <function createNewKeyPair at 0x3f95ce60> signTempKey -- <function signTempKey at 0x3f95d240> generatePublicKey -- <function generatePublicKey at 0x3f95d1a0> getRandomInt -- <function getRandomInt at 0x3f95cdc0> sha256 -- <function sha256 at 0x3f95d270> updateRandom32Bytes -- <function updateRandom32Bytes at 0x3f95cd10> random32Bytes -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') KeyConfig -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') configZone -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') input_buffer -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') writeConfigZone -- <function writeConfigZone at 0x3f95d280> lockDataSlot0 -- <function lockDataSlot0 at 0x3f95ccf0> signature -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') readConfigZone -- <function readConfigZone at 0x3f95ccd0> get_crc -- bytearray(b'\x00\x00') countGlobal -- 0 check_crc -- <function check_crc at 0x3f95ce20> read -- <function read at 0x3f95d1c0> write -- <function write at 0x3f95d1e0> __init__ -- <function __init__ at 0x3f95cd90> slot0LockStatus -- False createSignature -- <function createSignature at 0x3f95d200> revisionNumber -- bytearray(b'\x00\x00\x00\x00\x00') get_info -- <function get_info at 0x3f95ccb0> getRandomLong -- <function getRandomLong at 0x3f95cdd0> random_min_max -- <function random_min_max at 0x3f95cdf0> __module__ -- units._ID configLockStatus -- False hash256 -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') lockDataAndOTP -- <function lockDataAndOTP at 0x3f95cce0> random_max -- <function random_max at 0x3f95cde0> idle_mode -- <function idle_mode at 0x3f95cca0> calculate_crc -- <function calculate_crc at 0x3f95ce30> cleanInputBuffer -- <function cleanInputBuffer at 0x3f95ce40> lock_config -- <function lock_config at 0x3f95ccc0> __qualname__ -- ID serialNumber -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') lock -- <function lock at 0x3f95cd00> loadTempKey -- <function loadTempKey at 0x3f95d220> getRandomByte -- <function getRandomByte at 0x3f95cdb0> sendCommand -- <function sendCommand at 0x3f95d2c0> check_count -- <function check_count at 0x3f95ce10> SlotConfig -- bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') >>> help(_ID.ID.wakeup) object <function wakeup at 0x3f95cc90> is of type function >>> help(_ID.ID.get_info) object <function get_info at 0x3f95ccb0> is of type function >>> help('_ID.ID.get_info') object _ID.ID.get_info is of type str encode -- <function> find -- <function> rfind -- <function> index -- <function> rindex -- <function> join -- <function> split -- <function> splitlines -- <function> rsplit -- <function> startswith -- <function> endswith -- <function> strip -- <function> lstrip -- <function> rstrip -- <function> format -- <function> replace -- <function> count -- <function> partition -- <function> rpartition -- <function> center -- <function> lower -- <function> upper -- <function> isspace -- <function> isalpha -- <function> isdigit -- <function> isupper -- <function> islower -- <function> >>> import i2c_bus >>> i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21), freq=133000) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'machine' isn't defined >>> import i2c_bus >>> Import machine Traceback (most recent call last): File "<stdin>", line 1 SyntaxError: invalid syntax >>> import machine >>> i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21), freq=133000) >>> print(i2c.scan()) [52, 53, 56, 81, 104] >>> import units >>> from units import _ID >>> i2c.wakeup Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'I2C' object has no attribute 'wakeup' >>> ID_0 = unit.get(unit.ID, (21,22)) >>> ID_0.wakeup <bound_method> >>> ID_0.ID.wakeup Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'ID' object has no attribute 'ID' >>> ID_0.get_info <bound_method> >>> print(ID_0.get_info) <bound_method> >>> print(ID_0.get_info()) True >>> print(ID_0.wakeup()) True >>> print(ID_0.read_output()) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: function takes 5 positional arguments but 1 were given >>> print(ID_0.readConfigZone()) True >>> print(ID_0.revisionnumber()) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'ID' object has no attribute 'revisionnumber' >>> print(ID_0.revisionNumber()) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'bytearray' object isn't callable >>> print(ID_0.revisionNumber) bytearray(b'\x00\x00`\x02') >>> print(ID_0.serialNumber) bytearray(b'\x01#\xce\xa0\xcf\x06\x90\x0b\x01') >>>
Datalog dump from Thonny!
-
>>> print(ID_0.loadTempKey(64)) True >>> print(ID_0.generatePublicKey()) True >>> print(ID_0.publicKey64Bytes) bytearray(b'\x84\xf8\xda\xf6\xda\x18&r\x1b\xf0\xdbv\x1a\xcc\xf6z\xfd\xe2>\xdcY\xd5l\xf4kk\xb7D\xffI6\x1d\xcfDO\x9f\xc8bv\x80\xa9\xb8\xe75\xc5\x13\xe4\xe91\x9b\xcelg\xeb\x01Q\x18\xd0<\x91\xcb\xd8\xc1\xa1') >>>
Generate and display a key!
-
-
Hello @ajb2k3
thank you for putting together the guide. Unfortunately I cannot get it to work. I do not fully understand the following instructions from your guide.
Now I have the basics after poking away at micropython I import machine and units._ID0
import units from units import _ID ID_0 = unit.get(unit.ID, (21,22))
Using Thonny and ...
... trying toimport units._ID0
results in an error.
... where is_ID
used?
... trying to runID_0 = unit.get(unit.ID, (21,22))
still crashes my M5Core2.Thanks
Felix