From nobody Tue May 24 23:40:39 2022 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8006E1B4BA45 for ; Tue, 24 May 2022 23:41:01 +0000 (UTC) (envelope-from tomek@cedro.info) Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L79gc3B1Jz3hXh for ; Tue, 24 May 2022 23:41:00 +0000 (UTC) (envelope-from tomek@cedro.info) Received: by mail-oi1-x233.google.com with SMTP id q8so23212233oif.13 for ; Tue, 24 May 2022 16:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cedro.info; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YyP89JQh0ChDBcwWOmerH/S9K9BNhxPZMXoM5EabrnA=; b=Gw6RJFnzgtqMOUq+b8sQhNgMd/w8GjO0ERKpARE/Qnh4+dYn3yH2GuMSZCSGP9RMdW wHYGpm1ljAEbM0Kg9aLrOxmdjyH3sKcNFbmoGSlvbfBM5IGZpeU+n+7hJ46DhF7Xkj9k p0LO4HKbGxIMrZwGjISeXIATJR4XAT2/NJiAWI2rBj+VIQY6k4Abz3gp8YXpzQ2OYWbw Wz40f8UfqLRxVEQD7tCBVu+d84/THG0sEFyNWABYtljWxug1NWADQ2jx7Ntw1tOD9xBX QoMudLUTUD9SGaWG5jGHo/HYnTWGUGpX0DJXOIz5kgN0Sbv8RvSrgDFtOOeyQ9ROKvFt 696g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YyP89JQh0ChDBcwWOmerH/S9K9BNhxPZMXoM5EabrnA=; b=PewOC7QalEv4wdxHSgBaq9orP4IFlsurQBIeYbyt0tTkKpzxoobpVQXLLxNukAbfxq 6Geiw+TpcLhOo1Cb5MX5DUBFIaWjoPB+6II6NzQUtIEJJ4gHYTzqrtSOpinzzCOGVetG RYm2JTGn7KaJNHEvg+/QJQmEF7pDpHgY7dgboBmC5eAwlm7eIcAR2lxmNQXUWVzoPzSg UgWTeW3iYzAbnrJtSKlqftOaqU57g6T/hVWuDeShL62UGJUmnhgRVsrJk1gb7QLwUA6u kuySw+BhZXcyQ5VSq2hiuvOIJ+cEqck4MkJBrorOQ5/fecsn4c5Nw4dtNgFJ4xvUoN5T Fm1g== X-Gm-Message-State: AOAM5303l5fLfU8gLWiRgyMT8F7rhQCPVfWw9lTfBgl4KNwWVrXpVZnj i71sm9XBSY+KLhLASa/SVSYFVAaLYy2gOcbw X-Google-Smtp-Source: ABdhPJzk7WpOmJ7LEyGxSp/CIVnkDX9E+K+dLBT4E7kl7mL1++3L8w/Ozq18mxftRbuQApOUFTpihw== X-Received: by 2002:a05:6808:1b29:b0:32b:6a06:8135 with SMTP id bx41-20020a0568081b2900b0032b6a068135mr3721422oib.220.1653435654134; Tue, 24 May 2022 16:40:54 -0700 (PDT) Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com. [209.85.167.175]) by smtp.gmail.com with ESMTPSA id f2-20020a056830308200b006060322126dsm5542723ots.61.2022.05.24.16.40.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 May 2022 16:40:52 -0700 (PDT) Received: by mail-oi1-f175.google.com with SMTP id q10so23264115oia.9; Tue, 24 May 2022 16:40:52 -0700 (PDT) X-Received: by 2002:a05:6808:130d:b0:32b:1ff2:eb83 with SMTP id y13-20020a056808130d00b0032b1ff2eb83mr3695197oiv.175.1653435652231; Tue, 24 May 2022 16:40:52 -0700 (PDT) List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 References: <55AF97D3-5212-4A58-9942-3207A176C179@nimnet.asn.au> In-Reply-To: From: Tomek CEDRO Date: Wed, 25 May 2022 01:40:39 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Unwanted auto-assertion of DTR & RTS on serial port open To: Mychaela Falconia Cc: Warner Losh , Ian Smith , Daniel Feenberg , FreeBSD questions , Warner Losh , Kyle Evans Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4L79gc3B1Jz3hXh X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=cedro.info header.s=google header.b=Gw6RJFnz; dmarc=none; spf=none (mx1.freebsd.org: domain of tomek@cedro.info has no SPF policy when checking 2607:f8b0:4864:20::233) smtp.mailfrom=tomek@cedro.info X-Spamd-Result: default: False [-1.80 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[cedro.info:s=google]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; R_SPF_NA(0.00)[no SPF record]; NEURAL_HAM_LONG(-1.00)[-1.000]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[cedro.info]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[cedro.info:+]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_IN_DNSWL_NONE(0.00)[209.85.167.175:received,2607:f8b0:4864:20::233:from]; MLMMJ_DEST(0.00)[freebsd-questions]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-ThisMailContainsUnwantedMimeParts: N On Wed, May 25, 2022 at 12:47 AM Mychaela Falconia wrote: > Sounds like good news - but I am also going to test it myself on > actual hardware, i.e., I'll go through the learning curve of > installing FreeBSD on a spare laptop. For the test setup, my current > plan is to connect a USB cable from the FreeBSD machine to an FT2232D > breakout board, see if ttyU* and cuaU* devices appear as I would > expect, then connect an oscilloscope probe to DTR/RTS (first one, then > the other), set the scope to trigger on a falling edge (set the > trigger level to 2.0 V, the most common Vih spec for 3.3V logic) and > verify that no unwanted falls happen on either control signal. Does > anyone see any problems with this plan? I am using PL2303, FT2232D, FT2232H, and CP2102 based devices with no problem on FreeBSD for years with custom and self-designed hardware :-) If the chip driver is there but no VID:PID pair in the kernel module it is trivial to add. I usually use Minicom, PySerial, recently mpremote with ESP32. If you look for DTR / RTS reset/boot circuit here is an example from ESP32-DevKitC-V4: https://dl.espressif.com/dl/schematics/esp32_devkitc_v4-sch.pdf I have CP2102 USB adapter at hand to control and program ESP32 and ESP32-C3 chips.. but it only has RTS and CTS signals to control Reset and Boot lines as described in schematics above. I also use Prolific PL2303 USB-to-RTS232 converter that seem to have all CTS, RTS, DTR, DCD, DSR, RI lines so I can check on an oscilloscope something for you if you like (I am working on 13.1-STABLE). > Also if someone is opening a non-modem (no dial-in or dial-out > concepts) serial port for the purpose of talking to non-modem gear > (think industrial instrumentation, whatever), would it be more > "proper" to use ttyXX or cuaXX? On Linux there is only one ttyUSBx > for each port, but with FreeBSD there is a choice - hence I'd like to > know which one is more philosophically proper. I always used /dev/cuaU* for USB devices.. /dev/ttyU* showed up recently and means the same? > > despite the fact that the device uses conventions that are > > not RS-232 standard conventions This is UART transport over physical medium, TTL would be 0..5V or 0..3.3V maybe even 0..1.8V depending on the hardware. 0 is 0 (0V) and 1 is 1 (1.8V, 3.3V, 5V whatever logic is used). If you use RS-232 then 0 is +3..+12V and 1 is -5..-3V. and you need interface circuit such as MAX3232 for 3.3V logic. See: https://en.wikipedia.org/wiki/RS-232#Voltage_levels > But what's the alternative? On my target GSM device I have one full > 8-wire UART channel, another separate UART channel that is only TxD & > RxD, and two non-serial control lines which I would like to be able to > trigger from the connected host computer. My current solution covers > all of these interfaces with a single FT2232D chip. Someone could say > that I should replace this FT2232D with FT4232H (4 UART channels > instead of 2, and they don't make a 4-channel version in non-H), and > use each of the 2 extra UART channels just for its DTR (or RTS) > output, so that its control output can be independently wiggled by > opening that separate "serial" port. But this solution would have > negatives for both power efficiency and developer-user convenience: Whatever works and suits the need. I did several protocols on FT2232H chips, including UART, SPI, I2C, also Debug protocols JTAG and SWD (for ARM Cortex). The first JTAG adapters around 2010 were FT2232D and they worked too :-) I even added my custom FT2232H interface to work with AvrDude to program ATtiny10. I always carry KT-LINK interface in my backpack :-) Usually one channel on FT2232H is used for UART, the other is used for bitbang / custom protocol. If you mean Debug as JTAG or SWD not UART logging. Be aware of the USB bottleneck here. If you transfer big amounts of small data (bits over bytes) with buffer switches inside it will be slow. You may consider creating custom USB based interface on some cheap MCU, so MCU will handle gpio operations and bitstream protocol so USB will onty read/write commands. See: https://github.com/ARMmbed/DAPLink > But my GSM device is in fact a modem - or rather a cellphone handset > with built-in modem functionality. In current world situation I would rather go into independent Mesh Networking (LoRa, Bluetooth, WiFi, whatever) rather than GSM that depends on a complex infrastructure that is a single point of failure that can be easily kill-switched that its not going to be easy to restore :-) Anyways, if you use GSM then you also need a radio chip from a specific single vendor (that is also SPOF) with fairly complex radio circuit if you design that from scratch.. or you need to use some sort of module that will use proprietary firmware inside..? We were discussing Sierra modem driver recently and it seems that they Open-Sourced their whole firmware..? > Given the unavoidable problem of negatives and the desire to avoid > making it even worse with double negatives, the folks who implemented > this recent feature addition in FreeBSD settled for a somewhat > inverted sense between the underlying termios flag and stty front end: > > stty rtsdtr means CNO_RTSDTR flag is NOT set (default) > stty -rtsdtr means CNO_RTSDTR flag is SET (opposite of default) Aaah, now its clear! Thanks! :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info