nekromant/esp8266-frankenstein

Command line

Closed this issue · 28 comments

Today's update...

I powered up - fine - took a look at APCONFIG - fine - had NO idea what security type to insist on - so as people usually do I simply entered my access point name and password...

And it crashed...

frankenstein > apconfig
SSID: ESP_98E330 AUTH OPEN BSSID: 1a:fe:34:98:e3:30
frankenstein > apconfig loft-east 1921681232
Need more arguments. See help.

frankenstein > Fatal exception (28):
epc1=0x4020e3a6, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000084, depc=0x00000000

ets Jan 8 2013,rst cause:4, boot mode:(3,0)

wdt reset

Oh, and again - it crashes if you look at it the wrong way!!!!

apconfig name WPA2_PSK password

Thanks for reporting, I'll add another sanity check there.

Make sure you specify authentification mode. It won't work without it. This stuff is to be expected - Frankenstein is still very early alpha.

Thanks for that - I tried that and it worked... erm... but you end up back at the prompt.. shouldn't it say something like.. OK when it gets the connection?? It would be great if you could check for 2 arguments only and accept AP name and password, I doubt that many people would know what to put in the middle. I DO like the command line editor, it is SO frustrating not being able to backspace mistakes on other implementations.

Hmm. The code sat there for a little while at the prompt after I put my details in... then rebooted.

Some more for you - I setup in AP mode by mistake - put in my login details... realised I needed to be s STA and

frankenstein > iwconnect
Cannot connect while in 'AP' mode
frankenstein > iwmode STA
Wireless mode change: AP -> STA
frankenstein > Fatal exception (28):
epc1=0x4020eee5, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000018, depc=0x00000000

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

wdt reset
load 0x40100000, len 22564, room 16
tail 4
chksum 0x22
load 0x3ffe8000, len 2896, room 4
tail 12
chksum 0x9a
ho 0 tail 12 room 4
load 0x3ffe8b50, len 7848, room 12
tail 12
chksum 0x57
csum 0x57
25901

This one shouldn't happen. Never does on my hardware.
My guess is there are some configuration parameters left from previous version of SDK that confuses closed-source Espressif code and makes it go nuts. I'll try to flash different firmwares and see if I can reproduce this behaviour on my side. Will likely post an update later tonight.

Great thanks. I'm away tonight, back tomorrow night.Oh I think I might have one of those 512k blank files - I can run that then reload your software if that helps.

Is there a reason why your firmware has suffix ROM rather than BIN. some of the software out there can't open ROM files....

Sorry that whole connect thing was me reading it the wrong way - of COURSE you have to specify the security when becoming an access point... I'm in the right node now, having used a 512k blank file to clear the board.. and I've connected to my access point...

You have specified this

frankenstein > iwconnect apname WPA2_PSK password

in your doc. but in fact it only wants apname and password. which works. But ifconfig returns nothing...

If I connect to my router.... it says connected and gives an IP addres.. but the gateway address reported is completely wrong.

frankenstein > iwmode STA
Wireless mode change: STA -> STA
frankenstein > iwconnect loft-east 1921681974
Connected

frankenstein > printenv
=== Current environment ===
sta-mode dhcp
default-mode STA
sta-ip 192.168.0.123
sta-mask 255.255.255.0
sta-gw 192.168.0.1
ap-ip 192.168.1.1
ap-mask 255.255.255.0
ap-gw 192.168.1.1
hostname frankenstein
bootdelay 5
dhcps-enable 1
=== 201/4092 bytes used ===

frankenstein >

And then after a minute of sitting there... it reboots.

and maybe for the same reason (wrong gateway) the listener does not work. Doesn't see anything coming in.

I've just posted an updated binary.
Flash it, but before doing anything run

wipeparams 3 2 1

(3 required arguments are purely random requirement to prevent accidental invocation).
This will erase all the configuration parameters at 0x7d000 and 0x7e000 and reboot.
Tell me if it solves your problems. If it does - I'll update the README.

Yep, I was wrong in the README, I'll fix it. See if wiping parameters will help, and I'll just rig my board to sit for a little while - see if it reboots. And remember to powercycle the board after flashing

Tried latest....got this.

frankenstein > iwmode STA
Wireless mode change: STA -> STA
frankenstein > iwconnect loft-east 1921681974
Connected

frankenstein > iwconfig

Command iwconfig not found, type 'help' for a list

frankenstein > ifconfig

frankenstein >
frankenstein >

I'm assuming ifconfig should have returned something - trying to find out what IP address and access point...

Tried printenv and it's still wrong..

frankenstein > printenv
=== Current environment ===
sta-mode dhcp
default-mode STA
sta-ip 192.168.0.123
sta-mask 255.255.255.0
sta-gw 192.168.0.1
ap-ip 192.168.1.1
ap-mask 255.255.255.0
ap-gw 192.168.1.1
hostname frankenstein
bootdelay 5
dhcps-enable 1
=== 201/4092 bytes used ===

frankenstein >

The router address is wrong..

printenv shows only 'environment' variables. sta-ip and etc. are the parameters used for static ip configuration (e.g. if you disable DHCP).

That's what you should normally see.

Frankenstein ESP8266 Firmware
Powered by Antares 0.2-rc1, Insane Mushroom
(c) Andrew 'Necromant' Andrianov 2014 <andrew@ncrmnt.org>
This is free software (where possible), published under the terms of GPLv2

Memory Layout:
data  : 0x3ffe8000 ~ 0x3ffe8b50, len: 2896
rodata: 0x3ffe8b50 ~ 0x3ffea9e8, len: 7832
bss   : 0x3ffea9e8 ~ 0x3fff2288, len: 30880
heap  : 0x3fff2288 ~ 0x3fffc000, len: 40312
env: Environment @ 0x0007f000 size 0x00001000 bytes (0x00000ffc real) 
env: Bad CRC (c965 vs 600) using defaults
=== Current environment ===
sta-mode    dhcp
default-mode  AP
sta-ip      192.168.0.123
sta-mask    255.255.255.0
sta-gw      192.168.0.1
ap-ip       192.168.1.1
ap-mask     255.255.255.0
ap-gw       192.168.1.1
hostname    frankenstein
bootdelay   5
dhcps-enable  1
=== 201/4092 bytes used ===
dhcpserver: started

 === Press enter to activate this console === 



frankenstein > iwmode STA
Wireless mode change: AP -> STA

frankenstein > iwconnect shadowgate neverland2
Connected

frankenstein > ifconfig
sta0: WiFi Client Interface
     state   : Connected
     rssi    : -51
     channel : 3
     inet addr:192.168.0.198 Mask:255.255.255.0 Gateway:192.168.0.20 

frankenstein > 

Btw, what modules are you using? Can you post 'chipinfo' command output?

Thanks for that - clear enough - but didn't quite work that way. See output. All looks well until ifconfig...

Frankenstein ESP8266 Firmware
Powered by Antares 0.2-rc1, Insane Mushroom
(c) Andrew 'Necromant' Andrianov 2014 andrew@ncrmnt.org
This is free software (where possible), published under the terms of GPLv2

Memory Layout:
data : 0x3ffe8000 ~ 0x3ffe8b50, len: 2896
rodata: 0x3ffe8b50 ~ 0x3ffea9e8, len: 7832
bss : 0x3ffea9e8 ~ 0x3fff2288, len: 30880
heap : 0x3fff2288 ~ 0x3fffc000, len: 40312
env: Environment @ 0x0007f000 size 0x00001000 bytes (0x00000ffc real)
env: Bad CRC (c965 vs 600) using defaults
=== Current environment ===
sta-mode dhcp
default-mode STA
sta-ip 192.168.0.123
sta-mask 255.255.255.0
sta-gw 192.168.0.1
ap-ip 192.168.1.1
ap-mask 255.255.255.0
ap-gw 192.168.1.1
hostname frankenstein
bootdelay 5
dhcps-enable 1
=== 201/4092 bytes used ===
dhcpserver: started

=== Press enter to activate this console ===

frankenstein > iwmode STA
Wireless mode change: STA -> STA
frankenstein > iwconnect loft-east 1921681974
Connected

frankenstein > ifconfig

frankenstein >
frankenstein >

It gets better.

frankenstein > ifconfig

frankenstein >
frankenstein >
INTERRUPT
BUG: How on earth to properly stop listening???

frankenstein >
frankenstein >

ifconfig should hang in there for a while (~1-2s), do not interrupt it. It is required to get rssi info.
I think I'll move rssi stuff to a different command the next update if that's giving troubles. Still wondering why it doesn't work for you.

I've just pushed a small update. I disabled channel and rssi reporting in ifconfig and made it return results instantly. See if it gets better for you.

Progress. I love it.

frankenstein > iwmode STA
Wireless mode change: STA -> STA
frankenstein > iwconnect loft-east 1921681974
Connected

frankenstein > ifconfig
sta0: WiFi Client Interface
state : Connected
rssi : 0
channel : 0
inet addr:192.168.0.22 Mask:255.255.255.0 Gateway:192.168.0.138

frankenstein >

So now if I set up LISTEN... I've changed port numbers to protect the innocent...

frankenstein > listen 8000
Listening (TCP) on port 8000
connect | 109.160.102.114:61111
receive | GO2
disconnect | 109.160.102.114:61111
connect | 109.160.102.114:61112
receive | GO2
disconnect | 109.160.102.114:61112

INTERRUPT
BUG: How on earth to properly stop listening???

frankenstein >

