Keep the Elecrow's touch bus free of the USB PHY after Wi-Fi starts (0.2.94, firmware 0.2.80)
The GT911 of the CrowPanel 7.0" sits on GPIO 19 and 20, the ESP32-S3's USB pins. Firmware 0.2.79 freed them once, in a static constructor; the Wi-Fi PHY library then kept the USB PHY on (CONFIG_ESP_PHY_ENABLE_USB, on by default on an ESP32-S3) and the touch went quiet once Wi-Fi came up. The board file turns that option off, frees the pins again in BOOT_TOUCH after Wi-Fi started, and a one-second watchdog frees them whenever anything takes them, with a log line.
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
#pragma once
|
||||
// The Elecrow CrowPanel 7.0" wires its GT911 touch I2C to GPIO19 and GPIO20, the ESP32-S3's USB D- and D+. The ROM
|
||||
// leaves the USB_SERIAL_JTAG PHY on those pads, and ESP-IDF's I2C driver cannot take them back: the bus reads as
|
||||
// "I2C software timeout" and the touch never answers (esphome/esphome#15356, ESPHome 2026.3+). This runs before any
|
||||
// ESPHome component (a static constructor at priority 101): the PHY lets the pads go, and both become plain GPIOs
|
||||
// with their pull-ups, as the I2C driver expects to find them. The board's USB-C port is a CH340 on UART0, so nothing
|
||||
// is lost.
|
||||
// "I2C software timeout" and the touch never answers (esphome/esphome#15356, ESPHome 2026.3+). release_usb_pads() lets
|
||||
// the pads go: the PHY drops them, and both become plain GPIOs with their pull-ups, as the I2C driver expects to find
|
||||
// them. The board's USB-C port is a CH340 on UART0, so nothing is lost.
|
||||
//
|
||||
// It runs three times, because three things hand the pads back to the PHY: once before any ESPHome component (a
|
||||
// static constructor at priority 101, after the ROM), once in the board's BOOT_TOUCH hook (the core's on_boot at
|
||||
// priority -100, after Wi-Fi started: the Wi-Fi PHY library keeps the USB PHY unless CONFIG_ESP_PHY_ENABLE_USB is
|
||||
// off, which the board file sets as well), and from a one-second interval that reads the pad bit and releases the pads
|
||||
// again when anything took them (ESPHome's logger keeps the USB-Serial-JTAG secondary console, and a Wi-Fi restart
|
||||
// re-enables the PHY). The interval logs once per event, so the log says whether it ever had to.
|
||||
//
|
||||
// ESPHome includes every header of the component in every build, so the code is behind a flag only the Elecrow's board
|
||||
// file sets (`-DESP_SCREENS_FREE_USB_PADS=1`, packages/boards/elecrow-crowpanel7.yaml): the CYD has no such peripheral,
|
||||
@@ -15,7 +21,10 @@
|
||||
#include "soc/usb_serial_jtag_reg.h"
|
||||
|
||||
namespace elecrow {
|
||||
static __attribute__((constructor(101))) void release_usb_pads() {
|
||||
// True while the USB PHY holds GPIO19 and GPIO20.
|
||||
inline bool usb_pads_taken() { return REG_GET_BIT(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE) != 0; }
|
||||
|
||||
inline void release_usb_pads() {
|
||||
usb_serial_jtag_ll_phy_enable_pad(false);
|
||||
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE);
|
||||
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP);
|
||||
@@ -26,5 +35,7 @@ static __attribute__((constructor(101))) void release_usb_pads() {
|
||||
REG_CLR_BIT(reg, FUN_PD);
|
||||
}
|
||||
}
|
||||
|
||||
static __attribute__((constructor(101))) void release_usb_pads_early() { release_usb_pads(); }
|
||||
} // namespace elecrow
|
||||
#endif
|
||||
|
||||
+9
-3
@@ -55,9 +55,15 @@ touchscreen:
|
||||
|
||||
**GPIO 19 and 20, the touch I2C, are the ESP32-S3's USB D- and D+.** The ROM leaves the USB PHY on those pads and
|
||||
ESP-IDF's I2C driver cannot take them back: the bus reads as `I2C software timeout` and the touch never answers
|
||||
(esphome/esphome#15356, ESPHome 2026.3+). `elecrow_usb_phy.h` runs before any component, as a static constructor,
|
||||
and lets the pads go; it is behind the build flag `ESP_SCREENS_FREE_USB_PADS`, which only this board file sets, because
|
||||
ESPHome includes every header of the component in every build and the Guition, an ESP32-S3 too, keeps its USB. The board's USB-C port is a CH340 on UART0, so flashing and the log are unaffected; the
|
||||
(esphome/esphome#15356, ESPHome 2026.3+). `elecrow_usb_phy.h` lets the pads go, three times, because three things hand
|
||||
them back (firmware 0.2.80): a static constructor before any component runs (after the ROM); the board's `BOOT_TOUCH`
|
||||
hook after Wi-Fi started, because the Wi-Fi PHY library keeps the USB PHY on by default on an ESP32-S3
|
||||
(`CONFIG_ESP_PHY_ENABLE_USB`, which the board file turns off as well); and a one-second watchdog that reads the pad bit
|
||||
and releases the pads again when anything took them, logging `USB PHY took GPIO19/20 back; released again` once per
|
||||
event, so the log says whether it ever had to. The code is behind the build flag `ESP_SCREENS_FREE_USB_PADS`, which
|
||||
only this board file sets, because ESPHome includes every header of the component in every build and the Guition, an
|
||||
ESP32-S3 too, keeps its USB. ESPHome's logger keeps the USB-Serial-JTAG secondary console on, so ESP-IDF's own
|
||||
pad-release at startup (`clk.c`, only without that console) never runs here. The board's USB-C port is a CH340 on UART0, so flashing and the log are unaffected; the
|
||||
`GPIO19 is used by the USB-Serial-JTAG interface` warnings at build time are expected.
|
||||
|
||||
### Rotation
|
||||
|
||||
@@ -197,6 +197,9 @@ substitutions:
|
||||
# must name every hook, or ESPHome stops at the undefined one.
|
||||
# the first boot step: the touch guard, and what this board's panel needs
|
||||
BOOT_TOUCH: |-
|
||||
// The USB pins carry the touch I2C (elecrow_usb_phy.h): the Wi-Fi PHY started before this and may have taken them.
|
||||
if (elecrow::usb_pads_taken()) ESP_LOGW("touch", "USB PHY held GPIO19/20 at boot; released");
|
||||
elecrow::release_usb_pads();
|
||||
cyd::touch_guard.configure(${TOUCH_MOVE_LIMIT_PX}, ${TOUCH_MIN_PRESS_MS});
|
||||
cyd::edge_swipe.configure(${DISPLAY_W}, ${DISPLAY_H}, ${EDGE_SWIPE_BAND_PX}, ${EDGE_SWIPE_TRAVEL_PX});
|
||||
cyd::edge_snap_band = ${SLIDER_EDGE_SNAP_PX};
|
||||
@@ -360,6 +363,9 @@ esp32:
|
||||
sdkconfig_options:
|
||||
# The camera images' HTTP client links mbedTLS; nothing on the screen serves TLS (7 KB of flash).
|
||||
CONFIG_MBEDTLS_TLS_CLIENT_ONLY: y
|
||||
# The Wi-Fi PHY library keeps the USB PHY on by default on an ESP32-S3, which takes GPIO19/20, the touch I2C,
|
||||
# back the moment Wi-Fi starts (elecrow_usb_phy.h). Off: it leaves the USB PHY disabled, as this board needs.
|
||||
CONFIG_ESP_PHY_ENABLE_USB: n
|
||||
|
||||
psram:
|
||||
mode: octal
|
||||
@@ -460,6 +466,17 @@ online_image:
|
||||
- lambda: 'runtime_tiles::live_failed();'
|
||||
|
||||
|
||||
# The touch bus's watchdog (elecrow_usb_phy.h): whatever hands GPIO19/20 back to the USB PHY, the pads are released
|
||||
# again within a second, with one log line per event.
|
||||
interval:
|
||||
- interval: 1s
|
||||
then:
|
||||
- lambda: |-
|
||||
if (elecrow::usb_pads_taken()) {
|
||||
elecrow::release_usb_pads();
|
||||
ESP_LOGW("touch", "USB PHY took GPIO19/20 back; released again");
|
||||
}
|
||||
|
||||
text_sensor:
|
||||
# The sensor every large board has; ESP Screens 0.2.93+ reads the board from its value ("elecrow": a big panel that
|
||||
# draws images and does not turn), so it publishes like the core's diagnostics. An older app only looks for the sensor
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
# fonts/materialdesignicons-webfont.ttf (Apache 2.0, github.com/Templarian/MaterialDesign-Webfont).
|
||||
############################################################
|
||||
substitutions:
|
||||
SCREEN_FIRMWARE_VERSION: "0.2.79"
|
||||
SCREEN_FIRMWARE_VERSION: "0.2.80"
|
||||
DASHBOARD_INBOX_INTERNAL: "false"
|
||||
CALIBRATION_ON_BOOT: "false" # a bench build: start on the touch test page
|
||||
ROOM_NAME: "" # top left until ESP Screens sends the screen name
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
## 0.2.94 (firmware 0.2.80)
|
||||
|
||||
The Elecrow's touch, when Wi-Fi takes its pins.
|
||||
|
||||
- **Elecrow CrowPanel 7.0": the touch bus stays free of the USB PHY.** The GT911 sits on GPIO 19 and 20, the ESP32-S3's USB pins. Firmware 0.2.79 freed them once, before anything else started; the Wi-Fi PHY library then kept the USB PHY on, as it does on an ESP32-S3 by default, and the touch went quiet the moment Wi-Fi came up. The board now tells the PHY library to leave USB off (`CONFIG_ESP_PHY_ENABLE_USB`), frees the pins again after Wi-Fi started, and a one-second watchdog frees them again whenever anything takes them, with a log line (`USB PHY took GPIO19/20 back`) that says so.
|
||||
- Needs firmware 0.2.80 on an Elecrow: press **Update** on the screen. A CYD or Guition loses nothing by waiting. Elecrow firmware: 1,865,680 bytes, 91.8 % of its update slot.
|
||||
|
||||
## 0.2.93 (firmware 0.2.79)
|
||||
|
||||
A third screen: the 7-inch Elecrow CrowPanel, with everything the Guition shows across a wider page.
|
||||
|
||||
@@ -54,7 +54,7 @@ REFS = {'cyd': 'main', 'guition': 'main', 'elecrow': 'main'}
|
||||
# is the small one. The Elecrow CrowPanel 7.0" (app 0.2.93) is the Guition's kind at 800x480, without the Rotation.
|
||||
LARGE_BOARDS = ('guition', 'elecrow')
|
||||
# Firmware shipped with this app release; screens below it get an update offer.
|
||||
FIRMWARE_VERSION = '0.2.79'
|
||||
FIRMWARE_VERSION = '0.2.80'
|
||||
# The Auto standby switch a screen offers Home Assistant automations.
|
||||
AUTO_STANDBY_MIN_FIRMWARE = '0.2.41'
|
||||
# The settings page the screen opens itself, and the screen.settings tile that opens it.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: ESP Screen Manager
|
||||
version: "0.2.93"
|
||||
version: "0.2.94"
|
||||
slug: esp_screen_manager
|
||||
description: Choose tiles for your CYD and Guition touchscreen, without reflashing.
|
||||
url: https://gittea.trippedonmy.name/Xandrossian/homeassistant_espscreen
|
||||
|
||||
Reference in New Issue
Block a user