Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RNG Watchdog compilation error for Arduino Uno WiFi rev2 #49

Open
JurriaanD opened this issue Feb 23, 2020 · 1 comment
Open

RNG Watchdog compilation error for Arduino Uno WiFi rev2 #49

JurriaanD opened this issue Feb 23, 2020 · 1 comment

Comments

@JurriaanD
Copy link

Hi,
I've been using your library on an Arduino Uno and everythings works great (thank you!). However, when I try to compile for the Arduino Uno WiFi rev2, I get a long list of errors from the RNG.cpp file. (error log below). The lines mentioned in the error log are related to the RNG watchdog. I found #31 and the suggested fix did stop the compiler errors, but I'm not sure what noise source to replace it with/how to do it.

Steps to reproduce:

  • Download latest Arduino IDE (1.8.12) and library (0.2.0) version
  • Set targeted board to Arduino Uno WiFi rev2
  • Try to compile the TestCurve25519 example

This happens on Windows 10 as well as Arch Linux.

Full error log (pastebin)

Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno WiFi Rev2, ATMEGA328"

[System data, see pastebin]

C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp: In function 'void WDT_vect()':

C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:239:27: error: 'TCNT0' was not declared in this scope
     unsigned char value = TCNT0;
                           ^~~~~
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:239:27: note: suggested alternative: 'TCA0'
     unsigned char value = TCNT0;
                           ^~~~~
                           TCA0
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp: In destructor 'RNGClass::~RNGClass()':
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:288:5: error: 'MCUSR' was not declared in this scope
     MCUSR &= ~(1 << WDRF);
     ^~~~~
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:288:21: error: 'WDRF' was not declared in this scope
     MCUSR &= ~(1 << WDRF);
                     ^~~~
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:288:21: note: suggested alternative: 'DDRD'
     MCUSR &= ~(1 << WDRF);
                     ^~~~
                     DDRD
In file included from C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:37:0:
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:291:30: error: 'WDCE' was not declared in this scope
     _WD_CONTROL_REG |= (1 << _WD_CHANGE_BIT) | (1 << WDE);
                              ^
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:291:30: note: suggested alternative: 'ADC0'
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:291:54: error: 'WDE' was not declared in this scope
     _WD_CONTROL_REG |= (1 << _WD_CHANGE_BIT) | (1 << WDE);
                                                      ^~~
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:291:54: note: suggested alternative: 'WDT'
     _WD_CONTROL_REG |= (1 << _WD_CHANGE_BIT) | (1 << WDE);
                                                      ^~~
                                                      WDT
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:292:23: error: no match for 'operator=' (operand types are 'WDT_t {aka WDT_struct}' and 'int')
     _WD_CONTROL_REG = 0;
                       ^
In file included from c:\users\jurriaan\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:677:0,
                 from c:\users\jurriaan\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
                 from C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\utility/ProgMemUtil.h:27,
                 from C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:27:
c:\users\jurriaan\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\iom4809.h:2054:16: note: candidate: WDT_struct& WDT_struct::operator=(const WDT_struct&)
 typedef struct WDT_struct
                ^~~~~~~~~~
c:\users\jurriaan\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\iom4809.h:2054:16: note:   no known conversion for argument 1 from 'int' to 'const WDT_struct&'
c:\users\jurriaan\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\iom4809.h:2054:16: note: candidate: WDT_struct& WDT_struct::operator=(WDT_struct&&)
c:\users\jurriaan\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\iom4809.h:2054:16: note:   no known conversion for argument 1 from 'int' to 'WDT_struct&&'
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp: In member function 'void RNGClass::begin(const char*)':
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:485:5: error: 'MCUSR' was not declared in this scope
     MCUSR &= ~(1 << WDRF);
     ^~~~~
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:485:21: error: 'WDRF' was not declared in this scope
     MCUSR &= ~(1 << WDRF);
                     ^~~~
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:485:21: note: suggested alternative: 'DDRD'
     MCUSR &= ~(1 << WDRF);
                     ^~~~
                     DDRD
In file included from C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:37:0:
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:489:30: error: 'WDCE' was not declared in this scope
     _WD_CONTROL_REG |= (1 << _WD_CHANGE_BIT) | (1 << WDE);
                              ^
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:489:30: note: suggested alternative: 'ADC0'
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:489:54: error: 'WDE' was not declared in this scope
     _WD_CONTROL_REG |= (1 << _WD_CHANGE_BIT) | (1 << WDE);
                                                      ^~~
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:489:54: note: suggested alternative: 'WDT'
     _WD_CONTROL_REG |= (1 << _WD_CHANGE_BIT) | (1 << WDE);
                                                      ^~~
                                                      WDT
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:490:29: error: 'WDIE' was not declared in this scope
     _WD_CONTROL_REG = (1 << WDIE);
                             ^~~~
C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto\src\RNG.cpp:490:29: note: suggested alternative: 'WDT'
     _WD_CONTROL_REG = (1 << WDIE);
                             ^~~~
                             WDT
"C:\\Users\\Jurriaan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10812 -DARDUINO_AVR_UNO_WIFI_REV2 -DARDUINO_ARCH_MEGAAVR -DUNO_WIFI_REV2_328MODE -DMILLIS_USE_TIMERB3 "-IC:\\Users\\Jurriaan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.5\\cores\\arduino/api/deprecated" "-IC:\\Users\\Jurriaan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.5\\cores\\arduino" "-IC:\\Users\\Jurriaan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.5\\variants\\uno2018" "-IC:\\Users\\Jurriaan\\Documents\\Arduino\\libraries\\Crypto\\src" "C:\\Users\\Jurriaan\\Documents\\Arduino\\libraries\\Crypto\\src\\XTS.cpp" -o "C:\\Users\\Jurriaan\\AppData\\Local\\Temp\\arduino_build_653946\\libraries\\Crypto\\XTS.cpp.o"
Using library Crypto at version 0.2.0 in folder: C:\Users\Jurriaan\Documents\Arduino\libraries\Crypto 
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.
@rweather
Copy link
Owner

According to the web page for the Uno+Wifi rev2, it includes a "ECC608 crypto chip accelerator" for security purposes. According to the web page for the ECC608, it includes a random number generator: https://www.microchip.com/wwwproducts/en/ATECC608A.

If you can figure out how to access the ECC608's random number functionality from a sketch, then you might be able to use that as a noise source for the RNG class. I'm not familiar with that chip myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants