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

net.ifinfo fails with "Lua error: attempt to index a number value" or MCU reboot #3249

Closed
mk-pmb opened this issue Aug 23, 2020 · 9 comments · Fixed by #3267
Closed

net.ifinfo fails with "Lua error: attempt to index a number value" or MCU reboot #3249

mk-pmb opened this issue Aug 23, 2020 · 9 comments · Fixed by #3267
Assignees
Labels

Comments

@mk-pmb
Copy link
Contributor

mk-pmb commented Aug 23, 2020

Expected behavior

net.ifinfo() should return nil or a table.

Actual behavior

@0.00s  > =net.ifinfo(0)
@0.05s  Lua error: attempt to index a number value
@0.05s  stack traceback:
@0.05s  	[C]: in function 'ifinfo'
@0.05s  	stdin:1: in main chunk
@0.05s  	[C]: ?
@0.05s  	[C]: ?
@1.94s  > =net.ifinfo()
@9.29s   ets Jan  8 2013,rst cause:4, boot mode:(3,6)
@9.29s  wdt reset
@9.29s  load 0x40100000, len 30132, room 16 
@9.31s  tail 4
@9.31s  chksum 0x4b
@9.31s  load 0x3ffe8000, len 2772, room 4 
@9.32s  tail 0
@9.32s  chksum 0x2b
@9.32s  load 0x3ffe8ad4, len 8, room 8 
@9.32s  tail 0
@9.32s  chksum 0x4f
@9.32s  csum 0x4f
… noise …
@9.49s  NodeMCU 3.0.0.0 built with Docker provided by frightanic.com
@9.49s  	branch: master
@9.50s  	commit: 8d091c476edf6ae2977a5f2a74bf5824d07d6183
@9.50s  	release: 3.0-master_20200610
@9.50s  	release DTS: 202006092026
@9.50s  	SSL: false
@9.50s  	build type: float
@9.51s  	LFS: 0x00010000 bytes total capacity
@9.53s  	modules: adc,bit,color_utils,cron,crypto,encoder,file,gpio,gpio_pulse,http,i2c,mdns,mqtt,net,node,ow,pcm,perf,pipe,pwm,pwm2,rfswitch,rotary,rtcfifo,rtcmem,rtctime,sigma_delta,sjson,sntp,spi,struct,tls,tmr,uart,websocket,wifi,wifi_monitor
@9.53s   build 2020-08-23 04:19 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)

Test code

Provide a Minimal, Complete, and Verifiable example which will reproduce the problem.

=net.ifinfo(0)
=net.ifinfo()

NodeMCU startup banner

see above

Hardware

ESP8266 LoLin v3, esptool says "Chip is ESP8266EX", using the firmware image from this build

@marcelstoer
Copy link
Member

Can you reproduce this with a master build from the cloud builder?

@mk-pmb
Copy link
Contributor Author

mk-pmb commented Aug 23, 2020

Nope, seems I'm too n00b for that web form.

  1. I put an email address,
  2. verified the master branch is selected,
  3. unchecked all checkboxes,
  4. checked "debug ON",
  5. submitted…

… and it said "It's pointless to select that many modules, the build is going to fail."

I guess your idea is that the bug may be related to my modules selection, so I tried with the esp8266_nodemcu_firmware from this daily vanilla build, which ran your cloud builder docker image without custom config on the master branch. With that, it doesn't reboot, but

NodeMCU 3.0.0.0 built with Docker provided by frightanic.com
        branch: dev
        commit: a92da3c33cdb4446031e0add9fb661df82acbb0f
        release: 3.0-master_20200610 +17
        release DTS: 202008221641
        SSL: false
        build type: float
        LFS: 0x0 bytes total capacity
        modules: adc,bit,dht,file,gpio,i2c,mqtt,net,node,ow,spi,tmr,uart,wifi
 build 2020-08-23 11:17 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
cannot open init.lua: 
> = net.ifinfo()
> = net.ifinfo(0)
> = nil -- for comparison: the above seem to have returned not even nil
nil
> wifi.setmode(wifi.STATION)
> = net.ifinfo()
Lua error:      attempt to index a function value
stack traceback:
        [C]: in function 'ifinfo'
        stdin:1: in main chunk
        [C]: ?
        [C]: ?
