arduino-libraries / ArduinoECCX08

76 stars 49 forks source link

Teensy 4.0 and ATECC608 #36

Closed gannaramu closed 2 years ago

gannaramu commented 2 years ago

Hi Team, I know this library was intended for NINO devices. but I am trying to use it with Teensy4.0. Initially, I faced the below issue

lib\ArduinoECCX08\src\ECCX08.cpp: In member function 'int ECCX08Class::receiveResponse(void*, size_t)':
lib\ArduinoECCX08\src\ECCX08.cpp:724:80: error: call of overloaded 'requestFrom(uint8_t, size_t, bool)' is ambiguous
   while (_wire->requestFrom((uint8_t)_address, (size_t)responseSize, (bool)true) != responseSize && retries--);
                                                                                ^
In file included from C:\Users\ganna\.platformio\packages\framework-arduinoteensy\libraries\Wire/Wire.h:26:0,
                 from lib\ArduinoECCX08\src\ECCX08.h:24,
                 from lib\ArduinoECCX08\src\ECCX08.cpp:22:
C:\Users\ganna\.platformio\packages\framework-arduinoteensy\libraries\Wire/WireIMXRT.h:90:10: note: candidate: uint8_t TwoWire::requestFrom(uint8_t, uint8_t, uint8_t)
  uint8_t requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop);
          ^
C:\Users\ganna\.platformio\packages\framework-arduinoteensy\libraries\Wire/WireIMXRT.h:94:10: note: candidate: uint8_t TwoWire::requestFrom(int, int, int)
  uint8_t requestFrom(int address, int quantity, int sendStop) {
          ^
*** [.pio\build\teensy40\libc4b\ArduinoECCX08\ECCX08.cpp.o] Error 1

which I was able to fix by changing line724

  while (_wire->requestFrom((uint8_t)_address, (size_t)responseSize, (uint8_t)1) != responseSize && retries--);

But the Random number example always returns the same value :

--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
SN: 01234E5F5936FF28EE
Random number = 13312 
Random number = 13312
Random number = 13312

After a little bit of debugging, I realized the wakeup function returns zero after the first instance inside ECCX08.cpp at https://github.com/arduino-libraries/ArduinoECCX08/blob/ee4523d7802fdc4fc9347d2794bd9411ab1c1cbb/src/ECCX08.cpp#L135-L139

Any help is appreciated

gannaramu commented 2 years ago

The issue was with the Wire library buffer length which is default at 32 . I was able to solve the issue by increasing the default buffer_length to 256

https://github.com/PaulStoffregen/Wire/pull/36/files