Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0-b2] WLED stop working almost immediately on ESP32 when RX pin (GPIO03) is not pulled down (and USB IC is not attached) #3128

Closed
1 task done
wled-install opened this issue Mar 14, 2023 · 13 comments
Labels
bug discussion hardware (Likely) Setup-specific issue, e.g. flickering LEDs

Comments

@wled-install
Copy link
Contributor

What happened?

On a ESP32 based board without USB IC WLED software stops working almost immediately when RX pin (GPIO03) is not pulled down (and USB IC is not attached). After power-on WLED starts corerctly, it can be seen tat LEDs are controlled for a short time period, then it stops (no LED control signal, no GUI can be reached).
The issue is with current 0.14-b2 build. No issue with 13.3 Release.

To Reproduce Bug

  1. Take ESP32 based board without USB IC an nothing connected to RX (GPIO3) Pin.
  2. Take and connect USB adapter
  3. Erse flash and flash 14.0-b2 build
  4. Disconnect USB adapter
  5. Attach some leds to default GPIO to see if they are controlled
  6. Disconnect from the power board and connect again
  7. You will see tat LEDs are controlled for a short time, but no WLED-AP etc. since ESP32 stop working
  8. Tie GPIO3 (RX Pin) to Ground or attach USB adapter and repeat power off7on again. Now is everything fine.

Expected Behavior

Full functionality independent on what is attached or not to RX Pin

Install Method

Self-Compiled

What version of WLED?

0.14-b2 (dev branch taken on 14. of march 2023)

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@wled-install
Copy link
Contributor Author

could be HW +SW combination, closed till clarified in details

@blazoncek
Copy link
Collaborator

This may not be WLED SW related as there were no change in Serial processing in 0.14.
It may have to do with libraries used but that is beyond the scope of WLED.
My recommendation would be, if you design PCB with ESP and no USB-to-serial chip, pull-down GPIO3 (also pull-up GPIO0, GPIO1 and, in some instances, GPIO2).

@softhack007
Copy link
Collaborator

@softhack007 softhack007 added discussion hardware (Likely) Setup-specific issue, e.g. flickering LEDs labels Mar 16, 2023
@softhack007
Copy link
Collaborator

softhack007 commented Mar 16, 2023

A few ideas - but not sure if that would break other functionality

  • a) add if (!Serial) return; to catch situations where serial was not initialized (like CDC USB without cable connection)
  • b) add a limit to the while(Serial.availeable()) loop, for example 100 milliseconds
  • c) a bit of a hack in WLED.cpp: enable pulldown shortly before starting serial (not sure this will work) - pinMode(hardwareRX, INPUT_PULLDOWN); delay(1); Serial.begin(115200);

To be discussed...

Update for a): according to arduino docs "On the boards with native USB, if (Serial) indicates whether or not the USB CDC serial connection is open. For all other boards, and the non-USB CDC ports, this will always return true."

@softhack007
Copy link
Collaborator

Possibly not a SW bug, but let's discuss if we can avoid a lockup somehow

@softhack007 softhack007 reopened this Mar 16, 2023
@wled-install
Copy link
Contributor Author

pinMode(hardwareRX, INPUT_PULLDOWN); delay(1) or external pull-down or pull-up helps at low noise energy. It must be sufficient for household’s environments. For more noisy environments either dedicated EMC measures in HW needed or the possibility to switch off serial functions if not used.

So my proposal would be at least to implement pinMode(hardwareRX, INPUT_PULLDOWN); delay(1) in SW. Should not have any negative impact, easy to implement and must be enough for mainstream. Maybe additinal setting in GUI to switch serial off.

softhack007 added a commit that referenced this issue Mar 16, 2023
@blazoncek
Copy link
Collaborator

Please add DEBUG_PRINT statements around the code @softhack007 mentioned and use net debug functionality to capture debug output.

softhack007 added a commit to atuline/WLED that referenced this issue Mar 16, 2023
@wled-install
Copy link
Contributor Author

Not the net debug (not possible with the issue) but normal serial debug on TX pin:

  1. without fix: something like this
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1256
load:0x40078000,len:12040
load:0x40080400,len:5984
entry 0x40080688
Ada
Baud is now 500000
<0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0><0>

