arduino_uip
arduino_uip copied to clipboard
Seg fault in another library when EthernetClient is initialised
I am getting a very mysterious error, while using a different library (AESlib.h), I was getting a seg fault when using one particular function (aes_cbc_enc). At first I thought it may be an error in that library, but I discovered that the error disappears when I comment out the line EthernetClient client
, or even if I use the built in Arduino Ethernet.h.
Obviously I can't be sure which library is causing the error. In fact, I'm not even certain how to properly debug this library or further probe the cause of this error. Any help/advice would be appreciated.
#include <Arduino.h>
#include <AESLib.h>
#include <SPI.h>
#include <UIPEthernet.h>
//#include <Ethernet.h>
const uint8_t key[16] = {'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'};
// Comment this out and it works
EthernetClient client;
void setup() {
Serial.begin(9600);
cbcTest();
}
void loop() {}
void cbcTest() {
Serial.println("Entered cbcTest()");
uint16_t dataLength = 16;
char data[] = "abcdefghijklmnop";
uint8_t iv[16] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'};
Serial.print("Plaintext: "); Serial.write(data, dataLength); Serial.println("");
Serial.print("key: "); Serial.write(key, 16); Serial.println("");
Serial.print("IV: "); Serial.write(iv, 16); Serial.println("");
Serial.println("If it stops here, it has frozen");
delay(1000);
aes128_cbc_enc(key, iv, data, dataLength);
Serial.print("Ciphertext: "); Serial.write(data, dataLength); Serial.println("");
delay(100);
Serial.println("Finished cbcTest() without seg fault");
delay(100);
}
Running on a mega and using the 1.09ext version of the library