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

resetting via esp_restart() does not flush UART hardware TX-FIFO (IDFGH-4123) #5990

Closed
JB-DX opened this issue Oct 16, 2020 · 4 comments
Closed
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@JB-DX
Copy link

JB-DX commented Oct 16, 2020

ESP-IDF: v4.2-dev-994-gc9f29e0b5-dirty

Problem:
When an app has been restarted via esp_restart(), the uart tx hardware fifo appears to contain some random bytes that are not immediately sent out.

What we did:
At startup uart_driver_install() is called and then followed by this 9-bytes test-sequence.
uart_write_bytes(2, "\x11\x22\x33\x44\x54\x66\x77\x88\x99", 9);

During a normal power-up boot that sequence is seen at the UART-TX output.
The second line is a message of our protocol

11 22 33 44 54 66 77 88 99 
55 AA 01 FC 16 4C 01 20 33 73 54 65 72 6D 2D 46 39 38 43 3A 39 30 30 35 00 00 00 55 47 

After a esp_restart() initiated boot the same number of bytes are sent but have different values. Now the UART sends the test-sequence starting at byte #3 in the second line, which is part of our protocol. The protocol bytes start at byte #12. The message it too short, thus destroying our protocol.
Result: the byte protocol used in our application can't work anymore.

BF C1 55 74 70 93 DE 2D B2 
6E 65 11 22 33 44 54 66 77 88 99 55 AA 01 FC 16 4C 01 20 33 73 54 65 72 6D 2D 46 39 38 

Only re-applying power fixes this odd UART behaviour.
I ran into this problem after an OTA update that calls esp_restart()

Is there a way to reset the UART hardware and its FIFO?

Or better: How can a hardware reset be triggered via software?
I can't use any IO-port for it, as the hardware boards are already in production.

Why on earth does the UART TX-FIFO keep bytes without sending them?
Or is there a different reason?

@github-actions github-actions bot changed the title resetting via esp_restart() does not flush UART hardware TX-FIFO resetting via esp_restart() does not flush UART hardware TX-FIFO (IDFGH-4123) Oct 16, 2020
@negativekelvin
Copy link
Contributor

46713a5

@JB-DX
Copy link
Author

JB-DX commented Oct 17, 2020

Thanks for that.
I just downloaded the most recent esp-idf and now it works. Great that it already had been solved a few months ago.

@AxelLin
Copy link
Contributor

AxelLin commented Oct 19, 2020

Seems this fix is only in master tree now, other branches also needs the fix.

@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting and sorry for slow turnaround.

  • Fix on release/4.2 is available 7dbd5e1
  • Fix on release/4.1 is available ab1f629
  • Fix on release/4.0 is available at 6769057
  • Fix on release/3.3. is available c0aee61

Feel free to reopen.

@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Done Issue is done internally labels Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

5 participants