Micropython, Thonny, Raspberry Pico & USB port

Hi,
I am trying to react my development boards in Thonny IDE, there seems to be a permission issue with the USB port and USB device permission!
Which ports and and permission do i need for to configure?
I am fresh rookie with FreeBSD so please give me a noob friendly and understandable guide!
 
Is your application using libusb or /dev/XXX ?

Try to use usbconfig and chown XXX:XXX /dev/ugenX.Y to your user.
Code:
# usbconfig  
ugen1.1: <Intel EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1: <Intel EHCI root HUB> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.1: <Intel XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <A4Tech USB Optical Mouse> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen1.2: <vendor 0x8087 product 0x8008> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.2: <vendor 0x8087 product 0x8000> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.3: <vendor 0x8087 product 0x0032> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.4: <MicroPython Pyboard Virtual Comm Port in FS Mode> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
(500mA)
#
 
Last edited by a moderator:
# usbconfig
ugen1.1: <Intel EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1: <Intel EHCI root HUB> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.1: <Intel XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <A4Tech USB Optical Mouse> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen1.2: <vendor 0x8087 product 0x8008> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.2: <vendor 0x8087 product 0x8000> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.3: <vendor 0x8087 product 0x0032> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.4: <MicroPython Pyboard Virtual Comm Port in FS Mode> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
(500mA)
#
this is the output i get in the Thonny shell:
Couldn't find the device automatically.
Check the connection (making sure the device is not in bootloader mode) or choose
"Configure interpreter" in the interpreter menu (bottom-right corner of the window)
to select specific port or another interpreter.

i have installed the arm-none-eabi-gcc arm-none-eabi-newlib and pip install pyusb.
 
in linux i hade to typ cmd: chmod a+rw /dev/ttyACM0.
the question is now how to i find that chown XXX:XXX /dev/ugenX.Y
 
If your device shows up like /dev/cuaU0 there is an "dialer" group which you can add users to, which give access.

Also try:
usbconfig show_ifdrv
 
Or you could add a devd config file in /usr/local/etc/devd that does something like below. This is specific for a
Nikon D610 camera ,but if you change vendor/product you can make it work for your device.

notify 100 { match "vendor" "0x04B0"; match "product" "0x0434"; action "chgrp wheel /dev/$cdev && chmod 660 /dev/$cdev"; };
 
If your device shows up like /dev/cuaU0 there is an "dialer" group which you can add users to, which give access.

Also try:
usbconfig show_ifdrv
# usbconfig show_ifdrv
ugen1.1: <Intel EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.1.0: uhub0: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1>
ugen2.1: <Intel EHCI root HUB> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1.0: uhub1: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1>
ugen0.1: <Intel XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.1.0: uhub2: <Intel XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1>
ugen2.2: <vendor 0x8087 product 0x8000> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.2.0: uhub3: <vendor 0x8087 product 0x8000, class 9/0, rev 2.00/0.05, addr 2>
ugen1.2: <vendor 0x8087 product 0x8008> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.2.0: uhub4: <vendor 0x8087 product 0x8008, class 9/0, rev 2.00/0.05, addr 2>
ugen0.2: <MicroPython Pyboard Virtual Comm Port in FS Mode> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)
ugen0.2.0: umass0: <MicroPython Pyboard Virtual Comm Port in FS Mode, class 239/2, rev 2.00/2.00, addr 1>
ugen0.2.1: umodem0: <MicroPython Pyboard Virtual Comm Port in FS Mode, class 239/2, rev 2.00/2.00, addr 1>
ugen0.3: <A4Tech USB Optical Mouse> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen0.3.0: ums0: <A4Tech USB Optical Mouse, class 0/0, rev 1.10/0.01, addr 2>
ugen0.4: <vendor 0x8087 product 0x0032> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
Thank you for you reply,
ugen0.2: <MicroPython Pyboard Virtual Comm Port in FS Mode> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)
ugen0.2.0: umass0: <MicroPython Pyboard Virtual Comm Port in FS Mode, class 239/2, rev 2.00/2.00, addr 1>
ugen0.2.1: umodem0: <MicroPython Pyboard Virtual Comm Port in FS Mode, class 239/2, rev 2.00/2.00, addr 1>
its says at usbus0, so i assume that this might be the /dev/cuaU0
can you briefly guide me with the command line ?
 
after the following cmd in Konsole @ root:
chown a+rw /dev/cuaU0
when i start Thonny i still get the following output in the shell>
Couldn't find the device automatically.
Check the connection (making sure the device is not in bootloader mode) or choose
"Configure interpreter" in the interpreter menu (bottom-right corner of the window)
to select specific port or another interpreter.
 
i did this:
root@Core:~ # id neptunus
uid=1001(neptunus) gid=1001(neptunus) groups=1001(neptunus),0(wheel),44(video)
and then i did this:
pw usermod neptunus -G dialer
and when i did that and typ : id neptunus
uid=1001(neptunus) gid=1001(neptunus) groups=1001(neptunus),68(dialer)
what confuses me now, just a moment ago i hade this:
uid=1001(neptunus) gid=1001(neptunus) groups=1001(neptunus),0(wheel),44(video) and went to this > uid=1001(neptunus) gid=1001(neptunus) groups=1001(neptunus),68(dialer)
 
Now the good news is, when i go back into Thonny and settings and change the port from automatic to cuau0, it connects and i get this output in the shell:
MicroPython v1.12-351-gbd5633778 on 2020-04-08; MCUDEV STM32F407VE with STM32F407VE
Type "help()" for more information.
>>>
it means ut is connected! but why does it not connect when the port option is set to automatic?
 
really confusing, i disconnected and reconnected the board and the shell gives me:
Unable to connect to /dev/cuaU0: [Errno 13] could not open port /dev/cuaU0: [Errno 13] Permission denied: '/dev/cuaU0'

Backend terminated or disconnected. Use 'Stop/Restart' to restart.
when i restarted the Thonny IDE i still get the same output!
 
i disconnected and reconnected the board and the shell gives me:
Devices are created dynamically. The second you disconnect the device the associated /dev/cuaU0 device disappears. When you reconnect a new device node is created. It's the same as creating a file, setting some permissions on that file and removing the whole file. When you recreate the file those original permissions are gone, it's a new file.

 
pw usermod neptunus -G dialer
Wrong command. This doesn't add the dialer group to the neptunes user, it replaces all secondary groups of that user with the list given by -G

Code:
     -G grouplist  Set secondary group memberships for an account.  grouplist
                   is a comma, space, or tab-separated list of group names or
                   group numbers.  The user is added to the groups specified
                   in grouplist, and removed from all groups not specified.
                   The current login session is not affected by group
                   membership changes, which only take effect when the user
                   reconnects.  Note: do not add a user to their primary group
                   with grouplist.

If you just wanted to add this user to the dailer group you use pw groupmod dialer -m neptunes You need to modify the group, not the user. Simply put, you are adding a user to a group, not the other way around (adding a group to a user).

Code:
     -m newmembers  Similar to -M, this option allows the addition of existing
                    users to a group without replacing the existing list of
                    members.  Login names or user ids may be used, and
                    duplicate users are silently eliminated.
 
pw usermod neptunus -G dialer
Wrong command. This doesn't add the dialer group to the neptunes user, it replaces all secondary groups of that user with the list given by -G

Code:
     -G grouplist  Set secondary group memberships for an account.  grouplist
                   is a comma, space, or tab-separated list of group names or
                   group numbers.  The user is added to the groups specified
                   in grouplist, and removed from all groups not specified.
                   The current login session is not affected by group
                   membership changes, which only take effect when the user
                   reconnects.  Note: do not add a user to their primary group
                   with grouplist.

If you just wanted to add this user to the dailer group you use pw groupmod dialer -m neptunes You need to modify the group, not the user. Simply put, you are adding a user to a group, not the other way around (adding a group to a user).

Code:
     -m newmembers  Similar to -M, this option allows the addition of existing
                    users to a group without replacing the existing list of
                    members.  Login names or user ids may be used, and
                    duplicate users are silently eliminated.
Thank you SirDice!
is sudo pip install pyusb necessary?
 
I can't remember if I needed anything extra, just the permissions on the USB port, for Thonny to work with the Pico. But I'm fairly sure I didn't need to use pip.
 
Back
Top