-
-
Save bshambaugh/07fc95c7b129a2614c6bbc2288f124b5 to your computer and use it in GitHub Desktop.
Copyright @ 2019 Heltec Automation.All rights reserved. | |
Successful wakeUp(). I2C connections are good. | |
configZone: | |
0: 0x01 0b00000001 | |
1: 0x23 0b00100011 | |
2: 0x8B 0b10001011 | |
3: 0x93 0b10010011 | |
4: 0x00 0b00000000 | |
5: 0x00 0b00000000 | |
6: 0x50 0b01010000 | |
7: 0x00 0b00000000 | |
8: 0x3F 0b00111111 | |
9: 0x8B 0b10001011 | |
10: 0x73 0b01110011 | |
11: 0xD0 0b11010000 | |
12: 0xEE 0b11101110 | |
13: 0xC0 0b11000000 | |
14: 0x55 0b01010101 | |
15: 0x00 0b00000000 | |
16: 0xC0 0b11000000 | |
17: 0x00 0b00000000 | |
18: 0x55 0b01010101 | |
19: 0x00 0b00000000 | |
20: 0x83 0b10000011 | |
21: 0x20 0b00100000 | |
22: 0x83 0b10000011 | |
23: 0x20 0b00100000 | |
24: 0x8F 0b10001111 | |
25: 0x20 0b00100000 | |
26: 0xC4 0b11000100 | |
27: 0x8F 0b10001111 | |
28: 0x8F 0b10001111 | |
29: 0x8F 0b10001111 | |
30: 0x8F 0b10001111 | |
31: 0x4B 0b01001011 | |
32: 0x9F 0b10011111 | |
33: 0x8F 0b10001111 | |
34: 0xAF 0b10101111 | |
35: 0x8F 0b10001111 | |
36: 0x00 0b00000000 | |
37: 0x00 0b00000000 | |
38: 0x00 0b00000000 | |
39: 0x00 0b00000000 | |
40: 0x00 0b00000000 | |
41: 0x00 0b00000000 | |
42: 0x00 0b00000000 | |
43: 0x00 0b00000000 | |
44: 0x00 0b00000000 | |
45: 0x00 0b00000000 | |
46: 0x00 0b00000000 | |
47: 0x00 0b00000000 | |
48: 0x00 0b00000000 | |
49: 0x00 0b00000000 | |
50: 0xAF 0b10101111 | |
51: 0x8F 0b10001111 | |
52: 0xFF 0b11111111 | |
53: 0xFF 0b11111111 | |
54: 0xFF 0b11111111 | |
55: 0xFF 0b11111111 | |
56: 0x00 0b00000000 | |
57: 0x00 0b00000000 | |
58: 0x00 0b00000000 | |
59: 0x00 0b00000000 | |
60: 0xFF 0b11111111 | |
61: 0xFF 0b11111111 | |
62: 0xFF 0b11111111 | |
63: 0xB2 0b10110010 | |
64: 0x00 0b00000000 | |
65: 0x00 0b00000000 | |
66: 0x00 0b00000000 | |
67: 0x00 0b00000000 | |
68: 0xFF 0b11111111 | |
69: 0xFF 0b11111111 | |
70: 0xFF 0b11111111 | |
71: 0xFF 0b11111111 | |
72: 0xFF 0b11111111 | |
73: 0xFF 0b11111111 | |
74: 0xFF 0b11111111 | |
75: 0xFF 0b11111111 | |
76: 0xFF 0b11111111 | |
77: 0xFF 0b11111111 | |
78: 0xFF 0b11111111 | |
79: 0xFF 0b11111111 | |
80: 0xFF 0b11111111 | |
81: 0xFF 0b11111111 | |
82: 0xFF 0b11111111 | |
83: 0xFF 0b11111111 | |
84: 0x00 0b00000000 | |
85: 0x00 0b00000000 | |
86: 0x00 0b00000000 | |
87: 0x00 0b00000000 | |
88: 0xFE 0b11111110 | |
89: 0xFF 0b11111111 | |
90: 0x00 0b00000000 | |
91: 0x00 0b00000000 | |
92: 0x00 0b00000000 | |
93: 0x00 0b00000000 | |
94: 0x00 0b00000000 | |
95: 0x2F 0b00101111 | |
96: 0x33 0b00110011 | |
97: 0x00 0b00000000 | |
98: 0x33 0b00110011 | |
99: 0x00 0b00000000 | |
100: 0x33 0b00110011 | |
101: 0x00 0b00000000 | |
102: 0x1C 0b00011100 | |
103: 0x00 0b00000000 | |
104: 0x1C 0b00011100 | |
105: 0x00 0b00000000 | |
106: 0x1C 0b00011100 | |
107: 0x00 0b00000000 | |
108: 0x1C 0b00011100 | |
109: 0x00 0b00000000 | |
110: 0x1C 0b00011100 | |
111: 0x00 0b00000000 | |
112: 0x3C 0b00111100 | |
113: 0x00 0b00000000 | |
114: 0x3C 0b00111100 | |
115: 0x00 0b00000000 | |
116: 0x3C 0b00111100 | |
117: 0x00 0b00000000 | |
118: 0x3C 0b00111100 | |
119: 0x00 0b00000000 | |
120: 0x3C 0b00111100 | |
121: 0x00 0b00000000 | |
122: 0x3C 0b00111100 | |
123: 0x00 0b00000000 | |
124: 0x3C 0b00111100 | |
125: 0x00 0b00000000 | |
126: 0x1C 0b00011100 | |
127: 0x3A 0b00111010 | |
Serial Number: 01238B933F8B73D0EE | |
Rev Number: 00005000 | |
Config Zone: Locked | |
Data/OTP Zone: Locked | |
Data Slot 0: Locked | |
Failure to generate This device's Public Key | |
Would you like to configure your Cryptographic Co-processor with SparkFun Standard settings? (y/n) | |
***Note, this is PERMANENT and cannot be changed later*** | |
***If you do not want to do this, type an 'n' or unplug now.*** |
Compare:
/home/ubuntu/.arduino15/packages/CubeCell/hardware/CubeCell/1.0.0/cores/asr650x/Wire/Wire.h
/home/ubuntu/.arduino15/packages/Heltec-esp32/hardware/esp32/0.0.5/libraries/Wire/src/Wire.h
/home/ubuntu/Downloads/arduino-1.8.12/hardware/arduino/avr/libraries/Wire/src/Wire.h
make the CubeCell library look like the Heltec-esp32
Compare:
/home/ubuntu/.arduino15/packages/CubeCell/hardware/CubeCell/1.0.0/cores/asr650x/Wire/Wire.cpp
and
/home/ubuntu/.arduino15/packages/Heltec-esp32/hardware/esp32/0.0.5/libraries/Wire/src/Wire.cpp
boolean checkCount(boolean debug = false);
boolean checkCrc(boolean debug = false);
atecc.generatePublicKey()
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,
Failure to generate This device's Public Key
(when running on the cubecell)
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,
Failure to generate This device's Public Key
boolean ATECCX08A::generatePublicKey(uint16_t slot, boolean debug)
sendCommand(COMMAND_OPCODE_GENKEY, GENKEY_MODE_PUBLIC, slot);
delay(115); // time for IC to process command and exectute
......
if(receiveResponseData(64 + 2 + 1,true) == false) return false; // public key (64), plus crc (2), plus count (1)
idleMode();
.....
(running on the Heltec CubeCell)
Serial Number: 01238B933F8B73D0EE
Rev Number: 00005000
Config Zone: Locked
Data/OTP Zone: Locked
Data Slot 0: Locked
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,
Failure to generate This device's Public Key
Would you like to configure your Cryptographic Co-processor with SparkFun Standard settings? (y/n)
Note, this is PERMANENT and cannot be changed later
If you do not want to do this, type an 'n' or unplug now.
(running on the Heltec ESP32)
Serial Number: 01238B933F8B73D0EE
Rev Number: 00005000
Config Zone: Locked
Data/OTP Zone: Locked
Data Slot 0: Locked
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,
This device's Public Key:
uint8_t publicKey[64] = {
0xF9, 0xC3, 0x6F, 0x89, 0x64, 0x62, 0x33, 0x78, 0xBD, 0xC0, 0x68, 0xD4, 0xBC, 0xE0, 0x7E, 0xD1,
0x7C, 0x8F, 0xA4, 0x86, 0xF9, 0xAC, 0x0C, 0x26, 0x13, 0xCA, 0x3C, 0x8C, 0x30, 0x6D, 0x7B, 0xB6,
0x1C, 0xD3, 0x67, 0x17, 0xB8, 0xAC, 0x5E, 0x4F, 0xEA, 0x8A, 0xD2, 0x3D, 0xC8, 0xD0, 0x78, 0x3C,
0x23, 0x18, 0xEE, 0x4A, 0xD7, 0xA8, 0x0D, 0xB6, 0xE0, 0x02, 0x6A, 0xD0, 0xB0, 0x72, 0xA2, 0x4F
};
Would you like to configure your Cryptographic Co-processor with SparkFun Standard settings? (y/n)
Note, this is PERMANENT and cannot be changed later
If you do not want to do this, type an 'n' or unplug now.
https://www.thethingsnetwork.org/forum/t/heltec-cubecell-part-1/30684
"The CubeCell products are based on the ASR650x series SiP (system-in-package) which combine a Cypress PSoC 4000 ARM Cortex-M0+ 32 bits 48MHz MCU (with 16kB SRAM and 128kB flash) together with a Semtech SX1262 LoRa tranceiver in a single package."
(edit: https://www.cypress.com/documentation/datasheets/psoc-4-psoc-4000-family-datasheet-programmable-system-chip-psoc)
(edit: https://www.semtech.com/products/wireless-rf/lora-transceivers/sx1262)
https://heltec.org/project/wifi-lora-32/
"Microprocessor: ESP32 (dual-core 32-bit MCU + ULP core), with LoRa node chip SX1276/SX1278;"
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf
"7810D-AVR-01/15Features●High performance, low power AVR® 8-bit microcontroller●Advanced RISC architecture●131 powerful instructions – most single clock cycle execution●32 8 general purpose working registers●Fully static operation●Up to 16MIPS throughput at 16MHz●On-chip 2-cycle multiplier●High endurance non-volatile memory segments●32K bytes of in-system self-programmable flash program memory ●1Kbytes EEPROM●2Kbytes internal SRAM ●Write/erase cycles: 10,000 flash/100,000 EEPROM●Optional boot code section with independent lock bits●In-system programming by on-chip boot program●True read-while-write operation ●Programming lock for software security"
I2C Protocol: https://www.circuitbasics.com/basics-of-the-i2c-communication-protocol (too tired to read atm)
./Arduino/libraries/SparkFun_ATECCX08a_Arduino_Library-itwocdefault/src$ echo "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" | sed 's/,//g'
43F9C36F8964623378BDC068D4BCE07ED17C8FA486F9ACC2613CA3C8C306D7B
./Arduino/libraries/SparkFun_ATECCX08a_Arduino_Library-itwocdefault/src$ echo "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" | sed 's/,//g' | wc -m
64
./Arduino/libraries/SparkFun_ATECCX08a_Arduino_Library-itwocdefault/src$ echo "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," | sed 's/,//g' | wc -m
69
./Arduino/libraries/SparkFun_ATECCX08a_Arduino_Library-itwocdefault/src$ echo "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," | sed 's/,//g' | wc -m
69
(running the heltec esp32)
Serial Number: 01238B933F8B73D0EE
Rev Number: 00005000
Config Zone: Locked
Data/OTP Zone: Locked
Data Slot 0: Locked
Print this before recieving the response data
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,
Print this if I get past response Data
print this for checking the CRC count
countGlobal: 0x43
count heard from IC (inpuBuffer[0]): 0x43
CRC[0] Calc: 0xD8
CRC[1] Calc: 0x64
This device's Public Key:
uint8_t publicKey[64] = {
0xF9, 0xC3, 0x6F, 0x89, 0x64, 0x62, 0x33, 0x78, 0xBD, 0xC0, 0x68, 0xD4, 0xBC, 0xE0, 0x7E, 0xD1,
0x7C, 0x8F, 0xA4, 0x86, 0xF9, 0xAC, 0x0C, 0x26, 0x13, 0xCA, 0x3C, 0x8C, 0x30, 0x6D, 0x7B, 0xB6,
0x1C, 0xD3, 0x67, 0x17, 0xB8, 0xAC, 0x5E, 0x4F, 0xEA, 0x8A, 0xD2, 0x3D, 0xC8, 0xD0, 0x78, 0x3C,
0x23, 0x18, 0xEE, 0x4A, 0xD7, 0xA8, 0x0D, 0xB6, 0xE0, 0x02, 0x6A, 0xD0, 0xB0, 0x72, 0xA2, 0x4F
};
(CubeCell)
Serial Number: 01238B933F8B73D0EE
Rev Number: 00005000
Config Zone: Locked
Data/OTP Zone: Locked
Data Slot 0: Locked
Print this before recieving the response data
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,
Print this if I get past response Data
print this for checking the CRC count
countGlobal: 0x43
count heard from IC (inpuBuffer[0]): 0x43
CRC[0] Calc: 0x6E
CRC[1] Calc: 0xCC
Message CRC Error
Failure to generate This device's Public Key
trying on a Heltec LoRa ESP32, output:
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (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:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Successful wakeUp(). I2C connections are good.
Serial Number: 01238B933F8B73D0EE
Rev Number: 00005000
Config Zone: Locked
Data/OTP Zone: Locked
Data Slot 0: Locked
This device's Public Key:
uint8_t publicKey[64] = {
0xF9, 0xC3, 0x6F, 0x89, 0x64, 0x62, 0x33, 0x78, 0xBD, 0xC0, 0x68, 0xD4, 0xBC, 0xE0, 0x7E, 0xD1,
0x7C, 0x8F, 0xA4, 0x86, 0xF9, 0xAC, 0x0C, 0x26, 0x13, 0xCA, 0x3C, 0x8C, 0x30, 0x6D, 0x7B, 0xB6,
0x1C, 0xD3, 0x67, 0x17, 0xB8, 0xAC, 0x5E, 0x4F, 0xEA, 0x8A, 0xD2, 0x3D, 0xC8, 0xD0, 0x78, 0x3C,
0x23, 0x18, 0xEE, 0x4A, 0xD7, 0xA8, 0x0D, 0xB6, 0xE0, 0x02, 0x6A, 0xD0, 0xB0, 0x72, 0xA2, 0x4F
};
uint8_t message[32] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
};
uint8_t signature[64] = {
0x98, 0x6F, 0xA0, 0x9E, 0x38, 0x9B, 0xFA, 0x16, 0x0D, 0xF1, 0x01, 0x64, 0x57, 0xC9, 0x03, 0x11,
0x4A, 0x0C, 0x36, 0xC5, 0xB6, 0xE0, 0x33, 0x02, 0x1A, 0xD3, 0x2A, 0x1D, 0x75, 0x54, 0x47, 0xFB,
0xB2, 0x11, 0x0B, 0xB9, 0x96, 0xFA, 0x69, 0x80, 0x5B, 0x8F, 0x3C, 0x2D, 0xD6, 0x61, 0xCE, 0xFA,
0x27, 0xB1, 0xE0, 0xAB, 0xDC, 0x4B, 0xA8, 0xB3, 0x59, 0xF9, 0x5A, 0xB7, 0x82, 0x77, 0xF4, 0x89
};
Try:
boolean ATECCX08A::updateRandom32Bytes(boolean debug)
byte ATECCX08A::getRandomByte(boolean debug)
(on cubecell)
Beginning of update random 32 bytes
inputBuffer: 23,21,3E,38,1B,B7,7B,B3,C,10,DE,E3,E5,2,5C,32,80,6F,61,C1,D0,74,8,F4,D1,83,18,CA,EA,57,0,F5,26,64,FF,
countGlobal: 0x23
count heard from IC (inpuBuffer[0]): 0x23
CRC[0] Calc: 0x13
CRC[1] Calc: 0xE7
Message CRC Error
End of update random 32 bytes
(on heltec esp32)
Beginning of update random 32 bytes
inputBuffer: 23,98,C4,29,3B,71,71,1,19,FB,95,3E,13,84,97,C1,6A,3B,AA,1B,F8,D3,24,11,D6,63,F7,51,14,D9,FB,6A,9,2C,CB,
countGlobal: 0x23
count heard from IC (inpuBuffer[0]): 0x23
CRC[0] Calc: 0x2C
CRC[1] Calc: 0xCB
random32Bytes: 98,C4,29,3B,71,71,1,19,FB,95,3E,13,84,97,C1,6A,3B,AA,1B,F8,D3,24,11,D6,63,F7,51,14,D9,FB,6A,9,
End of update random 32 bytes
CRC transmission to ATECC508A:
https://cdn.sparkfun.com/assets/learn_tutorials/1/0/0/3/Microchip_ATECC508A_Datasheet.pdf (sec 6.2, pg 42)
Trying a second cubecell with the same cryptochip
Beginning of update random 32 bytes
inputBuffer: 23,AF,1B,7A,BC,57,96,27,F5,A1,66,8D,4,C3,53,A6,31,3,CC,8B,6E,C6,72,A9,91,57,B7,82,8,21,91,AF,3F,5E,FF,
countGlobal: 0x23
count heard from IC (inpuBuffer[0]): 0x23
CRC[0] Calc: 0x1A
CRC[1] Calc: 0xDC
Message CRC Error
Print this before recieving the response data
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,
Print this if I get past response Data
print this for checking the CRC count
countGlobal: 0x43
count heard from IC (inpuBuffer[0]): 0x43
CRC[0] Calc: 0x6E
CRC[1] Calc: 0xCC
Message CRC Error
Failure to generate This device's Public Key
See ardunio and cubecell compatibility ??? HelTecAutomation/CubeCell-Arduino#28 (for heltec esp32 and ardunio compatibility)
try this part of the SparkFun code??
"/** \brief
cleanInputBuffer()
This function sets the entire inputBuffer to 0xFFs.
It is helpful for debugging message/count/CRCs errors.
*/
void ATECCX08A::cleanInputBuffer()
{
for (int i = 0; i < sizeof(inputBuffer) ; i++)
{
inputBuffer[i] = 0xFF;
}
}"
friend
"It could be the board library or it could be my code. It is not the physical wiring because i do get something through.
My guess it is about the timing or the baud rate or it is something in the board library telling it to do something wrong."
"maybe it is the board configuration file"
and it has the same error on both cubecells
what is the timing on the cubcell? Is there a crystal? Does the cubecell set the clock or does the cryptochip set the clock? (master-slave) --- questions of friend.
I wonder if the serial.flush() issue is related to your issue.
HelTecAutomation/CubeCell-Arduino#118
here is a link to the wire.cpp library that may be of concern?
The ESP32 appears to use esp32-hal-i2c.h for the error codes, but the Cubcell appears to use all sorts of weird things for i2c. There is something custom for every sensor? Do I need something custom for the cryptochip? see; https://github.com/bshambaugh/heltecesp32andCubeCell_Wire/
I2c connection
https://www.best-microcontroller-projects.com/i2c-tutorial.html
https://learn.sparkfun.com/tutorials/i2c/all
https://i2c.info/i2c-bus-specification
How do I set the I2c speed?
I solved the problem. I it is described here: http://community.heltec.cn/t/debugging-faulty-cubecell-i2c-connection-to-cryptographic-authentication-chip-atecc508a/2300
/home/ubuntu/Arduino/libraries/SparkFun_ATECCX08a_Arduino_Library-Aug26 { I modified this library} ... I need to rename the .cpp and header files.
in Wire.cpp
I2C_ERROR_NO_BEGIN; // no begin, not transmitting