> = net.ifinfo(0)
Lua error:      attempt to index a number value
stack traceback:
        [C]: in function 'ifinfo'
        stdin:1: in main chunk
        [C]: ?
        [C]: ?
> wifi.setmode(wifi.SOFTAP)
> = net.ifinfo()
> = net.ifinfo(0)
> 

@marcelstoer
Copy link
Member

… and it said "It's pointless to select that many modules, the build is going to fail."

You only get to see this if you select 20 or modules.

I guess your idea is that the bug may be related to my modules selection

No, not exactly. Regardless of your level of expertise if you manually edit source code or configuration options all sorts of things may go wrong.

So, I built a default firmware myself (entered email address, didn't modify anything else and hit the build button) and flashed it.

NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
	branch: master
	commit: 8d091c476edf6ae2977a5f2a74bf5824d07d6183
	release: 3.0-master_20200610
	release DTS: 202006092026
	SSL: false
	build type: integer
	LFS: 0x0 bytes total capacity
	modules: file,gpio,net,node,tmr,uart,wifi
 build 2020-08-23 15:00 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
cannot open init.lua:

Connected MCU to WiFi AP then:

> print(net.ifinfo())
table: 3ffef9b0
> print(net.ifinfo(0))
table: 3ffef9b0
> print(net.ifinfo(0).dhcp.server_ip)
192.168.0.1

=> can't reproduce your issues

@mk-pmb
Copy link
Contributor Author

mk-pmb commented Aug 23, 2020

You only get to see this if you select 20 or modules.

Indeed I first tried without disabling any modules (i.e. left the checkboxes as they were, except enable debug), and got the same error. That's why I had the idea to uncheck all. I'll try your form again with JS enabled, in case the checkboxes really do need the jQuery and stuff.

=> can't reproduce your issues

Have you tried it with wifi.setmode(wifi.STATION) first? And maybe erase the flash first so it can't have a remembered IP. Also in your example, when you get a DHCP IP, it seem you've configured the wifi. In my scenario no wifi credentials have been set up yet. It was a fresh boot with flash erased and then firmware uploaded.

@mk-pmb
Copy link
Contributor Author

mk-pmb commented Aug 23, 2020

After a bit of debugging the web form I managed to make it work, and got this firmware image.
I erased the flash, uploaded the firmware, and was able to reproduce the error:
https://gist.github.com/mk-pmb/7803ab9d5ca228f106efb48eb791f8eb

The commands used, without the noise:

wifi.setmode(wifi.SOFTAP)
= net.ifinfo(0)
= net.ifinfo()
wifi.setmode(wifi.STATION)
= net.ifinfo(0)
= net.ifinfo()

@HHHartmann
Copy link
Member

HHHartmann commented Aug 26, 2020

Just tried with my current working dev build
and found similar results as @mk-pmb

I also fount that net.ifinfo(2) reboots immediately.
Can't see why any of this happens from the code though.

NodeMCU 3.0.0.0 
	branch: pr_3158
	commit: fd8ef76b0ae71dde56f0fb853faa2763520ebdea
	release: 3.0-master_20200610 +11
	release DTS: 
	SSL: false
	build type: float
	LFS: 0x40000 bytes total capacity
	modules: adc,bit,color_utils,crypto,dht,encoder,enduser_setup,file,gpio,http,i2c,l3g4200d,mdns,net,node,ow,pipe,pixbuf,pwm,rtcfifo,rtcmem,rtctime,sjson,sntp,spi,struct,tmr,uart,wifi,wifi_monitor,ws2812,ws2812_effects
 build 2020-06-26 19:39 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)

@marcelstoer
Copy link
Member

net.ifinfo(2) reboots immediately.

Instead it's supposed to return nil - at least that's what we documented.

@vsky279 would you have time to take a look?

@vsky279
Copy link
Contributor

vsky279 commented Aug 26, 2020

I'll try to have a look :-) sometimes next week.

@vsky279
Copy link
Contributor

vsky279 commented Sep 1, 2020

There seems to be an easy fix: #3267

@marcelstoer marcelstoer linked a pull request Sep 1, 2020 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants