annotate Linux-DTR-RTS-flaw @ 105:72a272083f46 default tip

Linux-DTR-RTS-flaw: link to new fc-linux-patch repository
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 11 Dec 2023 19:02:01 +0000
parents 916488f7a8e0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 There is a fundamental flaw in the Linux kernel serial port handling subsystem
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 that affects anyone who builds special hardware in which DTR and/or RTS modem
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 control lines are repurposed for some non-traditional functions. The flaw is
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 that whenever a serial port is opened under Linux, the kernel immediately and
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 unstoppably asserts DTR and RTS (their initial power-up state prior to software
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 action is negated on every sane serial port hardware implementation), *without*
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 giving userspace applications any ability to say "no, please don't do it".
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 As long as DTR and RTS modem control outputs from the DTE are used for their
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 original RS-232 functions, automatically raising both signals on serial port
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 open is harmless - and because these signals often need to be asserted in order
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 for serial communication to take place, having them raised automatically on
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 open (without requiring an explicit TIOCMBIS ioctl) is a convenience which many
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 applications rely on - if this standard kernel behaviour were to be changed
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 for the general case (outside of special quirk configurations), a lot of
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 applications will break. Linux implements this standard behaviour as mandated
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 by POSIX and other similar standards, and those standards are in turn based on
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 the original 1970s UNIX where this architectural design originates.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 However, this standard Linux behaviour (and going all the way back to 1970s in
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 the greater UNIX family) is a total killer for custom hardware designs in which
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 DTR and/or RTS outputs from the UART are repurposed for some totally different
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 functions. Suppose that the hardware is wired in such a way that asserting the
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 control output causes an explosive charge to be set off, or causes a radio
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 transmitter to turn on (perhaps operating on some tightly regulated frequency
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 supporting mission-critical services, where spurious out-of-protocol
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 transmissions are not permissible), or applies a hard reset to some other
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 component that may be part of a live production system that must not be casually
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 reset - in all listed examples having such hardware wiring would be perfectly
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 safe in an OS-less environment where the custom application controls the custom
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 hardware as desired, without any OS inserting its own mind: the hardware design
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 of most serial ports (both traditional and USB-serial) guarantees that the
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 initial power-up state of both DTR and RTS outputs prior to software action will
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 always be negated, and the custom application thus gets to decide if and when
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 each of the two signals (independent of each other) should be asserted.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 Everything works great if the application runs on the bare metal and directly
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 controls the hardware (or runs under something like DOS, which is the same as
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 running on bare metal for the present purpose of operating serial ports), but
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 add Linux into the equation, and things quickly begin to break. The problem is
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 that the moment you open a serial port under Linux (and sadly, the same thing
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 happens under most other current OSes too), the kernel automatically asserts
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 both DTR and RTS immediately on the open operation itself, without giving
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 userspace applications any way to say "no, please don't do it". Some people
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 have been proposing new termios flags that would suppress this auto-assertion
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 on subsequent opens, but you have to open the port first in order to do termios
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 or other ioctls on it, and if the auto-assertion of DTR and RTS on that initial
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 open causes irreparable damage, then you are screwed no matter what you do.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 The only currently possible solution to this madness is to patch the kernel to
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 suppress this automatic assertion of DTR & RTS upon serial port open. But one
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 cannot simply change the standard behaviour for all serial ports, as lots of
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 standard applications for classic serial communication (where DTR and RTS do
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 need to be asserted) will break in that case. Instead the suppression of
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 automatic assertion of DTR & RTS on open needs to be conditionalized in some
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 way, so that the modified against-standards serial port open behaviour is
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 applied ONLY when special modem-control-repurposed hardware is being operated
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 on, and not for ordinary applications operating on ordinary serial ports.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 Given the current state of Linux and what is possible in the current reality,
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 if a patch is to be applied to the kernel, creating the ability to exempt
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 certain serial port open operations from the standard POSIX requirement of
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 automatically asserting DTR & RTS, there are only 3 practically feasible ways
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 to communicate to the kernel that a given serial port (or a given individual
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 open operation on a serial port) should be exempt from automatic assertion of
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 DTR & RTS:
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 1) Create a new open flag like O_NODTR, or reuse/abuse some existing open flag
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 like O_DIRECT which currently has no effect on serial ports.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 2) Create a sysfs attribute that is attached to every serial port, controlling
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 whether or not DTR & RTS should be automatically asserted on open, with the
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 default being standards-mandated traditional UNIX behaviour of
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 auto-assertion.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 3) In special cases where the custom DTR/RTS-repurposed hardware is inseparably
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 integrated (on the same custom PCB) with a USB-serial chip, such that the
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 EEPROM controlling the USB VID:PID of the USB-serial device identifies not
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 just the USB-serial converter part, but the entire product board as a whole,
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 including the circuits that repurpose DTR and RTS for non-serial purposes,
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 then the most sensible approach is to mark the USB-serial device as special
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 and disable auto-assertion of DTR & RTS on this special device when the
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 custom USB VID:PID is detected.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 As it happens, our own FreeCalypso hardware gadget with repurposed DTR & RTS
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 that requires suppression of auto-assertion of these signals (the optional boot
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 control feature of our DUART28 adapter) falls into the last special category
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 above (custom USB-serial device unambiguously distinguished by a custom USB ID),
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 hence this special case is the one that I (Mother Mychaela) have been focusing
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 on the most - as humans, we all have a natural right to put our own self-
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 interest first.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 I (Mother Mychaela) have no way of knowing whether or not there is even one
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 person alive on Earth today who has an active use case where a need exists to
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 suppress automatic assertion of DTR & RTS for some serial device, but that
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 device does not have the same quality of being inseparably integrated with a
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 custom USB ID as our DUART28C, i.e., an active use case where a need exists to
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 signal to the kernel "please don't auto-assert DTR & RTS on this serial port"
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 and moreover do this special signaling for "any" serial port, rather than one
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 identified by a custom USB VID:PID. For all I know, I may very well be the
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 only person alive on Earth today who has an active need for auto-DTR/RTS
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 suppression - but I need it ONLY for a device that has a unique distinctive USB
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 VID:PID, not for "any" serial port.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 I currently run Slackware Linux 14.2 as my personal OS, running Linux kernel
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 version 4.4.14 around which this version of Slackware was built - when I tried
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 running newer 4.4.x kernels, I was getting crashes which I could not debug. I
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 currently run this elderly Linux kernel version with my own custom patch applied
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 to the ftdi_sio driver, a patch that adds support for FreeCalypso DUART28C
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 (custom USB ID) and applies the appropriate special quirk just for this USB ID,
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 not affecting any other devices - a quirk that suppresses automatic DTR & RTS
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 assertion on FT2232D Channel B, the UART channel on which these signals are
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 repurposed on DUART28 hardware. Several different versions of this patch (made
101
916488f7a8e0 Linux-DTR-RTS-flaw: link to current location of patches
Mychaela Falconia <falcon@freecalypso.org>
parents: 100
diff changeset
114 to apply cleanly to several different kernel versions) can be found here:
916488f7a8e0 Linux-DTR-RTS-flaw: link to current location of patches
Mychaela Falconia <falcon@freecalypso.org>
parents: 100
diff changeset
115
105
72a272083f46 Linux-DTR-RTS-flaw: link to new fc-linux-patch repository
Mychaela Falconia <falcon@freecalypso.org>
parents: 101
diff changeset
116 https://www.freecalypso.org/hg/fc-linux-patch/
100
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 In 2020-09 I made a good-faith, due-diligence attempt to get the hardware
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 support patch for DUART28C (a patch to ftdi_sio driver that recognizes the new
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 USB ID and applies the necessary quirk, entirely contained inside this driver)
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 mainlined - I submitted the patch to ftdi_sio maintainer Johan Hovold. I was
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 quickly met with hostility, with Johan telling me to redesign my hardware (he
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 was basically telling me to throw away 20 perfectly good boards) in some
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 different way that would be more in line with the 1970s UNIX worldview for DTR
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 and RTS, which is what Linux currently implements.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 Some time later I was able to kinda-somewhat-partially convince Johan that the
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 current handling of DTR and RTS is a serious problem for some users, and he was
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 a little more agreeable to my patch - but instead of merging it as-is, he
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 proposed an expanded patch (getting into the tty subsystem, outside of just
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 USB-serial) that solves a more general problem. Johan's proposed patch
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 introduced an internal flag telling the tty layer to suppress DTR & RTS
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 assertion on open, and a sysfs attribute (added to all classic serial and USB-
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 serial ports) that exposes this flag. A patch to ftdi_sio that recognizes my
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 custom USB ID and sets this flag in the quirk function was still included in
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 that proposed patch series, so I was happy with the proposal.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 However, Johan's sysfs proposal was quickly shot down by other kernel
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 maintainers who didn't like the sysfs approach, and Johan himself was not too
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 interested in defending his sysfs proposal either - instead he favors a termios
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 flag that would only affect second and subsequent repeated opens of a device,
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 after the initial open to set that flag. Of course this termios flag idea does
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 not help at all, given that the very first open of the serial port would still
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 unstoppably assert DTR & RTS, causing irreparable damage - if these control
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 signals are wired to set off explosives, for example, the user's house would be
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 up in flames the moment he issues that magic stty command to set the new termios
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 flag, and Johan's assurances that second and subsequent opens of the same
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 serial port would not auto-assert DTR & RTS would be of little help to the poor
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 guy who just lost his house.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 By the end of 2021-01 I realized that my battle against Johan and Greg K-H is
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 hopeless, so I give up. The only workable solution at this point is for all
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 affected people to stop running unpatched mainline kernels and to apply our own
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 local patches instead, preferably with our own coordination amongst ourselves
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 so we have some degree of standardization among our kind. The whole discussion
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 is archived here:
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 https://lore.kernel.org/linux-serial/X8iuCXYhOBVMGvXv@localhost/T/
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 I shall indefinitely, for as long as I am alive, maintain my ftdi_sio driver
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 patch that adds support for FreeCalypso DUART28C hardware. And because I do
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 not know whether or not there exists even one person on Earth who would benefit
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 from an ability to suppress DTR & RTS assertion under Linux on "any" serial
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 port, outside of tightly integrated USB-based devices with custom USB IDs, I
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 also make the following conditional offer: *if* at least one person comes
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 forward to me and demonstrates that he or she has an active use case of the
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 kind I am talking about, *then* I will also dig up Johan's patch (the one
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 rejected by other maintainers) adding a sysfs attribute, providing a working
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 solution for "any" serial port, start actively supporting that sysfs patch, and
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 maybe even make another attempt at convincing kernel maintainers to mainline it.
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 But I will go down that path *only* if there is at least one person alive on
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 Earth (just one person would be enough) who would actively benefit from this
48ea323c1c47 Linux-DTR-RTS-flaw: import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 feature - otherwise there is no point.