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

(WIP) update to latest nonos-sdk (SDK3) #4853

Open
wants to merge 8 commits into
base: master
from

Conversation

Projects
None yet
8 participants
@d-a-v
Copy link
Collaborator

d-a-v commented Jun 27, 2018

This PR reflects espressif/ESP8266_NONOS_SDK@89920dc (v2.2.0-28-g89920dc)

  • includes new syscalls wifi_{get,set}_sleep_level() and wifi_{get,set}_listen_interval()
  • API change: user must select between open/wep or WPA/WPA2

Now open or wep network must be selected before connecting.
This is introduced by struct station_config.open_and_wep_mode_disable (this new entry was forgotten in the former PR). This value is currently set to true by default.

Opened questions:

  • open_and_wep_mode_disable can be set to false if the password is empty (is an empty password is only allowed when using open APs ?)
  • Is there a way to detect a wep password that cannot be a wpa password ? In that case this new entry can be automagically set, otherwise we might need to introduce something like WiFi.wepAllowed().
  • Should we get rid of unused libraries ?
libgcc.a
libat.a
libupgrade.a
libjson.a
libssl.a
libdriver.a
liblwip_536.a
libpwm.a

(former PR #4806 has links about unsolved eduroam issue)

@d-a-v d-a-v requested review from igrr , earlephilhower and devyte Jun 27, 2018

@devyte

This comment has been minimized.

Copy link
Collaborator

devyte commented Jun 27, 2018

Connection to wep routers should probably be disallowed, it's not secure. I believe that's the current case in our core.

@@ -127,6 +127,7 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
}

conf.threshold.rssi = -127;
conf.open_and_wep_mode_disable = true;

This comment has been minimized.

@devyte

devyte Jun 27, 2018

Collaborator

Maybe this new call should depend on whether passphrase is empty?

This comment has been minimized.

@d-a-v

d-a-v Jun 27, 2018

Author Collaborator

Yes, but wep should not be left aside even if it is obsolete. People sometimes need to experiment with old hardware and at the same time are living in open country.

typedef enum {
MIN_SLEEP_T,
MAX_SLEEP_T
} sleep_level_t;

This comment has been minimized.

@devyte

devyte Jun 27, 2018

Collaborator

Is there info about what this sleep level means?

This comment has been minimized.

@d-a-v

d-a-v Jun 27, 2018

Author Collaborator

Question already asked, no answer yet. Reading actual values and playing with them may help #2330.

bool wifi_set_sleep_level(sleep_level_t level);
sleep_level_t wifi_get_sleep_level(void);

bool wifi_set_listen_interval(uint8 interval);

This comment has been minimized.

@devyte

devyte Jun 27, 2018

Collaborator

Is there info about what this listen interval means, and the units of the argument (e.g. ms)?

This comment has been minimized.

@d-a-v

d-a-v Jun 27, 2018

Author Collaborator

No doc to my knowledge yet.

@@ -0,0 +1,71 @@
#!/bin/bash

This comment has been minimized.

@devyte

devyte Jun 27, 2018

Collaborator

Some comments explaining this script would help.

This comment has been minimized.

@d-a-v

d-a-v Jun 27, 2018

Author Collaborator

moved to #4855 (improved and documented)

@d-a-v d-a-v force-pushed the d-a-v:fw branch from bfe530c to 12e99ef Jun 27, 2018

@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jun 28, 2018

@victorclaessen

Following your recent message in espressif's BBS about WPA2, please try this pull-request which contains the latest version of the nonos-sdk.
Comments are welcome.

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jun 29, 2018

As described here (and the next post) I now get this error "there is no poison after the block":

ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v00000000
~ld

SDK:3.0.0-dev(c0f7b44)/Core:win-2.5.0-dev/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-13-g163bb82)/BearSSL:94e9704
WPA2 ENTERPRISE VERSION: [v2.0] enable
scandone

Waiting for connection and IP Address from DHCP
wifi evt: 8
wifi evt: 2
.scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt
EAP-MSCHAPV2: RX identifier 3 mschapv2_id 3
EAP-MSCHAPV2: Generate Challenge Response
EAP-MSCHAPV2: RX identifier 4 mschapv2_id 3
there is no poison after the block. Expected poison address: 0x41491208, actual data: 0x0e 0x00 0x00 0x00
block start: 3fff10bc

Panic C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc\umm_malloc.c:861 check_poison_block

ctx: sys
sp: 3fffec50 end: 3fffffb0 offset: 01b0

>>>stack>>> 
Decoding 67 results
0x40204af6: printf at /Users/igrokhotkov/e/newlib-xtensa/xtensa-lx106-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/printf.c line 61
0x40244394: sleep_reset_analog_rtcreg_8266 at ?? line ?
0x401004db: check_poison at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 861
:  (inlined by) check_poison_block at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 851
0x4010020c: _umm_free at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1295
0x4010020c: _umm_free at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1295
0x4010053a: get_unpoisoned at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 946
0x401009dc: free at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1742
0x4022d8e0: _base64_decode at ?? line ?
0x40106944: vPortFree at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/heap.c line 59
0x4022581a: wpa2_sm_rx_eapol at ?? line ?
0x4022582e: wpa2_sm_rx_eapol at ?? line ?
0x40225869: wpa2_sm_rx_eapol at ?? line ?
0x40225434: wpa2_sm_rx_eapol at ?? line ?
0x4021cccd: sta_input at ?? line ?
0x40230d43: pp_tx_idle_timeout at ?? line ?
0x40230603: ppPeocessRxPktHdr at ?? line ?
0x40104740: call_user_start_local at ?? line ?
0x40104746: call_user_start_local at ?? line ?
0x4010000d: call_user_start at ?? line ?
0x40100a84: cont_ret at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/cont.S line 142
0x40100a31: cont_continue at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/cont.S line 51
0x40101232: pp_post at ?? line ?
0x40104620: lmacTxFrame at ?? line ?
0x4010383f: lmacRecycleMPDU at ?? line ?
0x40103ca2: lmacRecycleMPDU at ?? line ?
0x40103786: lmacProcessTxSuccess at ?? line ?
0x401025fb: wDev_ProcessFiq at ?? line ?
0x401022f8: wDev_ProcessFiq at ?? line ?
0x40100439: check_poison_block at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 842
0x40104f19: ets_timer_disarm at ?? line ?
0x40245d80: sleep_reset_analog_rtcreg_8266 at ?? line ?
0x40240000: phy_gpio_cfg at ?? line ?
0x40241c31: ram_set_txbb_atten at ?? line ?
0x4023e77a: tx_atten_set_interp at ?? line ?
0x40231763: pp_attach at ?? line ?
0x402317b2: pp_attach at ?? line ?
0x4010137b: ppCalFrameTimes at ?? line ?
0x4023086b: ppTxPkt at ?? line ?
0x40219d6b: ieee80211_send_probereq at ?? line ?
0x4021ddd4: cnx_start_handoff_cb at ?? line ?
0x4021bb93: scan_remove_probe_ssid at ?? line ?
0x4021b764: scan_start at ?? line ?
0x4021ddd4: cnx_start_handoff_cb at ?? line ?
0x4010505c: ets_timer_arm_new at ?? line ?
0x4021d76b: chm_start_op at ?? line ?
0x4021ddd4: cnx_start_handoff_cb at ?? line ?
0x4021ddd4: cnx_start_handoff_cb at ?? line ?
0x4021d6e0: chm_start_op at ?? line ?
0x4021b754: scan_start at ?? line ?
0x4021b728: scan_start at ?? line ?
0x4021b6f3: scan_start at ?? line ?
0x4021bca4: scan_remove_probe_ssid at ?? line ?
0x4010505c: ets_timer_arm_new at ?? line ?
0x40203398: esp_yield at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/core_esp8266_main.cpp line 91
0x402014e7: delay at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/core_esp8266_wiring.c line 51
0x40202716: setup at C:\Users\claessen\Documents\Arduino\wpa2/wpa2.ino line 45


