I am at a loss of how to get started??

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: I am at a loss of how to get started??

Post by scruss » Sat Apr 03, 2021 1:45 am

seaside_motors wrote:
Fri Apr 02, 2021 11:03 pm
robert@mountain-cabin:~$ rshell -p /dev/ttyACM0 -f blinkpico.py
That's attempting to execute MicroPython code on your local computer as rshell commands. Not really gonna work so well.
seaside_motors wrote:
Fri Apr 02, 2021 11:31 pm
One more question, How do I actually just upload the file straight into memory and execute?
If you want something to auto-run on a Pico, call it main.py and upload it to the Pico. Topics like this are in the getting started books you were pointed to. Chapter 4 of Raspberry Pi Pico Python SDK shows you how to use Thonny, but is a bit light on helpful details:
  1. To select your Pico, go Tools → Options, then Interpreter tab and select both Interpreter: MicroPython (Raspberry Pi Pico) and Port: Board in FS mode - Board CDC (/dev/ttyACM0)
  2. To see the files on the board, go to View menu and select Files. It will show panes with local and remote files, and you can select them and copy them across (right click for menu).
thonny.jpg
thonny showing the files pane
thonny.jpg (74.34 KiB) Viewed 3411 times
You might find the Raspberry Pi Pico MicroPython forum on the Raspberry Pi site more helpful

seaside_motors
Posts: 17
Joined: Thu Mar 25, 2021 4:19 am

Re: I am at a loss of how to get started??

Post by seaside_motors » Sat Apr 03, 2021 4:18 pm

I wanted to say thanks for all the replies and helpful comments posted. The rshell command was what I was seeking so I am grateful for the help getting that installed and working. I find that it is important to know how things work and being able to directly communicate with the hardware via command line. For now I am using vim as my python editor and now that I have figured out rshell and can cut and paste programs directly to the hardware I have a good starting point. I am not totally against the Thonny IDE, it works really well from what little experience I have with it and I am sure that it will be an excellent tool in the tool box. I am sure it will be a invaluable tool in debugging and testing programs.

Again, thanks for the assist, I got the information I was seeking and have a better grasp of micropython and interfacing with the micro-controller board. :)

Cheers!

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I am at a loss of how to get started??

Post by dhylands » Sat Apr 03, 2021 5:05 pm

You can use pyboard.py (found in micropython/tools) to upload a file into memory and execute it.

Something like:

Code: Select all

pyboard.py -d /dev/ttyACM0 name-of--python-file
Note which the RPi Pico and rshell you shouldn't need to specify the port. It should find it automatically. After launching rshell you can copy a python script to the board using rshell's copy command. Note that when you launch rshell you normally get a prompt, that looks like a shell prompt. You can use rshell's help command to see available commands. https://github.com/dhylands/rshell

To copy a python script to your RPi Pico, do something like the following:

Code: Select all

574 >rshell
Connecting to /dev/cu.usbmodem0000000000001 (buffer-size 128)...
Trying to connect to REPL  connected
Retrieving sysname ... rp2
Testing if sys.stdin.buffer exists ... Y
Retrieving root directories ... /main.py/
Setting time ... Apr 03, 2021 10:03:45
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.
/Users/davehylands/micropython/upy-examples/pico> cp blinky.py /pyboard
Copying '/Users/davehylands/micropython/upy-examples/pico/blinky.py' to '/pyboard/blinky.py' ...
/Users/davehylands/micropython/upy-examples/pico> repl
Entering REPL. Use Control-X to exit.
>
MicroPython v1.13-320-g407df82f8 on 2021-02-05; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> 
>>> import blinky
>>>  

seaside_motors
Posts: 17
Joined: Thu Mar 25, 2021 4:19 am

Re: I am at a loss of how to get started??

Post by seaside_motors » Sat Apr 03, 2021 9:53 pm

dhylands wrote:
Sat Apr 03, 2021 5:05 pm
You can use pyboard.py (found in micropython/tools) to upload a file into memory and execute it.

Something like:

Code: Select all

pyboard.py -d /dev/ttyACM0 name-of--python-file
I unfortunately get the following:

>robert@mountain-cabin:~/micropython-1.14/tools$ pyboard.py /dev/ttyACM0 blinkpico.py
bash: pyboard.py: command not found

All the tools including pyboard.py are in the tools directory, although not sure why many of them have an * after the name?
Perhaps I missed a step during the micropython installation? I downloaded the tar.xz file and used tar -d micropython-1.14.tar.xz to decompress the folder and then moved the entire folder from downloads to my home directory?

robert@mountain-cabin:~/micropython-1.14/tools$ l
build-stm-latest.sh* gen-changelog.sh* mpy_bin2res.py* uf2conv.py*
cc1* gen-cpydiff.py mpy_cross_all.py* uncrustify.cfg
ci.sh* gendoc.py mpy_ld.py* upip.py
codeformat.py* insert-usb-ids.py mpy-tool.py* upip_utarfile.py
codestats.sh* make-frozen.py* pyboard.py* verifygitlog.py*
dfu.py* makemanifest.py pydfu.py*
file2h.py metrics.py* tinytest-codegen.py*

As always your input is very welcome and appreciated, thanks

Cheers

Christian Walther
Posts: 169
Joined: Fri Aug 19, 2016 11:55 am

Re: I am at a loss of how to get started??

Post by Christian Walther » Sun Apr 04, 2021 10:01 am

seaside_motors wrote:
Sat Apr 03, 2021 9:53 pm
>robert@mountain-cabin:~/micropython-1.14/tools$ pyboard.py /dev/ttyACM0 blinkpico.py
bash: pyboard.py: command not found
Naming a command without a path does not search in the current directory, only in the $PATH environment variable. To run an executable from the current directory, say

Code: Select all

./pyboard.py
Or when you are in a different directory (which you likely are when working on your own project), call it with its full path

Code: Select all

~/micropython-1.14/tools/pyboard.py
Or copy it into /usr/local/bin or some other directory listed in $PATH, or add /home/robert/micropython-1.14/tools to $PATH.
All the tools including pyboard.py are in the tools directory, although not sure why many of them have an * after the name?
It says that they are executable. See man ls, I assume your l command is an alias for ls -F.

By the way, for everything you did up to now except using pyboard.py, you didn’t actually need to download the MicroPython source code. Even for pyboard.py, I believe you don’t need anything else than that one file.

Post Reply