Search code examples
pythonintellij-ideapycharmraspberry-pi-pico

MicroPython PyCharm 2021.3.3 plugin permission error


I was trying to set up MicroPython on PyCharm 2021.3.3, unfortunately I was not able to successfully connect my board to IDE. I'm getting trying to use tools>>MicroPython>>MicroPython REPL:

Found the device, but could not connect via port 'COM4': could not open port 'COM4': PermissionError(13, 'Odmowa dostępu.', None, 5)
I'm not sure what to suggest. :-(
Press ENTER to continue

Then I have tried to flush simple program to control despite previous error and it spits out:

Connecting to COM4
Traceback (most recent call last):
  File "C:\Users\reczul\AppData\Roaming\JetBrains\PyCharm2021.3\plugins\intellij-micropython\scripts\microupload.py", line 139, in <module>
    main(sys.argv[1:])
  File "C:\Users\reczul\AppData\Roaming\JetBrains\PyCharm2021.3\plugins\intellij-micropython\scripts\microupload.py", line 56, in main
    board = Pyboard(port)
  File "C:\Users\reczul\PycharmProjects\pythonProject1\venv\lib\site-packages\ampy\pyboard.py", line 147, in __init__
    raise PyboardError('failed to access ' + device)
ampy.pyboard.PyboardError: failed to access COM4

What can I do to fix this error?

The sample code I have used:

from machine import Pin, Timer

led = Pin(25, Pin.OUT)
tim = Timer()
def tick(timer):
    global led
    led.toggle()

tim.init(freq=2.5, mode=Timer.PERIODIC, callback=tick)```

Solution

  • Assuming you are using a Pi Pico.

    You are most likely getting this error because you pressed the 'BOOTSEL' button while plugging your device in.

    Drag your UF2 file onto the device, it should reboot. Don't unplug the device and hold the 'BOOTSEL' this time.

    It should be good to go now.