@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jun 29, 2018

Heap is corrupted.
That may not be espressif's fault,
@earlephilhower what do you think of this call stack ?

@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jun 29, 2018

@victorclaessen

I'm not a specialist in this area. I think the following patch reverts to using the original bss stack (at the price of 4KB in our precious heap).

Can you try replacing the code around app_entry() in cores/esp8266/core_esp8266_main.cpp L151 with this ?
Current master is using 1 for EXTRA_4K_HEAP, I propose you to try with 0 and check if heap poisoning still happens.

(ref: #4622)

/* This is the entry point of the application.
 * It gets called on the default stack, which grows down from the top
 * of DRAM area.
 * .bss has not been zeroed out yet, but .data and .rodata are in place.
 * Cache is not enabled, so only ROM and IRAM functions can be called.
 * Peripherals (except for SPI0 and UART0) are not initialized.
 * This function does not return.
 */
#define EXTRA_4K_HEAP 0

#if !EXTRA_4K_HEAP
cont_t g_cont __attribute__ ((aligned (16)));
#endif

extern "C" void ICACHE_RAM_ATTR app_entry(void)
{
#if EXTRA_4K_HEAP
    /* Allocate continuation context on this stack, and save pointer to it. */
    cont_t s_cont __attribute__((aligned(16)));
    g_pcont = &s_cont;
#else
    g_pcont = &g_cont;
#endif
    /* Call the entry point of the SDK code. */
    call_user_start();
}

Reference: (@Adam5Wu)

If we do this, then every time we upgrade SDK version, we need to literally run a set of regression tests on the actual hardware (there is not esp8266 hardware emulators, is there?) just for this feature, otherwise it may be too unreliable to be usable.

@earlephilhower @Adam5Wu @igrr Please correct me if I'm going in the wrong direction

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jun 29, 2018

Ok, the error is the same but the stack is now considerably shorter.

SDK:3.0.0-dev(c0f7b44)/Core:win-2.5.0-dev/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-13-g163bb82)/BearSSL:94e9704
WPA2 ENTERPRISE VERSION: [v2.0] enable
scandone

Waiting for connection and IP Address from DHCP
wifi evt: 8
wifi evt: 2
.scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt 
EAP-MSCHAPV2: RX identifier 3 mschapv2_id 3
EAP-MSCHAPV2: Generate Challenge Response
EAP-MSCHAPV2: RX identifier 4 mschapv2_id 3
there is no poison after the block. Expected poison address: 0x41492238, actual data: 0x0d 0x00 0x00 0x00
block start: 3fff20ec

Panic C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc\umm_malloc.c:861 check_poison_block

ctx: sys 
sp: 3ffffc80 end: 3fffffb0 offset: 01b0

>>>stack>>>
Decoding 21 results
0x40204af6: printf at /Users/igrokhotkov/e/newlib-xtensa/xtensa-lx106-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/printf.c line 61
0x40244394: sleep_reset_analog_rtcreg_8266 at ?? line ?
0x401004db: check_poison at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 861
:  (inlined by) check_poison_block at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 851
0x4010020c: _umm_free at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1295
0x4010020c: _umm_free at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1295
0x4010053a: get_unpoisoned at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 946
0x401009dc: free at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1742
0x4022d8e0: _base64_decode at ?? line ?
0x4010693c: vPortFree at C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/heap.c line 59
0x4022581a: wpa2_sm_rx_eapol at ?? line ?
0x4022582e: wpa2_sm_rx_eapol at ?? line ?
0x40225869: wpa2_sm_rx_eapol at ?? line ?
0x40225434: wpa2_sm_rx_eapol at ?? line ?
0x4021cccd: sta_input at ?? line ?
0x40230d43: pp_tx_idle_timeout at ?? line ?
0x40230603: ppPeocessRxPktHdr at ?? line ?
@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jun 29, 2018

