rshell can't mkdir or cd into directory on ESP8266
-
- Posts: 7
- Joined: Tue Jul 03, 2018 5:54 am
rshell can't mkdir or cd into directory on ESP8266
I'm just starting to use Micropython on ESP8266 and really enjoying it. I've been using rshell to copy files and run the REPL over USB.
I successfully connect rshell running on Mac to a D1 Mini Pro (ESP8266 by RobotDyn) using
`rshell -p /dev/cu.SLAB_USBtoUART --buffer-size 30`
I can list files using
`ls /pyboard` and copy files into that directory. I can use mkdir to create directories on the Mac filesystem but when I try `mkdir /pyboard/test` I get `Unable to create /pyboard/test`. However, I can create the directory from Micropython REPL using `uos.mkdir('test')`, and then I can copy files into that directory using rshell.
When I try to cd into a directory on the ESP, rshell crashes giving:
> cd /pyboard
Traceback (most recent call last):
File "//anaconda/bin/rshell", line 11, in <module>
load_entry_point('rshell==0.0.14', 'console_scripts', 'rshell')()
File "//anaconda/lib/python3.6/site-packages/rshell/command_line.py", line 4, in main
rshell.main.main()
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 2712, in main
real_main()
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 2695, in real_main
shell.cmdloop(cmd_line)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1589, in cmdloop
cmd.Cmd.cmdloop(self)
File "//anaconda/lib/python3.6/cmd.py", line 138, in cmdloop
stop = self.onecmd(line)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1619, in onecmd
self.onecmd_exec("".join(group))
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1630, in onecmd_exec
return cmd.Cmd.onecmd(self, line)
File "//anaconda/lib/python3.6/cmd.py", line 217, in onecmd
return func(arg)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1914, in do_cd
auto(chdir, dirname)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 524, in auto
return dev.remote_eval(func, dev_filename, *args, **kwargs)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1379, in remote_eval
return eval(self.remote(func, *args, **kwargs))
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
Could the problem be related to the fact that I froze a bunch of libraries into the firmware (e.g., picoweb, uasyncio, etc.), increased irom0_0_seg in esp8266.ld to avoid overflow during building, and flashed with `esptool.py --port /dev/cu.SLAB_USBtoUART --baud 460800 write_flash -fm dio -fs 16MB 0 firmware-combined.bin 0xffc000 esp_init_data_default.bin` in order to be able to use 16MB of flash on the board?
I successfully connect rshell running on Mac to a D1 Mini Pro (ESP8266 by RobotDyn) using
`rshell -p /dev/cu.SLAB_USBtoUART --buffer-size 30`
I can list files using
`ls /pyboard` and copy files into that directory. I can use mkdir to create directories on the Mac filesystem but when I try `mkdir /pyboard/test` I get `Unable to create /pyboard/test`. However, I can create the directory from Micropython REPL using `uos.mkdir('test')`, and then I can copy files into that directory using rshell.
When I try to cd into a directory on the ESP, rshell crashes giving:
> cd /pyboard
Traceback (most recent call last):
File "//anaconda/bin/rshell", line 11, in <module>
load_entry_point('rshell==0.0.14', 'console_scripts', 'rshell')()
File "//anaconda/lib/python3.6/site-packages/rshell/command_line.py", line 4, in main
rshell.main.main()
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 2712, in main
real_main()
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 2695, in real_main
shell.cmdloop(cmd_line)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1589, in cmdloop
cmd.Cmd.cmdloop(self)
File "//anaconda/lib/python3.6/cmd.py", line 138, in cmdloop
stop = self.onecmd(line)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1619, in onecmd
self.onecmd_exec("".join(group))
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1630, in onecmd_exec
return cmd.Cmd.onecmd(self, line)
File "//anaconda/lib/python3.6/cmd.py", line 217, in onecmd
return func(arg)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1914, in do_cd
auto(chdir, dirname)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 524, in auto
return dev.remote_eval(func, dev_filename, *args, **kwargs)
File "//anaconda/lib/python3.6/site-packages/rshell/main.py", line 1379, in remote_eval
return eval(self.remote(func, *args, **kwargs))
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
Could the problem be related to the fact that I froze a bunch of libraries into the firmware (e.g., picoweb, uasyncio, etc.), increased irom0_0_seg in esp8266.ld to avoid overflow during building, and flashed with `esptool.py --port /dev/cu.SLAB_USBtoUART --baud 460800 write_flash -fm dio -fs 16MB 0 firmware-combined.bin 0xffc000 esp_init_data_default.bin` in order to be able to use 16MB of flash on the board?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: rshell can't mkdir or cd into directory on ESP8266
I appreciate this doesn't help you much but (in rshell) `mkdir /pyboard/test` works here on the reference board.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 7
- Joined: Tue Jul 03, 2018 5:54 am
Re: rshell can't mkdir or cd into directory on ESP8266
Thanks for the reply pythoncoder.
I realized that this board is actually 4MB, so I reflashed using `esptool.py --port /dev/cu.SLAB_USBtoUART --baud 460800 write_flash -fm dio --flash_size=detect 0 firmware-combined.bin` but the behavior is as before. Next I'll try with just the stock Micropython distribution (no added modules).
I realized that this board is actually 4MB, so I reflashed using `esptool.py --port /dev/cu.SLAB_USBtoUART --baud 460800 write_flash -fm dio --flash_size=detect 0 firmware-combined.bin` but the behavior is as before. Next I'll try with just the stock Micropython distribution (no added modules).
-
- Posts: 7
- Joined: Tue Jul 03, 2018 5:54 am
Re: rshell can't mkdir or cd into directory on ESP8266
I just flashed with the prebuilt bin from the website and it seems to fix the problem. It seems like increasing irom0_0_seg in esp8266.ld may have caused the problem behavior. I guess I also need to change something in modesp.c and/or flashbdev.py. I see your post at https://github.com/micropython/micropyt ... -287737238
but it looks like modesp.c has changed since then and I don't yet understand how this stuff works.
So, can someone suggest a recipe for how to accommodate the larger firmware size due to a bunch of frozen modules (with the corresponding decrease in filesystem size)? Thanks.
but it looks like modesp.c has changed since then and I don't yet understand how this stuff works.
So, can someone suggest a recipe for how to accommodate the larger firmware size due to a bunch of frozen modules (with the corresponding decrease in filesystem size)? Thanks.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: rshell can't mkdir or cd into directory on ESP8266
From a study of the files and a quick test I think all you have to do is:
This will, of course, erase any files you have on the device.
Please report your findings. If you have success I'll post a follow up on the GitHub thread.
- Edit esp8266/esp8266.ld as below. No other file needs to be changed.
- Erase the flash.
- Issue make clean
- Issue make
- Flash the result.
Code: Select all
irom0_0_seg : org = 0x40209000, len = 0xa7000
Please report your findings. If you have success I'll post a follow up on the GitHub thread.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 7
- Joined: Tue Jul 03, 2018 5:54 am
Re: rshell can't mkdir or cd into directory on ESP8266
My firmware overflowed a segment size of 0xa7000 so I changed it to 0xb7000 and the firmware built successfully. Then I erased and flashed the board. I get the same problem behavior as before (e.g., unable to create subdirectory of /pyboard).
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: rshell can't mkdir or cd into directory on ESP8266
I can't replicate this on the reference board which I flashed with extra space as described above. I created a directory test using rshell:
Can you create a directory in Python? The following works here:
Code: Select all
/home/adminpete> mkdir /pyboard/test
/home/adminpete> cd /pyboard/test
/pyboard/test>
Code: Select all
>>> import os
>>> os.listdir('/')
['boot.py', 'main.py', 'test']
>>> os.mkdir('/rats')
>>> os.listdir('/')
['boot.py', 'main.py', 'test', 'rats']
>>>
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 7
- Joined: Tue Jul 03, 2018 5:54 am
Re: rshell can't mkdir or cd into directory on ESP8266
Here's my rshell session. Maybe one clue is that from MicroPython os.mkdir fails but uos.mkdir works.
Code: Select all
Michaels-iMac:~ michael$ rshell -p /dev/cu.SLAB_USBtoUART --buffer-size 30
Connecting to /dev/cu.SLAB_USBtoUART ...
Welcome to rshell. Use Control-D to exit.
ls /pyboard
boot.py
/Users/michael> mkdir /pyboard/test
Unable to create /pyboard/test
/Users/michael> ls /pyboard
boot.py
/Users/michael> repl
Entering REPL. Use Control-X to exit.
repl_serial_to_stdout dev = <rshell.main.DeviceSerial object at 0x109f85ba8>
>
MicroPython v1.9.4-227-gab02abe-dirty on 2018-07-05; ESP module with ESP8266
Type "help()" for more information.
>>>
>>> import os
>>> os.listdir('/')
['boot.py']
>>> os.mkdir('/rats')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "os/__init__.py", line 80, in mkdir
NameError: name 'mkdir_' is not defined
>>>
>>> import uos
>>> uos.mkdir('/rats')
>>> os.listdir('/')
['boot.py', 'rats']
>>>
Re: rshell can't mkdir or cd into directory on ESP8266
Did you by change copy a module like os.py from micropython_lib onto your device? That is not needed. uos and it's alias os is a built-in module.
-
- Posts: 7
- Joined: Tue Jul 03, 2018 5:54 am
Re: rshell can't mkdir or cd into directory on ESP8266
An "os" directory with an __init.py__ file was apparently created in the modules directory by one of the pip install commands I ran to install the modules. I removed that directory and rebuilt and reflashed the firmware and it fixed the problem! Now I can get back to my IoT endeavors. Thanks!