or this:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1256
load:0x40078000,len:12040
load:0x40080400,len:5984
entry 0x40080688
Ada
Baud is now 1500000
<0>
  1. With fix from softhack007
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1256
load:0x40078000,len:12040
load:0x40080400,len:5984
entry 0x40080688
Ada

@blazoncek
Copy link
Collaborator

It appears that random (or EMI) data triggers Serial input.

softhack007 added a commit that referenced this issue Mar 19, 2023
This flag disables reading commands from serial interface (RX = gpio 3)

Add -D WLED_DISABLE_ADALIGHT to your custom pio build environment.
@softhack007
Copy link
Collaborator

softhack007 commented Mar 19, 2023

Maybe additional setting in GUI to switch serial off.

Its not by GUI yet, but you could un-define WLED_ENABLE_ADALIGHT in wled.h
This disables reading from hardwareRX in handleSerial().

#define WLED_ENABLE_ADALIGHT // saves 500b only (uses GPIO3 (RX) for serial)

void handleSerial()
{
if (pinManager.isPinAllocated(hardwareRX)) return;
if (!Serial) return; // arduino docs: `if (Serial)` indicates whether or not the USB CDC serial connection is open. For all non-USB CDC ports, this will always return true
#ifdef WLED_ENABLE_ADALIGHT


With commit fd89209, I've added the flag WLED_DISABLE_ADALIGHT so that you can disable use of RX pin in your custom platformio_override.ini build env.

@wled-install
Copy link
Contributor Author

With commit fd89209, I've added the flag WLED_DISABLE_ADALIGHT so that you can disable use of RX pin in your custom platformio_override.ini build env.

Yeah, I've seen this #define in the code, thank you!

@wled-install
Copy link
Contributor Author

It appears that random (or EMI) data triggers Serial input.

Yes it is definately. For low noise energy the solution from softhack is sufficient. For more noisy enviroment we can turn serial off by define (or maybe in future someone make a switch in the GUI). I think the issue can be closed.

@softhack007
Copy link
Collaborator

Thanks for the feedback :-) There is only one downside of -D WLED_DISABLE_ADALIGHT - it also disables IMPROV, which works over serial. So web installers cannot configure Wifi settings after install any more when using this option.

imcmib added a commit to imcmib/WLED that referenced this issue Mar 20, 2023
* added klipper usermod

* enabled IP Change and updated the Readme

* Added spreading from center and fixed the enable

* fixing the PR conflict

* bugfixes

* xml.cpp: correct type for checkbox global led buffer" (was not shown correctly)
* fx.cpp: 2D floating blobs - correct swapped x/y coordinates (did not render correctly on non-square matrix)

* update build nr

and npm run build

* Delete wled00.ino.cpp

accident

* Whitespace.

* Art-Net transmit support for network LEDs

Like DDP, this allows WLED to address network systems using the Art-Net protocol.

Universe starts at zero, because that's the first universe in Art-Net.

Works with RGB. It's coded to also work with RGBW, but I couldn't find a great place to enable it without mucking with things I don't understand.

* whitespace cleanup

* PROGMEM for header

* Fix for Aircoookie#2542.
UI rebuild.

* workaround for issue Aircoookie#3128

* adding wled00.ino.cpp to gitignore

to avoid future accidents in GH Desktop

* Fix typing  to resolve build errors after installing the mpu6050_imu usermod.

* adding WLED_DISABLE_ADALIGHT (issue Aircoookie#3128

This flag disables reading commands from serial interface (RX = gpio 3)

Add -D WLED_DISABLE_ADALIGHT to your custom pio build environment.

* typo

* comment updated

Also "Serial JSON" is not possible when reading from RX pin is disabled.

---------

Co-authored-by: lost-hope <s.willrodt@yahoo.de>
Co-authored-by: Frank <frank.moehle@outlook.de>
Co-authored-by: Frank <91616163+softhack007@users.noreply.github.com>
Co-authored-by: Blaz Kristan <blaz@kristan-sp.si>
Co-authored-by: TroyHacks <5659019+troyhacks@users.noreply.github.com>
Co-authored-by: Ryan Horricks <ryan.horricks@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug discussion hardware (Likely) Setup-specific issue, e.g. flickering LEDs
Projects
None yet
Development

No branches or pull requests

3 participants