The "poison" is a magic value used by the allocator (new/malloc) at the beginning (or end) of allocated RAM blocks to check whether allocation mapping is valid. 0x41492238 is not a valid address since it's in the flash area (or beyond). So probably a malloc's block size is corrupted and the checker fails.

This could be a buffer overflow. The patch above seems to be (luckily :) useless but I personally still can't blame espressif at that point.

I only have WPA2 APs (apart from a TTLS/PAP WPA2-Enterprise network - eduroam - which does not work with the esp) and the new fw works with it, so I can't test right now with a WPA2-Enterprise network.

I think you really should reproduce your bug with the full native SDK alone outside from the arduino environment. Only if you manage to reproduce that with a native MCVE, espressif will be able to reproduce and fix. If the issue disappears with a native MCVE then we have to look for the source of the issue in the arduino core.

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jun 29, 2018

That goes somewhat beyond what I'm familiar with. I'm guessing that involves something like setting up a toolchain (https://github.com/pfalcon/esp-open-sdk) and using that to compile the flash firmware file?

@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jun 29, 2018

I understand :)
Their compiler is at http://downloads.espressif.com/FB/ESP8266_GCC.zip (according to their doc https://www.espressif.com/sites/default/files/documentation/2a-esp8266-sdk_getting_started_guide_en.pdf).
However you can safely use the arduino core compiler. Just set properly your PATH.

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jun 29, 2018

That last comment leaves me more confused than before. I can use the Arduino compiler - from the arduino IDE? - but what do I have to set the path to?

@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jun 29, 2018

The most simple is to follow their procedure and to use their compiler since it is documented.

To answer your question, the esp8266/Arduino core's compiler is located in tools/xtensa-lx106-elf/. The PATH has to be set on /full/path/to/tools/xtensa-lx106-elf/bin.

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Jul 6, 2018

@victorclaessen Did you have a chance to try out the whole standalone native SDK method as @d-a-v
suggested? It sounded a bit complicated for my level, so wanted to check with you first. Also, if I were to test this PR, how would I get the files? is it in teh staging version? I installed esp8266 via boards manager, and I am not sure how to update the files with those from this PR. much thanks for info.

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jul 6, 2018

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Jul 6, 2018

Aaaah! Seems like we are so close to getting this working but far away :( I will try to read upon this and see if i can figure it out too. Hopefully one of the main guys would get a moment to help us out. :)

@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jul 7, 2018

@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jul 9, 2018

Here's a command-line walkthrough with a fresh esp-nonos-sdk. Tested with linux.
You need make with windows (you may have it coming with git).

  • set a path to arduino's gcc
    linux: export PATH=/path/to/esp8266/Arduino/tools/xtensa-lx106-elf/bin:$PATH
    windows (maybe): set PATH=c:\path\to\esp8266\Arduino\tools\xtensa-lx106-elf\bin;%PATH%
  • copy libhal.a from esp8266/Arduino/tools/sdk/lib/ into esp-nonos-sdk/lib/ directory
  • copy an example to the root directory of esp-nonos-sdk:
    like: esp-nonos-sdk/example/wpa2_enterprise/ to esp-nonos-sdk/wpa2_enterprise/
    (which is with linux: cd /path/to/ESP-NONOS-SDK; cp -a example/wpa2_enterprise .)
  • change dir to esp-nonos-sdk/wpa2_enterprise/
  • make COMPILE=gcc
!!!
No boot needed.
Generate eagle.flash.bin and eagle.irom0text.bin successully in folder bin.
eagle.flash.bin-------->0x00000
eagle.irom0text.bin---->0x10000
!!!
  • The above files are stored into esp-nonos-sdk/bin/
  • Flash them with your preferred esptool (esp8266/Arduino's one is in tools/esptool/)

edit: We luckily have arduino for the simplicity of installation, examples, libraries, compilation and flashing :)

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jul 11, 2018

Thanks for attempting to hold my hand and walk me through it. However, I still managed to trip over something...

claessen@machine:~/ESP8266_NONOS_SDK/wpa2_enterprise$ make build=gcc
../../Makefile:34: warning: overriding recipe for target 'clean'
../Makefile:322: warning: ignoring old recipe for target 'clean'
make[1]: Entering directory '/home/claessen/ESP8266_NONOS_SDK/wpa2_enterprise/user'
../../../Makefile:34: warning: overriding recipe for target 'clean'
../../Makefile:322: warning: ignoring old recipe for target 'clean'
DEPEND: xt-xcc -M -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle -I ../../driver_lib/include user_main.c
../../../Makefile:34: warning: overriding recipe for target 'clean'
../../Makefile:322: warning: ignoring old recipe for target 'clean'
xt-xcc -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf  -DICACHE_FLASH   -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle -I ../../driver_lib/include  -o .output/eagle/debug/obj/user_main.o -c user_main.c
ar rcs  ru .output/eagle/debug/lib/libuser.a .output/eagle/debug/obj/user_main.o
ar: .output/eagle/debug/lib/libuser.a: No such file or directory
../../Makefile:394: recipe for target '.output/eagle/debug/lib/libuser.a' failed
make[1]: *** [.output/eagle/debug/lib/libuser.a] Error 1
make[1]: Leaving directory '/home/claessen/ESP8266_NONOS_SDK/wpa2_enterprise/user'
../Makefile:330: recipe for target '.subdirs' failed
make: *** [.subdirs] Error 2

Edit 1:
One thing I noticed is that it was using the wrong ar (from /usr/bin instead of the one from arduino/esp8266). I don't know if that makes much difference. I amended the PATH, but still ar seems to fail to make libuser.a. But why?

