Skip to content

Commit

Permalink
Merge branch 'mega' into feature/Over_255_pluginIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-er authored Oct 26, 2024
2 parents 6286391 + 1afb0c4 commit 9a2af95
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 21 deletions.
76 changes: 75 additions & 1 deletion docs/source/Participate/PlatformIO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,80 @@ All builds will be made in a directory with the same name as the environment use

Once the build is successful, the .bin file(s) and .bin.gz file (where applicable) are copied to the ``build_output/bin`` folder.

VS-Code with WSL2
=================

Building ESPEasy on Windows has become more and more tedious due to various issues:

* Maximum path lengh limits
* Maximum command line length limits
* Extremely long build times

All these mainly apply to the latest ESP32-xx builds using ESP-IDF5.x.

On a beefy desktop PC, like an AMD Ryzen9 with 12 CPU cores, building a ``MAX`` build for ESP32-S3 takes about 10 - 15 minutes on Windows.
The same build when using WSL2 via VS-Code takes only 2 minutes to build.


Installing WSL2
---------------


Linking USB serial adapter to WSL2
----------------------------------

In short, a specific USB device must first be shared (using ``usbipd bind --busid <busid>`` ) and thus made unavailable from Windows.
After the USB device is 'bound' (shared), it must be attached to a specific wsl instance.

N.B. this must be repeated after a device was unplugged and replugged.

The required steps are described `here <https://learn.microsoft.com/en-us/windows/wsl/connect-usb#attach-a-usb-device>`_
However since this is rather tedious and error prone, it is strongly adviced to use a GUI tool like `WSL USB Manager <https://gitlab.com/alelec/wsl-usb-gui>`_ to perform these steps.

After attaching an USB device to a WSL instance, it is best to check whether it was found using `dmesg` via the command line on WSL2.

If only an USB device was detected but no `/dev/ttyUSBxx` was assigned, then a modprobe call is needed:

* ``sudo modprobe usbserial`` - Probably needed for any USB to serial adapter
* ``sudo modprobe ch341`` - For CH340/CH341 USB to serial chips (rectangular form chip)
* ``sudo modprobe cp210x`` - For FTDI CP210x USB to serial chips (small square form factor)
* ``sudo modprobe ftdi_sio`` - For FTDI USB to serial chips with multiple serial ports like the FTDI4232H which has 4 serial ports.

After calling these 'modprobe' commands, the result can be verified using ``lsmod`` and rechecking ``dmesg`` to see which ``/dev/ttyUSBxx`` ports were assigned.

The ownerchip and permissions of these ``/dev/ttyUSBxx`` are probably set like this:

.. highlight::sh
.. code-block::
ll /dev/ttyUSB0
crw------- 1 root root 188, 0 Oct 18 22:02 /dev/ttyUSB0
The simplest way to get this to work without constantly using ``sudo`` or run as ``root`` is to change permissions like this:

.. highlight::sh
.. code-block::
sudo chmod 666 /dev/ttyUSB0
ll /dev/ttyUSB0
crw-rw-rw- 1 root root 188, 0 Oct 18 22:02 /dev/ttyUSB0
.. note:: This is not the best way from a security point of view.

A probably more preferred method is to change ownership of the device to ``dialout`` group:

.. highlight::sh
.. code-block::
sudo adduser $(whoami) dialout
sudo chown root.dialout /dev/ttyUSB0
sudo chmod 660 /dev/ttyUSB0
ll /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Oct 18 22:14 /dev/ttyUSB0
Upload to ESP
Expand Down Expand Up @@ -447,7 +521,7 @@ After the commit is completed, more commits can be added, if desired. It is good

To have the commit(s) to be presented as a pull request, they must be published, and the easiest way to accomplish that is to use the Publish Changes button in VSCode:

.. image:: VSCode_Publish_changes.png
.. image:: VSCode_publish_changes.png
:alt: VSCode publish change button

After clicking that button, you have to select the source the changes should be published to. As we don't have (direct) write access to the upstream ESPEasy repository, we can only publish to the 'origin' (git terminology), our own fork of the repository, so that option should be selected by clicking it, or pressing the Enter key:
Expand Down
6 changes: 3 additions & 3 deletions platformio_core_defs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ extra_scripts = ${esp82xx_common.extra_scripts}
; For MUSTFIX_CLIENT_TIMEOUT_IN_SECONDS See: https://github.com/espressif/arduino-esp32/pull/6676
[core_esp32_IDF5_1_4__3_0_5_SPIFFS]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.09.10/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2962/framework-arduinoespressif32-all-release_v5.1-33fbade.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3110/framework-arduinoespressif32-all-release_v5.1-632e0c2.zip
build_flags = -DESP32_STAGE
-DESP_IDF_VERSION_MAJOR=5
-DLIBRARIES_NO_LOG=1
Expand Down Expand Up @@ -197,8 +197,8 @@ lib_extra_dirs =

