Hi guys,
I have added simpe lines of code from tutorial but it's not working on boot.
Can somebody explain me why ?
Here is the code:
[code]
import pyb
import time
pin = pyb.Pin(2, pyb.Pin.OUT)
for i in range(4):
pin.value(0)
time.sleep(1)
pin.value(1)
time.sleep(1)
[/code]
However this works in python shell.
Thanks !
My code in esp8266/scrips/main.py is not working..
Re: My code in esp8266/scrips/main.py is not working..
Hi Vasili,Vasili wrote:Hi guys,
I have added simpe lines of code from tutorial but it's not working on boot.
Can somebody explain me why ?
Here is the code:
<
import pyb
import time
pin = pyb.Pin(2, pyb.Pin.OUT)
for i in range(4):
pin.value(0)
time.sleep(1)
pin.value(1)
time.sleep(1)
However this works in python shell.
Thanks !
on boot, the script "boot.py" is executed (this changed a while ago, and in the "scripts" directory, there is still only "main.py"). Thus, try the following:
add "boot.py" to the "scripts" directory with this in it:
Code: Select all
import main
Code: Select all
make clean
make
make PORT=/dev/ttyUSB0 deploy
Re: My code in esp8266/scrips/main.py is not working..
Thanks ! boot.py worked !
-
- Posts: 4
- Joined: Sat Apr 23, 2016 1:19 am
Re: My code in esp8266/scrips/main.py is not working..
I have some sort of the same problem, but can't solve it with boot.py file in esp8266/scripts folder.
Get this massage at startup of eps8266 module:
��could not open file 'boot.py' for reading
could not open file 'main.py' for reading
#4 ets_task(401002a8, 3, 3fff4658, 4)
MicroPython v1.7-150-g0d10e53 on 2016-04-23; ESP module with ESP8266
Type "help()" for more information.
I have placed a boot.py file with "import main" and a main.py in the scripts folder before building.
Get this massage at startup of eps8266 module:
��could not open file 'boot.py' for reading
could not open file 'main.py' for reading
#4 ets_task(401002a8, 3, 3fff4658, 4)
MicroPython v1.7-150-g0d10e53 on 2016-04-23; ESP module with ESP8266
Type "help()" for more information.
I have placed a boot.py file with "import main" and a main.py in the scripts folder before building.
Re: My code in esp8266/scrips/main.py is not working..
Hi Mikael,MikaelNissen wrote:I have some sort of the same problem, but can't solve it with boot.py file in esp8266/scripts folder.
Get this massage at startup of eps8266 module:
could not open file 'boot.py' for reading
could not open file 'main.py' for reading
...
I have placed a boot.py file with "import main" and a main.py in the scripts folder before building.
the boot sequence on the ESP changed lately. See this commit:
https://github.com/micropython/micropyt ... 8254a35b79
From the commit:
So to sum it up and come back to your problem:Upon start-up, _boot module is executed from frozen files to do early
initialization, e.g. create and mount the flash filesystem. Then
"boot.py" is executed if it exists in the filesystem. Finally, "main.py"
is executed if exists to allow start-on-boot user applications.
This allows a user to make a custom boot file or startup application
without recompiling the firmware, while letting to do early initialization
in Python code.
1) You don't need to "import main.py" in you "boot.py" any more. The "main.py" and "boot.py" are started both by MP if present
2) Both, "main.py" and "boot.py" are expected to be in the flash-file-system, NOT in frozen (means not in "scripts" when compiling)
At the moment, there is no official support for uploading files to the flash FS (but it is on the way I think). To make life a little easier, I use a script I wrote. If you like to have a look at it, it could be found here:
https://github.com/wendlers/mpfshell
Regards,
Stefan
-
- Posts: 4
- Joined: Sat Apr 23, 2016 1:19 am
Re: My code in esp8266/scrips/main.py is not working..
Thanks Stefan for the reply.
The mpfshell is very usefull to upload the files.
Regards
Mikael
The mpfshell is very usefull to upload the files.
Regards
Mikael
Re: My code in esp8266/scrips/main.py is not working..
Is there any update on this? I have a similar issue with main.py.
My main.py files contains nothing more than:
This only happens when I compile it with the image, not when I transfer the files via mpfshell.
Code: Select all
#��${$�$ܟ|��{oc��d�s��pp�c䌜���c�lclsdǃr$���#$�#;|�c�㓛ǜ�l��n�og�l$���d��$����d$`�g����c��#���cl�c�l{$s�'����cp��������bd�cd�|b�b��o���b8cĜ�����#l�#d�|#d`�d��|��{r'c��d�p{�#�c서��Ǐ<�cllcl��do�$`Ãl'�p;l�l��|���could not open file 'main.py' for reading
#5 ets_task(40100350, 3, 3fff6350, 4)
MicroPython v1.8.1-37-g236838a on 2016-06-13; ESP module with ESP8266
Type "help()" for more information.
>>> scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 3
cnt
connected with 0x43.2, channel 1
dhcp client start...
ip:192.168.178.12,mask:255.255.255.0,gw:192.168.178.1
>>> import main
WebREPL daemon started on ws://192.168.4.1:8266
WebREPL daemon started on ws://192.168.178.12:8266
Started webrepl in normal mode
>>>
Code: Select all
import webrepl
webrepl.start()
This only happens when I compile it with the image, not when I transfer the files via mpfshell.