From owner-freebsd-usb@freebsd.org Sun May 31 21:45:54 2020 Return-Path: Delivered-To: freebsd-usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DCB2A2F2E9F for ; Sun, 31 May 2020 21:45:54 +0000 (UTC) (envelope-from freebsd@dreamchaser.org) Received: from nightmare.dreamchaser.org (ns.dreamchaser.org [66.109.141.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "dreamchaser.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49ZsLT6NhXz419W for ; Sun, 31 May 2020 21:45:53 +0000 (UTC) (envelope-from freebsd@dreamchaser.org) Received: from breakaway.dreamchaser.org (breakaway [192.168.151.122]) by nightmare.dreamchaser.org (8.15.2/8.15.2) with ESMTP id 04VLjnEh009714; Sun, 31 May 2020 15:45:49 -0600 (MDT) (envelope-from freebsd@dreamchaser.org) Reply-To: freebsd@dreamchaser.org Subject: Re: arduino usb/com port issue To: Tomasz CEDRO , Hans Petter Selasky Cc: "freebsd-usb@FreeBSD.org" References: <59da59d9-f0f0-0b30-f112-1c0af5f5399f@dreamchaser.org> From: Gary Aitken Message-ID: <43628ef3-fc10-4bd8-4314-04a84a956d62@dreamchaser.org> Date: Sun, 31 May 2020 15:44:02 -0600 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (nightmare.dreamchaser.org [192.168.151.101]); Sun, 31 May 2020 15:45:50 -0600 (MDT) X-Rspamd-Queue-Id: 49ZsLT6NhXz419W X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd@dreamchaser.org designates 66.109.141.57 as permitted sender) smtp.mailfrom=freebsd@dreamchaser.org X-Spamd-Result: default: False [-2.64 / 15.00]; HAS_REPLYTO(0.00)[freebsd@dreamchaser.org]; TO_DN_EQ_ADDR_SOME(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; REPLYTO_ADDR_EQ_FROM(0.00)[]; DMARC_NA(0.00)[dreamchaser.org]; NEURAL_HAM_LONG(-1.00)[-1.002]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.31)[-0.311]; NEURAL_HAM_MEDIUM(-1.03)[-1.027]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:21947, ipnet:66.109.128.0/19, country:US]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 May 2020 21:45:54 -0000 Hello Tomasz and Petter, Thank you for your replies. Still working on this: >>> I installed the arduino package on an 11.3-RELEASE system. When >>> it comes up, the Tools/Serial Port menu item is greyed out, >>> apparently because it doesn't know USB ports serve as com ports, >>> or for some reason it can't find them. Is this something I need >>> to configure somehow? Is this something that should be filed as >>> a bug? ... >> Did you check the permissions on /dev/usb/XXX ? These are all set to crw------- I tried changing all to crw-rw-rw- but still no arduino success >> And output from usbconfig # usbconfig -d ugen6.2 dump_device_desc ugen6.2: at usbus6, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA) bLength = 0x0012 bDescriptorType = 0x0001 bcdUSB = 0x0110 bDeviceClass = 0x0002 bDeviceSubClass = 0x0000 bDeviceProtocol = 0x0000 bMaxPacketSize0 = 0x0008 idVendor = 0x2341 idProduct = 0x0043 bcdDevice = 0x0001 iManufacturer = 0x0001 iProduct = 0x0002 iSerialNumber = 0x00dc <75833353934351E05231> bNumConfigurations = 0x0001 ... > As HPS noted in the first place check if you have valid permissions > that allow you to read/write from/to usb device. I did a hint at the > OpenOCD port: > > /usr/ports/devel/openocd/pkg-message > > To allow an ordinary user to acces any of the the hotplug USB > interface add him/her to the operator group (pw groupmod operator -m > username), then setup the devfs subsystem by adding these lines to > the following files: > > ***/etc/devfs.rules: [localrules=10] add path 'ugen*' mode 0660 group > operator add path 'usb/*' mode 0660 group operator add path 'usb' > mode 0770 group operator > > ***/etc/rc.conf: devfs_system_ruleset="localrules" $ cat /etc/rc.conf | grep devfs # allow local rules as specified in /etc/devfs.rules (5) devfs_system_ruleset="localrules" $ cat /etc/devfs.rules # Allow operator group to mount USB devices [localrules=5] add path 'da*' mode 0660 group operator # for arduino hotplug USB add path 'ugen*' mode 0660 group operator add path 'usb/*' mode 0660 group operator add path 'usb' mode 0770 group operator Do I need to restart after changing devfs.rules? That would be a bit painful at the moment; already works for devices like camera and usb sticks but they are da* devices. > I use MINICOM as the Terminal emulator. Type Ctrl+A then Z for > command menu. Note that you will have to create a configuration for a > given port in the first place (as root type `minicom -s /dev/cuaU0` > set valid port name and parameters then save as the default > configuration for that port). I don't understand the need for MINICOM. I currently use xterm. Will that work for the print output? > I did not use that particular Arduino utility, but there may be a > chance that it was written for Linux and it may suggest port name > like /dev/ttyUSB0 instead /dev/cuaU0 as it is used in FreeBSD. The "Serial Port" menu item is greyed out, as if it found none. When I plug in the arduino, there are 7 new entries in /dev: $ diff dev_noarduino.txt dev_arduino.txt 29a30,32 > cuaU0 > cuaU0.init > cuaU0.lock 81a85,87 > ttyU0 > ttyU0.init > ttyU0.lock 106a113 > ugen6.2 > In general on FreeBSD COM port over USB (aka Virtual-COM-Port) is > handled by `ucom` kernel module (type `kldstat` to list loaded > kernel modules), also it may use `umodem` or even `u3g` module. Those > modules are loaded by `devd` system daemon based on USB descriptors > when you plug a device. I just found a bug in pyOCD (Python module > for ARM CPU debug) that prevents running GDB Server when `ucom` > module is loaded for the VCP port on that board. pyOCD tries to > unload the kernel module by default to gain access to the VCP using > LibUSB but it lacks permissions to do so and the whole program stops > with an exception. In that case simply unload selected modules and > `service devd stop` for the time of testing. This may be also the > case for you: 1. You lack permissions to access a resource so > temporary try run as root and see if that works. 2. You may require > some component that is already taken by other service/application. $ kldstat Id Refs Address Size Name 1 13 0xffffffff80200000 206c860 kernel 2 1 0xffffffff8226e000 15cf0 fuse.ko 3 1 0xffffffff82421000 2408 ums.ko 4 1 0xffffffff82424000 76cc tmpfs.ko 5 1 0xffffffff8242c000 1bc0 umodem.ko 6 1 0xffffffff8242e000 3c58 ucom.ko I don't think I can run arduino as root as I can't connect to X as root; do I need to reboot for the /etc/devfs.rules to take effect? (will have to do some cleanup before trying that) Thanks, Gary