webrepl won't load or run

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
perigalacticon
Posts: 5
Joined: Mon Nov 18, 2019 12:03 am

webrepl won't load or run

Post by perigalacticon » Wed Feb 19, 2020 7:59 pm

I am trying the WebREPL for the first time. I loaded the firmware esp8266-20191220-v1.12.bin using esptool.py v2.0. I ran "import webrepl_setup" and got:

Code: Select all

14:02:03.479 -> >>> import webrepl_setup
14:03:38.066 -> WebREPL daemon auto-start status: disabled
14:03:38.066 -> 
14:03:38.066 -> Would you like to (E)nable or (D)isable it running on boot?
14:03:38.066 -> (Empty line to quit)
14:03:38.066 -> > E
14:03:59.930 -> To enable WebREPL, you must set password for it
14:03:59.930 -> New password (4-9 chars): python
14:04:15.044 -> Confirm password: python
14:04:26.973 -> 
14:04:26.973 ->  ets Jan  8 2013,rst cause:4, boot mode:(3,6)
14:04:26.973 -> 
14:04:26.973 -> wdt reset
14:04:26.973 -> load 0x40100000, len 31088, room 16 
14:04:27.006 -> tail 0
14:04:27.006 -> chksum 0xc4
14:04:27.006 -> load 0x3ffe8000, len 1028, room 8 
14:04:27.006 -> tail 12
14:04:27.006 -> chksum 0x9e
14:04:27.006 -> ho 0 tail 12 room 4
14:04:27.006 -> load 0x3ffe8410, len 824, room 12 
14:04:27.006 -> tail 12
14:04:27.006 -> chksum 0x89
14:04:27.006 -> csum 0x89
14:06:00.710 -> r
I connected to the ESP8266 MicroPython-087154 hotspot from my Win10 PC and pinged 192.168.4.1. I opened the WebREPL html page from a local directory using the Edge browser and everything seemed correct used the default websocket address. When I click Connect button the only response is "Disconnected". I also tried the WebREPL page at MicroPython website, same result. The ESP8266 is a "Generic" ESP-01 module that I have run many Arduino programs on, with 1MB flash.

Subsequent attempts to run "import webrepl_setup" result in:

Code: Select all

14:09:59.858 -> >>> import webrepl_setup
14:10:07.399 -> Traceback (most recent call last):
14:10:07.399 ->   File "<stdin>", line 1, in <module>
14:10:07.399 ->   File "webrepl_setup.py", line 102, in <module>
14:10:07.399 ->   File "webrepl_setup.py", line 71, in main
14:10:07.399 ->   File "webrepl_setup.py", line 40, in get_daemon_status
14:10:07.399 -> OSError: [Errno 2] ENOENT
Could you suggest a solution?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: webrepl won't load or run

Post by Roberthh » Wed Feb 19, 2020 8:07 pm

Look into boot.py. It should contain (next to others) the following lines to start webrepl:

Code: Select all

import webrepl
webrepl.start()
There should also be the file named webrepl_cfg.py, containing a single line with the content:

PASS = "python"

The error seems to indicate, that boot.py does not exist. That's strange.

perigalacticon
Posts: 5
Joined: Mon Nov 18, 2019 12:03 am

Re: webrepl won't load or run

Post by perigalacticon » Wed Feb 19, 2020 9:18 pm

Thanks. This is my first foray into MP.

If I run:

Code: Select all

c:\>ampy --port COM3 ls
I get:

Code: Select all

/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .
/        .

c:\>
?

perigalacticon
Posts: 5
Joined: Mon Nov 18, 2019 12:03 am

Re: webrepl won't load or run

Post by perigalacticon » Thu Feb 20, 2020 2:31 am

Is there a reason why I wouldn't be able to see any files? I also ran uPyLoader and it doesn't show any files, but if I run File/Init transfer files then I see __upload.py and __download.py.

If I run your suggestion:

Code: Select all

21:26:39.542 -> >>> import webrepl
21:28:16.556 -> >>> webrepl.start()
21:28:25.504 -> WebREPL is not configured, run 'import webrepl_setup'
21:28:25.504 -> >>> import webrepl_setup
21:28:41.130 -> Traceback (most recent call last):
21:28:41.130 ->   File "<stdin>", line 1, in <module>
21:28:41.130 ->   File "webrepl_setup.py", line 102, in <module>
21:28:41.130 ->   File "webrepl_setup.py", line 71, in main
21:28:41.130 ->   File "webrepl_setup.py", line 40, in get_daemon_status
21:28:41.130 -> OSError: [Errno 2] ENOENT
If I run help() I get a good response.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: webrepl won't load or run

Post by Roberthh » Thu Feb 20, 2020 7:11 am

It looks like the file system got corrupted. That happens sometimes with FAT when during file writes the device looses power.
Fix: erase the whole flash using the erase_flash command of esptool.py and reload the firmware.

perigalacticon
Posts: 5
Joined: Mon Nov 18, 2019 12:03 am