Edit 2: If I take out the "ru" argument, then it works. I had to make a lot of symlinks (from objcopy to xt-objcopy, etcetera, because those xt-prefixed binaries did not exist. I now have two eagle files. Let's see if I can flash it.

(By the way: I changed the SSID in the wpa2_enterprise example to eduroam and substituted some valid credentials.)

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jul 11, 2018

Ok I flashed both files to the ESP8266. Then after finding the baud rate (74880) I get this, repeating very fast.

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 26212, room 16
tail 4
chksum 0x89
load 0x3ffe8000, len 7524, room 4
tail 0
chksum 0xef
load 0x3ffe9d70, len 5808, room 8
tail 8
chksum 0x03
csum 0x03
rf_cal[0] !=0x05,is 0x00

I'm not sure what we've learned now. I hope this effort was in some way useful to you @d-a-v.

@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jul 11, 2018

Google with rf_cal[0] !=0x05 tells you to flash bin/esp_init_data_default.bin too.
The correct location is described in bin/at/README.md.
Seems to be 0x3fc000 for 4MB flash chips in non boot mode.

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jul 12, 2018

Thanks for the hint. The output is now:

scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt
pm open,type:2 0
state: 5 -> 0 (2)
rm 0
pm close 7
reconnect
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt
pm open,type:2 0
state: 5 -> 2 (7c0)
rm 0
pm close 7
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (4)
reconnect
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (4)
reconnect
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (4)
reconnect

(the last part scandone..reconnect keeps repeating).

Does this mean it connected succesfully?

Edit: I've tried adding a piece of code to tell me if I got an IP address, but the whole thing is sufficiently different from what I'm used to with the Arduino-interface that I've not been successful yet.

@d-a-v

This comment has been minimized.

Copy link
Collaborator Author

d-a-v commented Jul 12, 2018

Is it the WPA2 example ? (logs are different with my tests in espressif's issue, link from #4806, ...EAP-TTLS: Start...).
If the esp is keeping reconnecting, it means it does not connect.
Have you tried to perform a full erase before flashing ?

@victorclaessen

This comment has been minimized.

Copy link

victorclaessen commented Jul 12, 2018

@d-a-v d-a-v force-pushed the d-a-v:fw branch from 7e0dfb6 to 677323e Aug 24, 2018

@d-a-v d-a-v changed the title update to latest git version of nonos-sdk (SDK:3.0.0-dev(c0f7b44)) (WIP) update to latest nonos-sdk (SDK3) Aug 24, 2018

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Aug 27, 2018

@ustccw Hi, Just a quick question. On your hostapd.conf, you have

#interface=eth0

I don't see a line like

interface=wlan0

Which is what most online examples show when using hostapd. Is this intentional or do you have a different conf file that you used?

@ustccw

This comment has been minimized.

Copy link

ustccw commented Aug 28, 2018

@kapyaar hi, here are the hostapd setup way:

@ustccw

This comment has been minimized.

@ustccw

This comment has been minimized.

Copy link

ustccw commented Aug 28, 2018

@kapyaar about freeradius , i would try it some days later.

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Sep 3, 2018

@ustccw

I was able to follow your instructions and, YES the device connects to the AP, gets an IP as well.

pm open,type:2 0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (4)
reconnect
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0                                                                           
aid 1                                                                           
                                                                                
connected with myPiAP, channel 6                                                
dhcp client start...                                                            
cnt                                                                             
ip:192.168.5.187,mask:255.255.255.0,gw:192.168.5.1                              
clear wpa2 enterprise resource...                                               
WPA2 ENTERPRISE VERSION: [v2.0] disable                                         
wpa2 enterprise success! 

Definitely good news, but I guess you already know this will work :)
I hope you will be able to try out freeradius soon. As always, If you need any assistance with testing, let me know.

@devyte

This comment has been minimized.

Copy link
Collaborator

devyte commented Sep 4, 2018

CC @d-a-v

@kapyaar I've been following this, but I don't fully understand everything. Can you please provide a working example, including the server config, as well as condensed instructions? That would serve other users in the meantime, while the freeradius thing is explored.

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Sep 4, 2018

@devyte attaching a short write up and associated files. let me know if you need any further info.
ESP8266-wpa2-enterprise-hostapd.zip

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Sep 10, 2018

@ustccw Just checking back on this to see if you had any chances or visiting this again :)

@ustccw

This comment has been minimized.

Copy link

ustccw commented Sep 18, 2018

@kapyaar sorry that i am on a two more weeks business travel.
about freeradius, i mark this issue and link to inner, will do and update here later.

thanks

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Sep 18, 2018

@ustccw No worries, I really appreciate your response, and I will wait for your further updates

@zhxq

This comment has been minimized.

Copy link

zhxq commented Sep 22, 2018

@ustccw @kapyaar

I was able to follow your instructions and, YES the device connects to the AP, gets an IP as well.

pm open,type:2 0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (4)
reconnect
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0                                                                           
aid 1                                                                           
                                                                                
connected with myPiAP, channel 6                                                
dhcp client start...                                                            
cnt                                                                             
ip:192.168.5.187,mask:255.255.255.0,gw:192.168.5.1                              
clear wpa2 enterprise resource...                                               
WPA2 ENTERPRISE VERSION: [v2.0] disable                                         
wpa2 enterprise success! 

Definitely good news, but I guess you already know this will work :)
I hope you will be able to try out freeradius soon. As always, If you need any assistance with testing, let me know.

Just wonder if you can share your code here - I'm currently trying to connect to eduroam as well using the code d-a-v commented on 12 Jul, but I have no luck. My board is NodeMCU 1.0 (ESP-12E Module). As far as I know, my university is using PEAP as eduroam authorization method. I also changed nothing except changing the authentication info to suite my needs.
#define SSID "eduroam"
#define PASSWORD "" //(I believe this place should be blank, right?)
#define WPA2_USERNAME "mysusername@university.edu" //(changed to my university email)
#define WPA2_IDENTITY WPA2_USERNAME
#define WPA2_PASSWORD "mypassword" //(changed to my university password)

