Uploading and running micropython code...?
-
Can anyone explain simply how to run a micropython script on the M5Stack? I'm currently on a windows computer. This feels like it should be a very easy question, but I've had no luck. What I would like to do is:
- Create and edit a main.py file in a text editor, like Sublime
- Put that on the M5Stack along with any resources (i.e. any supporting .py files, images, etc)
Preferably, I'd like to do that over USB.
I've seen other boards that just show up as a removable USB drive, and you can drag-and-drop files directly into it. I was hoping the M5Stack would be similar, but unless I'm missing something, that isn't the case.
I can get desktop UIFlow to work, but I'd rather not copy-paste code all the time, and it's unclear to me how to add additional files (for example, another .py file with classes that main.py imports, or images, etc.).
I'm sorry if I'm totally missing something obvious, but after many hours of looking, I'm about out of ideas.
-
@marf No you are not missing anything.
I did ask about USB drive mode but because of the windows UIFlow we are stuck with USB serial device mode.Most of us use Adafruits Ampy to copy files to the M5Stacks and stick, but you need to connect to the M5Stack first using the command line.
When you upload a .py file you may need to go into the M5Stacks app menu to run the script on the device.Unfortunately this section of the documents are not well covered but if you go to the http://micropython.org web site then their documents should be able to help.
-
Thank you! This helped! At the very least, I've got Ampy up and running and can toss some files onto the device. I've got the M5Stack Faces kit, and I'm using the factory firmware (rather than UIFlow). Now I'm working on getting the M5Stack libraries working... I found the githubs located here: http://community.m5stack.com/topic/724/micropython-firmware-with-m5stack-libraries
and managed to move over m5stack.py and input.py, but now m5stack.py is grumpy because it can't find the "display" module. Any pointers on where to go from here?Alternatively, I suppose the UIFlow firmware probably has these libraries already... or it's using a different M5Stack.py maybe? Even in USB mode, I can't seem to access the REPL with the UIFlow firmware.
Thanks again, and sorry for leaning on the forums hard for this... it just feels like there ought to be a better way to get this to get this running a python file without the extra UIFlow interference. (I'm sure it's great for starting out, but I was hoping to use this more for prototyping, etc.)
-
@marf Thanks for sharing you experiences, it through this feedback that the project can improve and grow.
I don't have faces as I'm still waiting for it to be delivered.
I have noticed that accessing REPL is very hit and miss at the moment and reported this to @heybin.One of the greatest difficulties with the faces kit is that the firmware wasn't developed by M5Stack, and now the problems are starting to show.
Please fill in the icebreaker thread in the general forum and create a project where you can share updates on issues you find and over come.
-
@marf said in Uploading and running micropython code...?:
Even in USB mode, I can't seem to access the REPL with the UIFlow firmware.
I'm on a Mac, so sorry I don't have the exact commands for Windows. But this is how I access the REPL.
First open up a screen session using the Mac Terminal. On Windows, you will need a program like Putty to have access to a terminal emulator.world101$ screen /dev/tty.SLAB_USBtoUART 115200
This gets me into the REPL automatically.
MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on M5Stack with ESP32 Type "help()" for more information. >>> >>> os.listdir() >['image_app', 'flow_usb.py', 'sys_lib', 'modeconfig.json', 'emoji', 'config.py', 'lib', 'res', 'flow.py', 'blocks', 'apps', 'debug.py', '.vscode', 'boot.py', 'img', 'main.py']
If for some reason I don't get the >>> cursor, then I press Ctrl+C on the keyboard to get the REPL prompt.
-
@world101 said in Uploading and running micropython code...?:
screen /dev/tty.SLAB_USBtoUART 115200
Thanks mate, my M5Go is hit and miss accessing REPL.
-
One thing I just noticed. If I run an ampy command (ampy -p /dev/tty.SLAB_USBtoUART -b 115200 ls) before doing the screen session, I get the REPL prompt every time without needing to press Ctrl+C. Running an ampy command must break the m5stack out of the currently running main program loop, which is what Ctrl+C does anyway. Just wanted to provide that additional detail.
-
@world101 said in Uploading and running micropython code...?:
One thing I just noticed. If I run an ampy command (ampy -p /dev/tty.SLAB_USBtoUART -b 115200 ls) before doing the screen session, I get the REPL prompt every time without needing to press Ctrl+C. Running an ampy command must break the m5stack out of the currently running main program loop, which is what Ctrl+C does anyway. Just wanted to provide that additional detail.
Strange, didn't work for me.