Micro-Python / Repl Setup W/Pycharm in a Linux Envirnoment
In this quick guide we go over setting up the Repl Enviroment for Pycharm for quick little one-off programs on your edge MCU's
Music of the Day: Night Music for Work
- Micropython is a tiny version of Python allowing you to run a 'sub-python.'
- Sadly - No Step-Debugging yet..
- It is designed to install directly onto small MCU's such as the raspberry pi-pico, etc etc.
- The site (and a good plethora of board suppport) is available here:
- Once you have micropython installed it will supply a 'REPL' which is effectively its own built in debugger over one of the /dev/ttyACM0 ports.
Part 1. Install micropython to the Raspberry Pi-Pico
We are working with a standard Raspberry Pi-Pico
- One can dowload the MicroPython here (select the one that is applicable)
- In linux installing your .uf2 file is a bit different. Open a terminal and type:
watch lsblk
- Before you plug in your pico
- After you plug in your pico (if no program has been installed prior)
- Mounting it is as easy as (requring sudo)
sudo mount /dev/sda1 /raspa
- If you have anything installed you will need to hold down 'bootsel' while you power it then release the button.
sudo cp RPI_PICO-20240602-v1.23.0.uf2 /raspa
Finding your MicroPython installed .uf2 system
sudo dmesg -w
When you plug it in you will see:
Step 2: Confirm Micropython REPL works.
- Install minicom
sudo apt install minicom
Manual Link Check to minicom.
sudo minicom -D /dev/ttyACM0 -b 115200
Now that we have proven our downstream to the chip we can focus on the Pycharm side.
Step 3. Adding your IDE Pycharm and Setting the Enviroment.
- Install the marketplace plugin (MicroPython)
- At this point you make a standard python project and then simply enable your micropython:
Pycharm is good in that it will install some associate packages required:
Setup some boiler code (main.py)
- Note we are free of CMakeLists.txt the CMake enviroment and that makes things simpler.
import machine
import sys
import utime
# Pin definitions
repl_button = machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_UP)
# Wait for button 0 to be pressed, and then exit
while True:
# If button 0 is pressed, drop to REPL
if repl_button.value() == 0:
print("Dropping to REPL")
sys.exit()
# Do nothing
utime.sleep_ms(1)
Setup your Run/Debug Configuration as:
Under your Languages & Framework / Micropython set:
You may need to change your permissions:
sudo chmod 776 /dev/ttyACM0
Hit your run button, and you will see the program automatically pushed up.
Summary...
- Why go backwards after writing so many documents on the more advanced CMSIS-DAP Clion Stepping Debugger?
- What is very handy is if you need a simple 'tool-builder' that will give you some quick bits this is a why to do it!