I tried to receive debug info from a 2x16 LCD screen, and I got basically "STA_CONNECTING" for station status. There is one time I received "STA_WRONGPWD" (when I was using 2.4.2, 2.5.0-dev has some problem with this, and I explained it below), but I'm really sure my password is correct (I connected eduroam with my iPhone and everything went well). Finally, after a long time of failure, I received "STATION_CONNECT_FAIL".

I really appreciate any help here - the hardware unit is fine (I tried to connect to a normal WPA2 network at home, and everything was fine). Just wonder if this is something wrong with my coding, or the SDK is still not updated yet. I just upgraded SDK today (2.5.0-dev), and I hope someone can give me some tips here...

I don't currently have a spare router for me to set up my own WPA-Enterprise network, so I hope you can share the code with us, along with your configurations and info about your boards/SDK version, etc.

----some updates:

I'm trying to use my computer in university now (my home does not have school network), and I used Wi-Fi debug level, then I see these exceptions from the output:

WPA2 ENTERPRISE VERSION: [v2.0] enable
Status: Fatal exception 28(LoadProhibitedCause):
epc1=0x402045ec, epc2=0x00000000, epc3=0x00000000, excvaddr=0x000000ff, depc=0x00000000

Exception (28):
epc1=0x402045ec epc2=0x00000000 epc3=0x00000000 excvaddr=0x000000ff depc=0x00000000

ctx: cont
sp: 3ffffca0 end: 3fffffc0 offset: 01a0

