feat: add LAN8720 support and extend ESP32 Ethernet profiles

This commit is contained in:
Yurii committed 2026-12-04 15:12:16 +03:00
1 parent cea8231015
commit 54caf4fd7f
16 files changed
+441 -123

No files matched your search

+6 -2
View File
@@ -170,14 +170,18 @@
"ethernet": {
"unavailable": "此固件版本不支持以太网。",
"notConfigured": "配置全部六个 GPIO 引脚以使用以太网。",
"controller": "以太网控制器",
"clk": "SPI clock GPIO",
"mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO",
"irq": "Interrupt GPIO",
"rst": "Reset GPIO",
"note": "W5500 SPI 接线"
"phyAddr": "PHY 地址",
"clockMode": "RMII 时钟",
"mdc": "MDC GPIO",
"mdio": "MDIO GPIO",
"power": "电源/复位 GPIO(可选)"
},
"wifi": {
"ssid": "SSID",
+6 -2
View File
@@ -170,14 +170,18 @@
"ethernet": {
"unavailable": "This firmware build does not support Ethernet.",
"notConfigured": "Configure all six GPIOs to use Ethernet.",
"controller": "Ethernet controller",
"clk": "SPI CLK GPIO",
"mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO",
"irq": "IRQ GPIO",
"rst": "RST GPIO",
"note": "W5500 SPI wiring"
"phyAddr": "PHY address",
"clockMode": "RMII clock",
"mdc": "MDC GPIO",
"mdio": "MDIO GPIO",
"power": "Power/reset GPIO (optional)"
},
"wifi": {
"ssid": "SSID",
+6 -2
View File
@@ -170,14 +170,18 @@
"ethernet": {
"unavailable": "Questa versione del firmware non supporta Ethernet.",
"notConfigured": "Configura tutti e sei i GPIO per utilizzare Ethernet.",
"controller": "Controller Ethernet",
"clk": "SPI clock GPIO",
"mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO",
"irq": "Interrupt GPIO",
"rst": "Reset GPIO",
"note": "Cablaggio SPI del W5500"
"phyAddr": "Indirizzo PHY",
"clockMode": "Clock RMII",
"mdc": "MDC GPIO",
"mdio": "MDIO GPIO",
"power": "GPIO alimentazione/reset (opzionale)"
},
"wifi": {
"ssid": "SSID",
+6 -2
View File
@@ -170,14 +170,18 @@
"ethernet": {
"unavailable": "Deze firmwarebuild ondersteunt geen Ethernet.",
"notConfigured": "Configureer alle zes GPIO's om Ethernet te gebruiken.",
"controller": "Ethernetcontroller",
"clk": "SPI clock GPIO",
"mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO",
"irq": "Interrupt GPIO",
"rst": "Reset GPIO",
"note": "W5500 SPI-bedrading"
"phyAddr": "PHY-adres",
"clockMode": "RMII-klok",
"mdc": "MDC GPIO",
"mdio": "MDIO GPIO",
"power": "Voedings-/reset-GPIO (optioneel)"
},
"wifi": {
"ssid": "SSID",
+6 -2
View File
@@ -170,14 +170,18 @@
"ethernet": {
"unavailable": "Эта сборка прошивки не поддерживает Ethernet.",
"notConfigured": "Для подключения через Ethernet настройте все шесть GPIO.",
"controller": "Контроллер Ethernet",
"clk": "SPI clock GPIO",
"mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO",
"irq": "Interrupt GPIO",
"rst": "Reset GPIO",
"note": "Подключение W5500 по SPI"
"phyAddr": "Адрес PHY",
"clockMode": "Тактирование RMII",
"mdc": "MDC GPIO",
"mdio": "MDIO GPIO",
"power": "GPIO питания/сброса (необязательно)"
},
"wifi": {
"ssid": "Имя сети",
+97 -15
View File
@@ -101,37 +101,84 @@
<div>
<p class="unsupported hidden" data-i18n>network.ethernet.unavailable</p>
<fieldset class="supported">
<label>
<span data-i18n>network.ethernet.controller</span>
<select name="ethernet[type]">
<option value="0">NONE</option>
</select>
</label>
</fieldset>
<fieldset id="ethernet-w5500">
<legend><b>W5500</b></legend>
<div class="grid">
<label>
<span data-i18n>network.ethernet.clk</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][clk]" min="0" max="254" step="1">
<input type="number" inputmode="numeric" name="ethernet[w5500][clk]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.mosi</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][mosi]" min="0" max="254" step="1">
<input type="number" inputmode="numeric" name="ethernet[w5500][mosi]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.miso</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][miso]" min="0" max="254" step="1">
<input type="number" inputmode="numeric" name="ethernet[w5500][miso]" min="0" max="254" step="1">
</label>
</div>
<div class="grid">
<label>
<span data-i18n>network.ethernet.cs</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][cs]" min="0" max="254" step="1">
<input type="number" inputmode="numeric" name="ethernet[w5500][cs]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.irq</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][irq]" min="0" max="254" step="1">
<input type="number" inputmode="numeric" name="ethernet[w5500][irq]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.rst</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][rst]" min="0" max="254" step="1">
<input type="number" inputmode="numeric" name="ethernet[w5500][rst]" min="0" max="254" step="1">
</label>
</div>
</fieldset>
<fieldset id="ethernet-lan8720">
<legend><b>LAN8720</b></legend>
<div class="grid">
<label>
<span data-i18n>network.ethernet.phyAddr</span>
<input type="number" inputmode="numeric" name="ethernet[lan8720][phy_addr]" min="0" max="31" step="1" required>
</label>
<label>
<span data-i18n>network.ethernet.clockMode</span>
<select name="ethernet[lan8720][clock_mode]">
<option value="0">GPIO0 IN</option>
<option value="1">GPIO0 OUT</option>
<option value="2">GPIO16 OUT</option>
<option value="3">GPIO17 OUT</option>
</select>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>network.ethernet.mdc</span>
<input type="number" inputmode="numeric" name="ethernet[lan8720][mdc]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.mdio</span>
<input type="number" inputmode="numeric" name="ethernet[lan8720][mdio]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.power</span>
<input type="number" inputmode="numeric" name="ethernet[lan8720][power]" min="0" max="254" step="1">
</label>
</div>
</fieldset>
@@ -418,18 +465,35 @@
const lang = new Lang(document.getElementById('lang'));
await lang.build();
const ethernetType = document.querySelector("[name='ethernet[type]']");
const fillNetworkSettings = (settings) => {
setSelectValue("[name='type']", settings.type);
setSelectValue("[name='type']", ethernetType.disabled ? 2 : settings.type);
setInputValue("[name='hostname']", settings.hostname);
setCheckboxValue("[name='use_dhcp']", settings.use_dhcp);
for (const field of ['ip', 'gateway', 'subnet', 'dns']) {
setInputValue(`[name='static_config[${field}]']`, settings.static_config[field]);
}
if (settings.ethernet?.gpio) {
for (const pin of ['clk', 'mosi', 'miso', 'cs', 'irq', 'rst']) {
const value = settings.ethernet.gpio[pin];
setInputValue(`[name='ethernet[gpio][${pin}]']`, value < 255 ? value : '');
const ethernet = settings.ethernet;
if (ethernet) {
ethernetType.value = ethernet.type;
if (ethernet.w5500) {
for (const gpio of ['clk', 'mosi', 'miso', 'cs', 'irq', 'rst']) {
const value = ethernet.w5500[gpio];
setInputValue(`[name='ethernet[w5500][${gpio}]']`, value < 255 ? value : '');
}
}
if (ethernet.lan8720) {
for (const gpio of ['mdc', 'mdio', 'power']) {
const value = ethernet.lan8720[gpio];
setInputValue(`[name='ethernet[lan8720][${gpio}]']`, value < 255 ? value : '');
}
setInputValue("[name='ethernet[lan8720][phy_addr]']", ethernet.lan8720.phy_addr);
setSelectValue("[name='ethernet[lan8720][clock_mode]']", ethernet.lan8720.clock_mode);
}
}
@@ -454,11 +518,29 @@
}
const settings = await response.json();
if (!settings.ethernet) {
const ethernet = settings.ethernet;
if (ethernet?.w5500) {
ethernetType.add(new Option('W5500', '1'));
} else {
document.getElementById('ethernet-w5500').remove();
}
if (ethernet?.lan8720) {
ethernetType.add(new Option('LAN8720', '2'));
} else {
document.getElementById('ethernet-lan8720').remove();
}
// The API includes settings only for Ethernet drivers built into this firmware.
if (!ethernet?.w5500 && !ethernet?.lan8720) {
show('.ethernet .unsupported');
const gpioFields = document.querySelector('.ethernet .supported');
gpioFields.classList.add('hidden');
gpioFields.disabled = true;
hide('.ethernet .supported');
ethernetType.disabled = true;
// Value 3 in the network mode selector is Ethernet (NetworkMode::ETH).
document.querySelector("[name='type'] [value='3']").disabled = true;
}
fillNetworkSettings(settings);
+34 -12
View File
@@ -1,4 +1,5 @@
const convertLegacyBackup = (data) => {
// 1.x to 2.0.0: rename legacy settings keys throughout the backup.
const aliases = {
alwaysSendIndoorTemp: 'always_send_indoor_temp',
antiStuckInterval: 'antistuck_interval',
@@ -61,8 +62,8 @@ const convertLegacyBackup = (data) => {
useDhcp: 'use_dhcp',
webSerial: 'web_serial'
};
const logLevels = [0, 1, 1, 2, 3, 3, 4, 5];
// 1.x to 2.0.0: apply the key aliases recursively, including objects inside arrays.
const convert = (value) => {
if (Array.isArray(value)) {
return value.map(convert);
@@ -79,6 +80,8 @@ const convertLegacyBackup = (data) => {
return result;
};
// 1.x to 2.0.0: map TinyLogger levels to ESP-IDF levels before renaming logLevel.
const logLevels = [0, 1, 1, 2, 3, 3, 4, 5];
const legacySystem = data?.settings?.system;
if (legacySystem !== null && typeof legacySystem === 'object'
&& Object.prototype.hasOwnProperty.call(legacySystem, 'logLevel')) {
@@ -98,8 +101,15 @@ const convertLegacyBackup = (data) => {
const result = convert(data);
// 1.x to 2.0.0: settings.system.unit_system became the sole unit setting.
const opentherm = result?.settings?.opentherm;
if (opentherm !== null && typeof opentherm === 'object') {
delete opentherm.unit_system;
}
const network = result?.network;
if (network !== null && typeof network === 'object' && !Array.isArray(network)) {
// 1.x to 2.0.0: move network.ap and network.sta under network.wifi.
const hasLegacyAp = Object.prototype.hasOwnProperty.call(network, 'ap');
const hasLegacySta = Object.prototype.hasOwnProperty.call(network, 'sta');
if (hasLegacyAp || hasLegacySta) {
@@ -117,28 +127,40 @@ const convertLegacyBackup = (data) => {
delete network.sta;
}
// 1.x to 2.0.0: derive network.type from the settings present in the backup.
if (!Object.prototype.hasOwnProperty.call(network, 'type')) {
if (typeof network.ethernet?.enabled === 'boolean') {
// Legacy builds with W5500 after the 1.6.0 tag (#286) stored ethernet.enabled.
network.type = network.ethernet.enabled ? 3 : 2;
} else if (hasLegacyAp || hasLegacySta) {
// Tagged 1.x releases only supported Wi-Fi.
network.type = 2;
}
}
if (network.ethernet !== null && typeof network.ethernet === 'object' && !Array.isArray(network.ethernet)) {
if (Object.prototype.hasOwnProperty.call(network.ethernet, 'pins')
&& !Object.prototype.hasOwnProperty.call(network.ethernet, 'gpio')) {
network.ethernet.gpio = network.ethernet.pins;
const ethernet = network.ethernet;
if (ethernet !== null && typeof ethernet === 'object' && !Array.isArray(ethernet)) {
// Post-1.6.0 legacy (#286) to 2.0.0: rename ethernet.pins to ethernet.gpio.
if (Object.prototype.hasOwnProperty.call(ethernet, 'pins')
&& !Object.prototype.hasOwnProperty.call(ethernet, 'gpio')) {
ethernet.gpio = ethernet.pins;
}
delete network.ethernet.pins;
delete network.ethernet.enabled;
}
}
delete ethernet.pins;
delete ethernet.enabled;
const opentherm = result?.settings?.opentherm;
if (opentherm !== null && typeof opentherm === 'object') {
delete opentherm.unit_system;
// 2.0.0 and 2.0.1 to the per-controller format: ethernet.gpio belonged to W5500.
const gpio = ethernet.gpio;
if (gpio !== null && typeof gpio === 'object' && !Array.isArray(gpio)) {
if (!Object.prototype.hasOwnProperty.call(ethernet, 'w5500')) {
ethernet.w5500 = gpio;
}
if (!Object.prototype.hasOwnProperty.call(ethernet, 'type')) {
ethernet.type = 1; // W5500
}
}
delete ethernet.gpio;
}
}
return result;