Re: webrepl won't load or run

Post by perigalacticon » Thu Feb 20, 2020 1:31 pm

Thanks I did the erase:

Code: Select all

c:\>esptool.py --port COM3 erase_flash
esptool.py v2.8
Serial port COM3
Connecting........_
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: a0:20:a6:08:71:54
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 2.6s
Hard resetting via RTS pin...
c:\>
Then uploaded the .bin:

Code: Select all

c:\>esptool.py --port COM3 --baud 460800 write_flash --flash_size=detect 0 C:\Users\perigalacticon\Documents\Arduino\esp8266-20191220-v1.12.bin
esptool.py v2.8
Serial port COM3
Connecting........_____.
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: a0:20:a6:08:71:54
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 1MB
Flash params set to 0x0020
Compressed 619828 bytes to 404070...
Wrote 619828 bytes (404070 compressed) at 0x00000000 in 9.1 seconds (effective 545.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

c:\>
Then I reset the board, actually, it needs a power cycle to start it. I can run the MP command prompt normally from serial. Now, I already see the hotspot network: "MicroPython-067154" is available in the wireless networks list on my PC. I connect to it and I can ping 192.168.1.4.

I cannot connect to the WebREPL at this point using the local html file or the MP website, the response is "disconnected."

When I list files using uPyLoader I see boot.py now. When I get the file, this is the contents viewing from Notepad++:

Code: Select all

# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import uos, machine
#uos.dupterm(None, 1) # disable REPL on UART(0)
import gc
#import webrepl
#webrepl.start()
gc.collect()
I uncomment the 2 webrepl lines, save the file and transfer the file back to the ESP. Now when I connect over serial I run:

Code: Select all

08:11:08.113 -> >>> help()
08:11:15.684 -> Welcome to MicroPython!
08:11:15.684 -> 
08:11:15.684 -> For online docs please visit http://docs.micropython.org/en/latest/esp8266/ .
08:11:15.785 -> For diagnostic information to include in bug reports execute 'import port_diag'.
08:11:15.785 -> 
08:11:15.785 -> Basic WiFi configuration:
08:11:15.785 -> 
08:11:15.785 -> import network
08:11:15.785 -> sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
08:11:15.785 -> sta_if.scan()                             # Scan for available access points
08:11:15.785 -> sta_if.connect("<AP_name>", "<password>") # Connect to an AP
08:11:15.785 -> sta_if.isconnected()                      # Check for successful connection
08:11:15.785 -> # Change name/password of ESP8266's AP:
08:11:15.785 -> ap_if = network.WLAN(network.AP_IF)
08:11:15.785 -> ap_if.config(essid="<AP_NAME>", authmode=network.AUTH_WPA_WPA2_PSK, password="<password>")
08:11:15.785 -> 
08:11:15.785 -> Control commands:
08:11:15.785 ->   CTRL-A        -- on a blank line, enter raw REPL mode
08:11:15.785 ->   CTRL-B        -- on a blank line, enter normal REPL mode
08:11:15.785 ->   CTRL-C        -- interrupt a running program
08:11:15.785 ->   CTRL-D        -- on a blank line, do a soft reset of the board
08:11:15.785 ->   CTRL-E        -- on a blank line, enter paste mode
08:11:15.785 -> 
08:11:15.785 -> For further help on a specific object, type help(obj)
08:11:15.785 -> >>> import webrepl
08:12:12.731 -> >>> webrepl.start()
08:12:32.481 -> WebREPL is not configured, run 'import webrepl_setup'
08:12:32.481 -> >>> import webrepl_setup
08:12:53.780 -> WebREPL daemon auto-start status: enabled
08:12:53.780 -> 
08:12:53.780 -> Would you like to (E)nable or (D)isable it running on boot?
08:12:53.780 -> (Empty line to quit)
08:12:53.780 -> > E
08:13:03.393 -> To enable WebREPL, you must set password for it
08:13:03.393 -> New password (4-9 chars): python
08:13:11.660 -> Confirm password: python
08:13:18.025 -> No further action required
08:13:18.025 -> >>> 
Now I can still ping 192.168.4.1, but the response at the WebREPL webpage is still "disconnected".

file:///C:/Users/perigalacticon/Documents/Arduino/webrepl-master/webrepl.html#192.168.4.1:8266/

or

http://micropython.org/webrepl/#192.168.4.1:8266/

even after refreshing the pages. Now if I reset the ESP, I get:

Code: Select all

WebREPL daemon started on ws://192.168.4.1:8266
08:26:14.861 -> Started webrepl in normal mode
08:26:14.861 -> 
08:26:14.861 -> MicroPython v1.12 on 2019-12-20; ESP module with ESP8266
08:26:14.861 -> Type "help()" for more information.
08:26:14.861 -> >>> 
Now at this point I am able to login to the WebREPL webpages and it runs correctly.

I think a few more board resets were necessary in my case to get through the procedures correctly. Thanks for the help.

Post Reply