; ESP_IDF 5.3.1
[core_esp32_IDF5_3_1__3_0_5_LittleFS]
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF53
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3019/framework-arduinoespressif32-all-release_v5.3-98aecc7e.zip
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.10.31/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3112/framework-arduinoespressif32-all-release_v5.3-1c74f314.zip
build_flags = -DESP32_STAGE
-DESP_IDF_VERSION_MAJOR=5
-DLIBRARIES_NO_LOG=1
Expand Down
4 changes: 2 additions & 2 deletions platformio_esp32_solo1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
; IDF 5.3.1
[esp32_solo1_common_LittleFS]
extends = esp32_base_idf5
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF53
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3020/framework-arduinoespressif32-solo1-release_v5.3-98aecc7e.zip
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.10.31/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3113/framework-arduinoespressif32-solo1-release_v5.3-1c74f314.zip
build_flags = ${esp32_base_idf5.build_flags}
-DFEATURE_ARDUINO_OTA=1
-DUSE_LITTLEFS
Expand Down
13 changes: 6 additions & 7 deletions src/src/WebServer/NotificationPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ void handle_notifications() {
String dummyString;
NPlugin_ptr[NotificationProtocolIndex](NPlugin::Function::NPLUGIN_WEBFORM_SAVE, 0, dummyString);
}

// Reload & overwrite
LoadNotificationSettings(notificationindex, reinterpret_cast<uint8_t *>(&NotificationSettings), sizeof(NotificationSettingsStruct));
NotificationSettings.validate();
NotificationSettings.Port = getFormItemInt(F("port"), 0);

NotificationSettings.Timeout_ms = getFormItemInt(F("timeout"), NPLUGIN_001_DEF_TM);
Expand All @@ -93,10 +97,9 @@ void handle_notifications() {
strncpy_webserver_arg(NotificationSettings.Receiver, F("receiver"));
strncpy_webserver_arg(NotificationSettings.Subject, F("subject"));
strncpy_webserver_arg(NotificationSettings.User, F("username"));
strncpy_webserver_arg(NotificationSettings.Pass, F("password"));
strncpy_webserver_arg(NotificationSettings.Body, F("body"));

// copyFormPassword(F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass));
copyFormPassword(F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass));
}
}
addHtmlError(SaveNotificationSettings(notificationindex, reinterpret_cast<const uint8_t *>(&NotificationSettings),
Expand Down Expand Up @@ -247,7 +250,6 @@ void handle_notifications() {
NotificationSettings.Timeout_ms = NPLUGIN_001_DEF_TM;
}

// FIXME TD-er: Must convert to msec as every other timeout used/configured in ESPEasy is in msec
addFormNumericBox(
F("Timeout"), F("timeout"),
NotificationSettings.Timeout_ms,
Expand All @@ -264,10 +266,7 @@ void handle_notifications() {
addFormSubHeader(F("Credentials"));

addFormTextBox(F("Username"), F("username"), NotificationSettings.User, sizeof(NotificationSettings.User) - 1);
addFormTextBox(F("Password"), F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass) - 1);

// addFormPasswordBox(F("Password"), F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass) -
// 1);
addFormPasswordBox(F("Password"), F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass) - 1);

addFormSubHeader(F("Email Attributes"));

Expand Down
23 changes: 15 additions & 8 deletions src/src/WebServer/TimingStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ void handle_timingstats() {
sendHeadandTail_stdtemplate(_HEAD);
html_table_class_multirow();
html_TR();
html_table_header(F("Description"));
html_table_header(F("Function"));
html_table_header(F("#calls"));
html_table_header(F("call/sec"));
html_table_header(F("duty (%)"));
html_table_header(F("min (ms)"));
html_table_header(F("Avg (ms)"));
html_table_header(F("max (ms)"));
{
const __FlashStringHelper * headers[] = {
F("Description"),
F("Function"),
F("#calls"),
F("call/sec"),
F("duty (%)"),
F("min (ms)"),
F("Avg (ms)"),
F("max (ms)")};
for (unsigned int i = 0; i < NR_ELEMENTS(headers); ++i) {
html_table_header(headers[i]);
}
}


const long timeSinceLastReset = stream_timing_statistics(true);
html_end_table();
Expand Down
10 changes: 10 additions & 0 deletions tools/set_tty_permissions_WSL2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

sudo modprobe usbserial
sudo modprobe ch341
sudo modprobe cp210x
sudo modprobe ftdi_sio


sudo chmod 666 /dev/ttyACM*
sudo chmod 666 /dev/ttyUSB*

0 comments on commit 9a2af95

Please sign in to comment.