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

Cannot enable WPA2 Enterprise using arduino libraries #1744

Closed
daniel-dsouza opened this issue Aug 9, 2018 · 6 comments
Closed

Cannot enable WPA2 Enterprise using arduino libraries #1744

daniel-dsouza opened this issue Aug 9, 2018 · 6 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@daniel-dsouza
Copy link

daniel-dsouza commented Aug 9, 2018

Hardware:

Board: Adafruit Feather ESP32
Core Installation/update date: ?8/9/2018?
IDE name: Arduino IDE and Platform.io
Flash Frequency: 80Mhz
Upload Speed: 921600

Description:

Fails on esp_wifi_sta_wpa2_ent_enable(&config);

Sketch:

#include "esp_wpa2.h"
#include <WiFi.h>

const char* ssid = "eduroam";
const char* eap_username = "hunter";
const char* eap_password = "hunter123";

void setup() {
  Serial.begin(115200);
  delay(10);

  Serial.print("Connecting to network: ");
  Serial.println(ssid);

  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)eap_username, strlen(eap_username));
  esp_wifi_sta_wpa2_ent_set_username((uint8_t *)eap_username, strlen(eap_username));
  esp_wifi_sta_wpa2_ent_set_password((uint8_t *)eap_password, strlen(eap_password));
  esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
  esp_wifi_sta_wpa2_ent_enable(&config);

  WiFi.begin(ssid);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address set: ");
  Serial.println(WiFi.localIP()); //print LAN IP
}

void loop() {}

Debug Messages:

Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400e6f51  PS      : 0x00060530  A0      : 0x800d1ca6  A1      : 0x3ffb1f40  
A2      : 0x3ffb1f74  A3      : 0x3ffc5890  A4      : 0x00000000  A5      : 0x526312a6  
A6      : 0x00000001  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x3ffb1f40  
A10     : 0x3ffb23cc  A11     : 0x3f4010a5  A12     : 0x0000000a  A13     : 0x3ffb23d6  
A14     : 0x00000079  A15     : 0x00000033  SAR     : 0x00000018  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000138  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0xffffffff  

Backtrace: 0x400e6f51:0x3ffb1f40 0x400d1ca3:0x3ffb1f70 0x4012ad1f:0x3ffb1fa0


PC: 0x400e6f51
EXCVADDR: 0x00000138

Decoding stack results
0x400d1ca3: setup() at /home/hunter/Documents/Arduino/sketch_aug09a/sketch_aug09a.ino line 24
0x4012ad1f: loopTask(void*) at /home/hunter/.arduino15/packages/esp32/hardware/esp32/1.0.0/cores/esp32/main.cpp line 15
@stickbreaker
Copy link
Contributor

This code is invalid.

#define EAP_USERNAME "usrname"
#define EAP_PASSWORD "hunter123"

    esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME));
    esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME));
    esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));

The define statement is just a substitution:

    esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)"usrname", strlen("usrname"));

with this type declaration you are telling the compiler to treat the first four letters of "usrn" as the value of a pointer to a cstring of characters.

the correct way would be to define a variable:

const char* eap_username = "usrname";
    esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)eap_usernam, strlen(eap_username));

Chuck.

@daniel-dsouza
Copy link
Author

daniel-dsouza commented Aug 9, 2018

@stickbreaker

Thanks for finding that bug. I have updated my original post with the revised code. However the same error persists.

I am trying to follow the sample WPA2 enterprise sample

@stickbreaker
Copy link
Contributor

@daniel-dsouza

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

LoadProhibited is telling you that an invalid memory address was access (READ). Usually this means that some pointer is loaded with an invalid value,

esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
  esp_wifi_sta_wpa2_ent_enable(&config);

This is how WPA2_CONFIG_INIT_DEFAULT() is defined in esp32_wpa2.h

#include "esp_err.h"
#include "esp_wifi_crypto_types.h"

#ifdef __cplusplus
extern "C" {
#endif

extern const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs;

typedef struct {
    const wpa2_crypto_funcs_t *crypto_funcs;
}esp_wpa2_config_t;

#define WPA2_CONFIG_INIT_DEFAULT() { \
    .crypto_funcs = &g_wifi_default_wpa2_crypto_funcs \
}

It looks to me that

extern const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs;

May not have been initialized before you use it. It looks too me that you have skipped a few steps in the initialization sequence. I have no knowledge how to correctly use WPA2, so I can't be of any more help, Sorry.

Chuck.

@vitcon-iot
Copy link

WiFi.mode() is now required in order to init the hardware.

#1618
#1618 (comment)

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

3 participants