stack>>>
3ffffe40: feefeffe feefeffe feefeffe feefeffe
3ffffe50: feefeffe feefeffe feefeffe 3ffefb50
3ffffe60: 3fffdad0 00000040 3ffee5bc 40100518
3ffffe70: 3fffdad0 00000000 3ffee5bc 3ffefb50
3ffffe80: 3fffdad0 3ffe9800 3ffefb24 402028c0
3ffffe90: 3fffdad0 0000000c 0000000c 40202ac5
3ffffea0: 000000ff 3ffefb24 3ffe9800 00000002
3ffffeb0: 40239ab7 00000000 3ffefb24 40202ad8
3ffffec0: 00000000 4020267c 3ffefb24 40202686
3ffffed0: 2d75796e 6167656c 00007963 00000000
3ffffee0: 00000000 00000000 00000000 00000000
3ffffef0: 00000000 00000000 00000000 00000000
3fffff00: 00000000 00000000 00000000 00000000
3fffff10: 00000000 00000000 00000000 00000000
3fffff20: 00000000 00000000 00000000 00000000
3fffff30: 00000000 00000000 00000000 00000000
3fffff40: 00000000 00000000 00000000 00000000
3fffff50: 00000000 00000000 00000000 00000000
3fffff60: 00000000 00000000 00000000 00000000
3fffff70: 00000000 00000000 00000000 00000000
3fffff80: 2d75796e 6167656c 00007963 00000000
3fffff90: 00000000 00000000 00000000 00000000
3fffffa0: feefeffe 00000000 3ffefb48 40202dc0
3fffffb0: feefeffe feefeffe 3ffe8570 40100739
<<<stack<<<
0x40100518: calloc (C:\Program Files at x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc\umm_malloc.c line 1699
0x402028c0: HardwareSerial::write(unsigned char const*, unsigned int) (C:\Program Files at x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/HardwareSerial.h line 159
0x40202ac5: Print::write(char const*) (C:\Program Files at x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Print.h line 60
0x40202ad8: Print::print(char const*) (C:\Program Files at x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\Print.cpp line 122
0x4020267c: setup() at C:\Users\username\OneDrive\Arduino\鑷祴\serialwpa2enterprise/serialwpa2enterprise.ino line 92
0x40202686: setup() at C:\Users\username\OneDrive\Arduino\鑷祴\serialwpa2enterprise/serialwpa2enterprise.ino line 93
0x40202dc0: loop_wrapper() (C:\Program Files at x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266\core_esp8266_main.cpp line 122

R⸮��⸮^

Then I found this is related to a helper function:

lcd.print(sta_status_to_string(wifi_station_get_connect_status()));

const char* sta_status_to_string(station_status_t status) {
switch (status) {
case STATION_IDLE: return "STA_IDLE";
case STATION_CONNECTING: return "STA_CONNECTING";
case STATION_WRONG_PASSWORD: return "STA_WRONGPWD";
case STATION_NO_AP_FOUND: return "STA_APNOTFOUND";
case STATION_CONNECT_FAIL: return "STA_FAIL";
case STATION_GOT_IP: return "STA_GOTIP";
}
}

The status given by wifi_station_get_connect_status() is 255, which is not in status list. It should be 0-5. Therefore, I think there is something wrong with 2.5.0-dev. 2.4.2 worked fine, but the thing is 2.4.2 will give me a result of STA_WRONGPWD (as I said, I'm sure my password is correct).
When sta_status_to_string() receives 255 as the argument, it will return a null char*, which caused print function failed to print.

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Sep 24, 2018

@zhxq You are not alone in this. :) I did make it work but that was with a specific AP setting using hostapd. It does not work with eduroam or other wpa2 enterprise networks. ustccw is working on this, so we must wait. :) For all the info I have including instructions, working code and setup, please see my previous comment/ attachments.

@zhxq

This comment has been minimized.

Copy link

zhxq commented Sep 24, 2018

@zhxq You are not alone in this. :) I did make it work but that was with a specific AP setting using hostapd. It does not work with eduroam or other wpa2 enterprise networks. ustccw is working on this, so we must wait. :) For all the info I have including instructions, working code and setup, please see my previous comment/ attachments.

I just moved to ESP 32 Platform, but I still got no luck. I think I'm going to try more about that platform now. I just hate WPA2-Enterprise - I cannot connect it without any hassle with these development boards for once (e.g. Rasp Pi, Arduino, ESP8266, ESP32)!

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Oct 8, 2018

@ustccw Hi, just a gentle follow up to see if you or your assisting team had a chance to revisit this. kind regards.

@ustccw

This comment has been minimized.

Copy link

ustccw commented Oct 9, 2018

@kapyaar thanks for your follow up~ will do radius server in three month, because of busying of customer projects.

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Oct 9, 2018

@ustccw thanks for the update. Ok, I was only hoping you would be able to get back to this sooner. A shorter time scale would have been much more exciting given it probably needs a lot more testing and back and forth which will take it even further away, but I totally understand that you are busy too :)

Let me know as and when things move. I believe there are lot of people who may be able to contribute if given a chance. Just a thought ;)

@jaylthegreat

This comment has been minimized.

Copy link

jaylthegreat commented Nov 29, 2018

I would like to throw my hat into this, as I also need connect the esp8266 to wpa2 enterprise network.

I got as far as getting an access-accept Id from my freeRadius server (using eap-msvchapv2 for auth); however, according to the debug from my board a STA disconnect: 204 (Handshake timeout) occurs, and then my board will just keep retrying the authorization with the radius server.

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Dec 4, 2018

@ustccw Hope all is going well with you and team. Just a kind and humble request to keep this in your calendar so it wont get pushed back further :) Looking forward to the updates.

best!

@kapyaar

This comment has been minimized.

Copy link

kapyaar commented Feb 12, 2019

Hello @ustccw , I just wanted to get back here and say that now with the hostapd config, and arduino IDE, the board is able to get an IP. This is great! I just wanted to see if you could put some time on the freeradius server? My hope is that since we are this far, if we can let the sensor connect to most common types of networks (eduroam for example), it would be terrific. If you want me to test or troubleshoot or help with any thing, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.