fadushin / esp8266

This repository contains source code for the ESP8266.
BSD 2-Clause "Simplified" License
73 stars 22 forks source link

issue with frozen code #3

Open krystlih opened 7 years ago

krystlih commented 7 years ago

Hi,

I followed your instructions for building the frozen code, and I'm getting the following on import:

import uhttpd Traceback (most recent call last): File "", line 1, in File "uhttpd.py", line 29, in ImportError: no module named 'uasyncio'

I have all the files linked as specified in the modules directory:

total 32 -rw-rw-r-- 1 cscott cscott 288 Mar 18 09:51 _boot.py lrwxrwxrwx 1 cscott cscott 56 Mar 18 10:13 console_sink.py -> /home/cscott/esp8266/micropython/logging/console_sink.py lrwxrwxrwx 1 cscott cscott 59 Mar 18 10:12 core.py -> /home/cscott/micropython-lib/uasyncio.core/uasyncio/core.py -rw-rw-r-- 1 cscott cscott 1455 Mar 18 09:51 ds18x20.py -rw-rw-r-- 1 cscott cscott 1110 Mar 18 09:51 flashbdev.py lrwxrwxrwx 1 cscott cscott 59 Mar 18 10:07 http_api_handler.py -> /home/cscott/esp8266/micropython/uhttpd/http_api_handler.py lrwxrwxrwx 1 cscott cscott 60 Mar 18 10:07 http_file_handler.py -> /home/cscott/esp8266/micropython/uhttpd/http_file_handler.py lrwxrwxrwx 1 cscott cscott 58 Mar 18 10:12 init.py -> /home/cscott/micropython-lib/uasyncio/uasyncio/init.py lrwxrwxrwx 1 cscott cscott 47 Mar 18 10:08 logging.py -> /home/cscott/micropython-lib/logging/logging.py -rw-rw-r-- 1 cscott cscott 2430 Mar 18 09:51 onewire.py lrwxrwxrwx 1 cscott cscott 49 Mar 18 10:07 uhttpd.py -> /home/cscott/esp8266/micropython/uhttpd/uhttpd.py lrwxrwxrwx 1 cscott cscott 48 Mar 18 10:13 ulog.py -> /home/cscott/esp8266/micropython/logging/ulog.py lrwxrwxrwx 1 cscott cscott 19 Mar 18 09:51 upip.py -> ../../tools/upip.py lrwxrwxrwx 1 cscott cscott 28 Mar 18 09:51 upip_utarfile.py -> ../../tools/upip_utarfile.py -rw-rw-r-- 1 cscott cscott 2076 Mar 18 09:51 webrepl.py -rw-rw-r-- 1 cscott cscott 2963 Mar 18 09:51 webrepl_setup.py -rw-rw-r-- 1 cscott cscott 1624 Mar 18 09:51 websocket_helper.py

Thoughts?

fadushin commented 7 years ago

You need to install the asyncio (and other) dependencies.

Please see https://github.com/fadushin/esp8266/tree/master/micropython/uhttpd#frozen-bytecode-recommended

fadushin commented 7 years ago

@krystlih Ok to close?

alive-corpse commented 6 years ago

Hi! I also trying to compile firmware with uhttpd and I following this instructions: https://github.com/fadushin/esp8266/tree/master/micropython/uhttpd#frozen-bytecode-recommended But at the moment link https://github.com/micropython/micropython/tree/master/esp8266 is broken and it seems, that directory structure of micropython project is changed. I found directory esp8266 at https://github.com/micropython/micropython/tree/master/ports/esp8266 and I'll check ability of compiling, but documentations needs to be fixed.

UPD: I checked it - I can compile firmware, that contains uhttpd, asyncio, logger. Also I can start server:

import uhttpd
import uhttpd.file_handler
import uhttpd.api_handler
import api

api_handler = uhttpd.api_handler.Handler([
    (['system'], api.SystemAPIHandler()),
    (['memory'], api.MemoryAPIHandler()),
    (['flash'], api.FlashAPIHandler()),
    (['network'], api.NetworkAPIHandler())
])
file_handler = uhttpd.file_handler.Handler('/www') 
# in documentaion Handler initialized without '/www' parameter,
# but I think it's mistake, anyway, I cat get content from /www only
# if I initialize Handler with path, cause by documentation I uploaded 
# content into /www

server = uhttpd.Server([
    ('/api', api_handler),
    ('/', file_handler)],
    {'max_headers': 50, 'backlog': 10})

server.run()

I append api.py (and then api.mpy - the same situation) into the root. It works if I run it from repl:

MicroPython v1.9.3-240-ga275cb0f on 2018-01-12; ESP module with ESP8266                                                                                                      
Type "help()" for more information.                                                                         
>>> import api
>>> m = api.MemoryAPIHandler()
>>> m.get_memory_stats()
{'mem_alloc': 19648, 'mem_free': 16320}
>>> n = api.NetworkAPIHandler()
>>> n.get_ap_stats()
{'ifconfig': {'ip': '192.168.4.1', 'gateway': '192.168.4.1', 'subnet': '255.255.255.0', 'dns': '208.67.222.222'}, 'status': 'Unknown wlan status: -1', 'config': {'authmode':
'AUTH_WPA_WPA2_PSK', 'hidden': False, 'mac': '0x1afe34d3fc05', 'channel': 1, 'essid': 'MicroPython-d3fc05'}}

But when I trying to get api through web, I got error and repl restarting:

>>> import serv                                                                   
INFO:None:uhttpd-master running...                                                  

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

wdt reset                                                                                                                                                                     
load 0x40100000, len 31096, room 16                                                                                                                                           
tail 8                                                                                                                                                                        
chksum 0x40
load 0x3ffe8000, len 1076, room 0
tail 4                             
chksum 0xfd
load 0x3ffe8440, len 3252, room 4
tail 0                           
chksum 0x89
csum 0x89  

lܞ|rn#
      l    
       Bb䌜dl
             "
              b$`$
                  $ܟ|2srn#l$
                            bc"
                               $`lo"

                                    #
                                     #l
                                       b#lNN|l
                                              lld`$

                                                   p
                                                    l l
                                                       $l {l#ccc{
                                                                 n$lllll nb
                                                                           $
                                                                            $b
                                                                              $
                                                                               cr$r$s
                                                                                     oܟcpBr$#$`lorll#4 ets_task(40100130, 3, 3fff838c, 4)
OSError: [Errno 2] ENOENT                                            

MicroPython v1.9.3-240-ga275cb0f on 2018-01-12; ESP module with ESP8266
Type "help()" for more information.                                              
>>>
fadushin commented 6 years ago

Wow that's cool. It looks like your ESP (or whatever device you are running on) crashed. Does it crash immediately, or does it crash only when you make an HTTP request to the device?

I'm not sure how to help you here. For me, I usually experience issues like this when I have a faulty power supply.

alive-corpse commented 6 years ago

Wow that's cool. It looks like your ESP (or whatever device you are running on) crashed. Does it crash immediately, or does it crash only when you make an HTTP request to the device?

Couple of hours ago I taked two other esp8266 boards, and flashed them with the same builded firmware. They doesn't crash at all. I can get any api response by curl or browser, so it seems, that my first ESP board is broken. But there are another problem with web-console: I can see console, but in "About" tab I can see only "A web console into your ESP8266" label, "Access Point" label in "Networking" tab and some empty space between labels and footers.