So that is my mobile app sending commands - and I need to respond to those commands... can I control the period before that disconnect (it's not the other end disconnecting) .....

So if you can imagine, my phone app polls maybe 4 times a second or more various inputs - and I need to see those requests - which I can above - and respond to them before the disconnect....

Thoughts? This is looking good EXCEPT... that shortly after that interrupt - which I had nothing to do with .... this..

INTERRUPT
BUG: How on earth to properly stop listening???

frankenstein >
frankenstein > Fatal exception (28):
epc1=0x4020e38a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000084, depc=0x00000000

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

wdt reset
load 0x40100000, len 22564, room 16

When I use SAVEENV it does indeed save the status - and on reboot I can check and it's there - but the message on boot is all wrong - it's showing address 192.168.0.23 and gw 192.168.0.1 which is all wrong..

Frankenstein ESP8266 Firmware
Powered by Antares 0.2-rc1, Insane Mushroom
(c) Andrew 'Necromant' Andrianov 2014 andrew@ncrmnt.org
This is free software (where possible), published under the terms of GPLv2

Memory Layout:
data : 0x3ffe8000 ~ 0x3ffe8b50, len: 2896
rodata: 0x3ffe8b50 ~ 0x3ffea9f4, len: 7844
bss : 0x3ffea9f8 ~ 0x3fff2298, len: 30880
heap : 0x3fff2298 ~ 0x3fffc000, len: 40296
env: Environment @ 0x0007f000 size 0x00001000 bytes (0x00000ffc real)
=== Current environment ===
sta-mode dhcp
default-mode STA
sta-ip 192.168.0.123
sta-mask 255.255.255.0
sta-gw 192.168.0.1
ap-ip 192.168.1.1
ap-mask 255.255.255.0
ap-gw 192.168.1.1
hostname frankenstein
bootdelay 5
dhcps-enable 1
=== 201/4092 bytes used ===
dhcpserver: started

=== Press enter to activate this console ===

frankenstein >
frankenstein > ifconfig
sta0: WiFi Client Interface
state : Connected
rssi : 0
channel : 0
inet addr:192.168.0.22 Mask:255.255.255.0 Gateway:192.168.0.138

The bottom line after I do ifconfig - is right... so.... the point of that first message?

See README, these are environment variables, that are not necessaraly applied.
if sta-mode is set to dhcp - sta-ip,gw,netmask are not applied on boot. If you set sta-mode to 'static' - they will be applied and you'll have to change them with setenv.
You can store your own data in environment if you want as well. Like 'setenv something someotherthing'

As for your app - I guess you'll have to wait a little for the transparent UART<-->TCP bridge to be finally finished. This is what I have planned next. 'listen' and 'send' are the only network commands for now. And both have their issues, mostly related to underlying espressif's code (they were actually the testcases I made when nothing seemed to be properly working for my own app)

As for interrupting listen - crashes are okay. Once you start a server listening for something - you freaking can't stop it. espconn_disconnect() just silently does nothing for listening servers (doh!)

I am SOOOOO looking forward to your transparent UART <--> TCP bridge... that is EXACTLY what I need. When putting that together please keep in mind that connections will be faulty.. so for example - a mobile phone polling inputs or sending commands over WIFI.. that might be WIFI at home, or in the street over 3G which means the signal could be lost at any time. Even at home, I use NETIO and when you close the phone or switch apps it tends to stop unceremoniously. On my ETHERNET version of this (hardwired) everything recovers. On the current LUA implementation, that recovers too (but loses a little memory). Using the original AT commands from ESPRESSIF the ESP-01 locks up all the time - however they have said that this Friday they will fix that - or kind of fix it.

However, a transparent bridge would be MUCH better, using carriage returns as delimiters say... as long as it can handle the phone app disconnecting and reconnecting.....

I'm getting excited now...

I wouldn't forward the TCP end of that bridge to the internets directly with no authorisation, if I were you. That would be a security hole of a very huge size.

I'm looking to espressif's update as well, since most of the current problems with 'send' and 'listen' are related to their code.

Well any security is going to have to be handled by the WIFI board - not easy to see how that might happen. On my existing setups I include a password... and using an obscure port etc... and that's worked for me - but yes good point. Not too many methods that are satisfactory - one could use a VPN - but loading that up on a mobile phone before using an App would just be way too painful. All ideas, preferably easy ones, welcomed.

Actually I thought Espressifs uipdates to SDK version 3 were already out - the stuff on Friday I think is just the AT demo? I could be miles out - I do know the fellow doing the LUA implementation has written to them about a memory leak. It really would have been nice if they'd given their SDK a good thrashing BEFORE they brought out the modules and got us all excited.

The next frankenstein release will be 0.9.3-based. We'll see how things work with it.
Btw, I mostly got lua running on frankenstein myself. Since nodemcu is closed-sourced it's a no-go for me, so I'll have to duplicate that effort.

Well I have to say, I'd never heard of LUA until I saw that implementation - but I've fallen in love with it - I think it's great. Sadly right now the memory holes are just too much and the implementation won't let me write a routine to make a transparent bridge although internally if you want to turn a light on and off it's great. For many projects however, the board will be talking to an external board. In my case I need to get and maintain the time, calculate lighting up and dawn times, control stuff, read temperatures - probably the same as everyone else. I can see uses for LUA in a self-contained unit (we need an ESP-01X which would be similar price but a third row of connectors bringing out the GPIOs that they didn't think we'd want in the ESP-01 (how bad a decision that was). I didn't realise you were still using the 0.9.2 version - happy to test the next version to death.

Of interest my efforts using Ethernet cards as against this alternative, have stayed up and running for up to a year (and that's only because I fitted the kit a year ago). I write about it here occasionally. http://www.scargill.net/tag/home-control-system/

I too am dying for a transparent UART<-->TCP bridge.