Skip to content

Commit

Permalink
openthread_border_router: Deassert DTR/RTS lines for USB devices usin…
Browse files Browse the repository at this point in the history
…g these for BSL (#3677)

* patch terminal to de-assert dtr/rts if flow control disabled

* Changelog entry

* Bump version 2.9.0

* Update openthread_border_router/CHANGELOG.md

Co-authored-by: Stefan Agner <[email protected]>

---------

Co-authored-by: Stefan Agner <[email protected]>
  • Loading branch information
tl-sl and agners authored Jul 2, 2024
1 parent fd92775 commit 63508a7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From b5adc7fb59939a5054e2e2d301b26b5132254262 Mon Sep 17 00:00:00 2001
From: Tim Lunn <[email protected]>
Date: Mon, 1 Jul 2024 14:27:40 +1000
Subject: [PATCH] Deassert DTR and RTS if flow control is disabled

Many USB radio devices (particularly those based on TI CC2652) have
reset and bootloader activation directly connected to DTR/RTS lines.
These devices will fail to start, in the default state where both
DTR/RTS are asserted on connection.

This patch ensures flow control is disabled and both DTR and RTS are
deasserted on startup while configuring the terminal.
---
src/posix/platform/hdlc_interface.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp
index 12726fc72..056224786 100644
--- a/src/posix/platform/hdlc_interface.cpp
+++ b/src/posix/platform/hdlc_interface.cpp
@@ -600,6 +600,16 @@ int HdlcInterface::OpenFile(const Url::Url &aRadioUrl)
{
tios.c_cflag |= CRTSCTS;
}
+ else
+ {
+ tios.c_cflag &= ~(CRTSCTS);
+
+ // Deassert DTR and RTS
+ int flags;
+ VerifyOrExit((ioctl(fd, TIOCMGET, &flags)) != -1, perror("tiocmget"));
+ flags &= ~(TIOCM_DTR | TIOCM_RTS);
+ VerifyOrExit((ioctl(fd, TIOCMSET, &flags)) != -1, perror("tiocmset"));
+ }

VerifyOrExit((rval = cfsetspeed(&tios, static_cast<speed_t>(speed))) == 0, perror("cfsetspeed"));
rval = tcsetattr(fd, TCSANOW, &tios);
--
2.43.0

5 changes: 5 additions & 0 deletions openthread_border_router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.9.0

- Avoid triggering reset/boot loader on TI CC2652 based devices

## 2.8.0

- Bump to OTBR POSIX version 41474ce29a (2024-06-21 08:41:31 -0700)
Expand All @@ -15,6 +19,7 @@
- Add support for network sockets using socat

## 2.5.1

- Support Home Assistant Connect ZBT-1.

## 2.5.0
Expand Down
3 changes: 2 additions & 1 deletion openthread_border_router/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY 0002-rest-support-deleting-the-dataset.patch /usr/src
COPY 0003-openthread-set-netif-route-metric-lower.patch /usr/src
COPY 0001-channel-monitor-disable-by-default.patch /usr/src
COPY 0002-posix-fix-build-with-custom-netif-prefix-route-set.patch /usr/src

COPY 0004-Deassert-DTR-and-RTS-if-flow-control-is-disabled.patch /usr/src
# Required and installed (script/bootstrap) can be removed after build
ENV OTBR_BUILD_DEPS build-essential ninja-build cmake wget ca-certificates \
libreadline-dev libncurses-dev libcpputest-dev libdbus-1-dev libavahi-common-dev \
Expand Down Expand Up @@ -61,6 +61,7 @@ RUN \
cd third_party/openthread/repo \
&& patch -p1 < /usr/src/0001-channel-monitor-disable-by-default.patch \
&& patch -p1 < /usr/src/0002-posix-fix-build-with-custom-netif-prefix-route-set.patch \
&& patch -p1 < /usr/src/0004-Deassert-DTR-and-RTS-if-flow-control-is-disabled.patch \
) \
# Mimic rt_tables_install \
&& echo "88 openthread" >> /etc/iproute2/rt_tables \
Expand Down
2 changes: 1 addition & 1 deletion openthread_border_router/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 2.8.0
version: 2.9.0
slug: openthread_border_router
name: OpenThread Border Router
description: OpenThread Border Router add-on
Expand Down

0 comments on commit 63508a7

Please sign in to comment.