BetaRavener / uPyLoader

File transfer and communication tool for MicroPython boards
MIT License
354 stars 77 forks source link

File->Init Transfer Files Issue #24

Closed BOB63 closed 7 years ago

BOB63 commented 7 years ago

Hi, I'm trying to use uPyLoader 0.1.1 on W10 machine and a ESP8266 on which I've already flashed Micropython .I'm able to connect the board via serial port and on the right window I've listed the two files in the board but not transfer on my pc .At startup I got message that UART files are missing and doing File->Init Transfer Files Issue the program is in stall. On the terminal window when I try to transfer from board to PC a file i got this error msg: paste mode; Ctrl-C to cancel, Ctrl-D to finish === file_name="boot.py" === with open("__download.py") as f: === exec(f.read(), globals()) === Traceback (most recent call last): File "", line 2, in OSError: [Errno 2] ENOENT

3#0

Do you have any suggestion ? Thanks.

P.S. I don't know why the big font in my post ..... sorry.

BetaRavener commented 7 years ago

Hi, no problem with the font. Let me just double-check what you did:

  1. Connected to ESP via UART (serial)
  2. Got warning message about transfer files
  3. Tried to File->Init Transfer Files but the program stalled/hung?
  4. Proceeded anyway to transfer a file to ESP (should be named boot.py.

If it's so, then the problem is obviously in third step. File transfer is dependent on the files that are copied in step 3. Without them, you get the error (ENOENT) because the transfer files do not exist on the ESP .

To fix this, you have to make sure that __download.py and __upload.py are on the ESP (listed in right column) and you no longer get that warning message when connecting to board. If uPyLoader hangs during initialization, please try again. The problem is that without these scripts, file transfer is unreliable (that's why they are used in first place) so errors may occur.

BetaRavener commented 7 years ago

The initialization can be made more reliable by sending only __upload.py and using reliable transfer for sending __download.py. Error checking and timeouts can be used to detect when transfer failed (to output message) and prevent hang ups.

BOB63 commented 7 years ago

Hi , are the upload.py and download.py the two files that I find into the MCU folder of the code or where can I find those files ?

BetaRavener commented 7 years ago

Yes, these are the scripts that will be transferred BUT you can't transfer them yourself. You have to use File -> Init Transfer Files. If everything goes right, you should see those 2 files listed on the connected device as in the image below.

image

BOB63 commented 7 years ago

No, unfortunately this option doesn't work . File transfer windows don't show any progress and I've to force the closing of program.

jdeltoft commented 7 years ago

Are you using com or wifi? Are you sure you have the right com port?

BOB63 commented 7 years ago

I'm using com. As soon as I push the connect button on the right window I see the files on esp8266, so I suppose that the connection is OK .

Inviato da smartphone Samsung Galaxy. -------- Messaggio originale --------Da: Justin Eltoft notifications@github.com Data: 10/07/17 00:01 (GMT+01:00) A: BetaRavener/uPyLoader uPyLoader@noreply.github.com Cc: Roberto Portesani speedlight86@gmail.com, Author author@noreply.github.com Oggetto: Re: [BetaRavener/uPyLoader] File->Init Transfer Files Issue (#24) Are you using com or wifi? Are you sure you have the right com port?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/BetaRavener/uPyLoader","title":"BetaRavener/uPyLoader","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/BetaRavener/uPyLoader"}},"updates":{"snippets":[{"icon":"PERSON","message":"@jdeltoft in #24: Are you using com or wifi? Are you sure you have the right com port?"}],"action":{"name":"View Issue","url":"https://github.com/BetaRavener/uPyLoader/issues/24#issuecomment-313968430"}}}

BetaRavener commented 7 years ago

Ok sorry about that. I can now reproduce the problem and will be fixing it today. The problem was that the transfer scripts were not packed with pyinstaller that creates executable. The reason why we didn't see that happening is because we have source code downloaded and executable in the same folder, so our executable would pull these transfer files from source code folder.

BetaRavener commented 7 years ago

The issue should be fixed in source code and I will release executables in few moments. Please let me know if the problem is gone in release 0.1.2.

BOB63 commented 7 years ago

Great job !! Now via serial interface it works. I've to test via wifi because it doesn't work, but I'm facing some problems also with Webrepl , so may be something wrong in my setting . Anyway thank again for now . I'll keep you informed if I find other issues . Thanks. Roberto.

BOB63 commented 7 years ago

Also wifii works, was just the setting of my antivirus that was blocking the connection.

BetaRavener commented 7 years ago

Ok great, closing the issue.

xpiolx commented 6 years ago

This function stop working with the new release 0.1.3. Tried in 2 PC (both Win10 64b, esp1.9.3) and only v0.1.2 work.

BetaRavener commented 6 years ago

@xpiolx Thanks for reporting an issue, but I will need more information. What exactly is your problem? Uploading transfer scripts to MCU? What is the behavior (something getting stuck, crashing, no visible change,...)? Is the connection to MCU working without problems (files listed correctly on connect, terminal responding to commands)?

I'm not 100% sure, but few days ago I had to download release 0.1.3 and run it in new folder, and I think I did upload the scripts without problem, so it might be an individual problem.

xpiolx commented 6 years ago

v0.1.3: After serial connect, at startup I got message that UART files are missing, or wrong version, and doing File->Init Transfer Files, one popup File Transfer opens, but instantly, another popup named Error hows up with File transfer failed. Click Ok, they close with no more info. Any double click on files on MCU, popup with title: File transfer, text: reading file, and progress bar [infinite loop] opens but did not read any file. I force close this popup, editor open with blank text from file selected.

terminal freeze with this: paste mode; Ctrl-C to cancel, Ctrl-D to finish === file_name="boot.py" === with open("__download.py") as f: === exec(f.read(), globals()) === edit: After force close popup, if I click in Disconnect, program freeze and only force closing the main exec solves. Reopen another version, and things works good.

Than I tried the previus version: v0.1.2: Normal, recognizes that there is no files for upload/download on the board, I install it normally File>Init transfer, can download and upload with no problem.

Now with the initial files for transfer installed on the MCU, even with the v0.1.3, same error occurs, freeze terminal, no download/upload.

BetaRavener commented 6 years ago

v0.1.2: Normal, recognizes that there is no files for upload/download on the board this is incorrect. In v0.1.2, there was no checking for transfer scripts. It was added in v0.1.3 and it is precisely the message you see after connecting.

The transfer scripts and also uPyLoader code which handles transfers changed significantly from 0.1.2 to 0.1.3. This was because 0.1.2 used custom message format that was problematic on some firmwares.

There might be an issue when coming from v0.1.2 to v0.1.3, if the old transfer scripts are on the MCU. You should try delete those first if you didn't already. Other than that, this would require debugging on your side. File transfer failed popping up imediately after File->Init is not expected behavior. You copied the terminal content after trying to read a file boot.py, but I would be more interested if there is any output during File->Init. There certainly should be something.

Also, if you are more capable, you could always try pulling the latest source code and run uPyLoader in debugger. The function responsible for uploading transfer scripts is this one, so you should set breakpoint at its first line and step each line. Don't take too long, there are some timeouts that would also cause file transfer to fail, you're just trying to identify where it goes bad. Another function which this one calls is send_file, so if it fails on that line, you should step into this other function to get more details.

I know it's not your responsibility as a user but since this is just a side project for me, I could use some help :) Hope we can solve this one somehow together. I could also try to add some diagnostics in next release, but again, it takes time and I'm currently short on it.

mindforger commented 5 years ago

i got a similar issue on my w10 system but i am not sure if this is an issue with my device since it is a snowflake device

i just managed to flash a specialised version of micropython to an NUCLEO-L432KC board with a minimalistic FS of only 23kBytes (thanks to the others who made it work, i just pushed the right buttons XD ... i further improved it to 28k by removing some socket related stuff that was left behind, as it has no wifi or anything besides an frozen sdcard.py module to attach an sd)

when i want to init transfer files i get to around 9% and then get the described file transfer failed message

why exactly am i not allowed to manually transfer it using a temporary linux environment?

i got tools to copy over the files myself but using them is a pain and even if i move and name those files like described, the tool won't accept those files, it feels just wrong that you are forced to use the methode that is not working for whatever reason

i don't know how to run python in debug on my mini VM, its very limited and can not access internet because of firewall reasons and sharing files between host and VM is also a pain to do too, so i am desperate to use uPyLoader for windows but i can not get the initial file transfer files working

if i could freeze them it would be even better for me but that failed catastrophically as my micropython just hangs up completely when i want to transfer a file

BetaRavener commented 5 years ago

I'm not sure I really get you. First of all, you should be able to upload transfer scripts yourself - they are in the mcu folder. There isn't any check if you used uPyLoader to get them there and I don't modify them in any way during transfer. The only check is for the version, which is first line comment and will be there if you transfer them yourself anyway.

If you want to use uPyLoader without transfer scripts, there's also hidden setting that you can change in config.json called use_transfer_scripts. Normally, it's set to true, so just change it to false. It's a bit of legacy code but should still work. uPyLoader then uses paste mode which might be unreliable, but should be fine for small files.

The problem with freezing is that the files currently have to be edited (their code) before they are run. I wonder why I designed it in such way as there might be a better solution, so maybe I'll have look on overhauling that aspect.

mindforger commented 5 years ago

If you want to use uPyLoader without transfer scripts, there's also hidden setting that you can change in config.json called use_transfer_scripts. Normally, it's set to true, so just change it to false. It's a bit of legacy code but should still work. uPyLoader then uses paste mode which might be unreliable, but should be fine for small files.

where is that config.json located? i am using the compiled windows binary because running python behind this damn ssl-box is a major pain

i am just too blind ... json files did not show up as text-file and i have overseen it because of a bizarr association with dll filse the whole time ... haha

okay so paste mode seems to fail for some reason using windows and this NUCLEO L432KC Firmware ... unfortunate, but strange enough i could transfer files (most of times) with rshell but i have no idea how to make it run without pip

reading the file i only get back a fragment

V2

import sys import time from ubinascii import a2b_base64

def _read_timeout(cnt, timeout_ms=

yeah okay i get it, the readback in paste mode is terrible, something is wrong with the input buffer in this firmware build