10000 esp32: Restore ESP32-C3 brownout detector settings to IDF defaults. by projectgus · Pull Request #15610 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

esp32: Restore ESP32-C3 brownout detector settings to IDF defaults. #15610

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

Merged

Conversation

projectgus
Copy link
Contributor
@projectgus projectgus commented Aug 7, 2024

Summary

PR #7715 added the ESP32_GENERIC_C3_USB board (now merged with ESP32_GENERIC_C3) and changed the brownout detector from the default level 7 (~2.51V) to level 4 (~2.92V).

Going back to the default level seems to fix random BOD resets on some of the cheaper ESP32-C3 dev boards (that likely skimp on power supply capacitance.) Specifically, this change prevents random resets running multi_bluetooth tests on ESP32-C3 "SuperMini" board.

Also removed from the LOLIN_C3_MINI board (#8396) as it seems this config is a copy of the generic one.

Found while testing #15523.

Testing

On both master (IDF V5.0.4) and the IDF V5.2.2 update branch, running multi_bluetooth tests on the "SuperMini" board triggers random software resets. The same tests pass on Espressif DevKit-C3 boards. With this fix, the software resets go away on the cheap board.

The multi_bluetooth tests still randomly fail on the "SuperMini" board, but the new failures are timeouts, and increasing the test timeouts mostly makes those failures go away. I think the signal integrity is bad enough that a lot of BLE transfers have to be retried. I was going to submit a PR that raises the timeouts in the multi_bluetooth tests, but I think they're pretty high already - the root cause is that boards like this "SuperMini" are only just good enough to work, and not good enough to work well.

Trade-offs and Alternatives

I don't know why the brownout detector settings were changed for the C3_USB board (they were never changed for the generic C3 board). If it was to fix some other issue then maybe it should be left alone, but I can't find any reference to what that issue might have been.

This work was funded through GitHub Sponsors.

@projectgus
Copy link
Contributor Author

@xorbit Hi! I don't suppose you remember why you needed to increase the brownout detector voltage when you added C3 USB support?

Copy link
Member
@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me.

At least for our generic board definitions we should use the IDF defaults where possible. The IDF has a reason for them having the defaults they do, and unless we have a good reason to change, they should stay as the default.

For the Lolin board, that probably was just copied from the generic definition, so should be changed to the default as well.

@dpgeorge
Copy link
Member
dpgeorge commented Aug 7, 2024

I was going to submit a PR that raises the timeouts in the multi_bluetooth tests, but I think they're pretty high already

I also sometimes see timeouts on the multi_bluetooth tests, and it's definitely more common on esp32 boards. I rarely see timeouts on stm32-based boards with BLE (eg PYBD). I never spent time to investigate this and put it down to either hardware differences (antenna layout) or environmental interference.

@projectgus
Copy link
Contributor Author

I also sometimes see timeouts on the multi_bluetooth tests, and it's definitely more common on esp32 boards. I rarely see timeouts on stm32-based boards with BLE (eg PYBD).

Interesting, I think the only timeouts I've seen with this round of testing were on this one board. All my other ESP32 boards are genuine Espressif boards though, using their modules.

If timeouts are more commonplace then maybe it is worth bumping up some of the timeouts, though.

@dhalbert
Copy link
Contributor
dhalbert commented Aug 7, 2024

In CircuitPython, we noticed wifi had problems connecting when using maximum power as the default on some ESP32-C3 boards with chip antennas, and lowered the default power. We speculate this may be due to less-than-ideal impedance matching. At higher powers RF could be getting back into the chip. We didn't see resets.

BLE wouldn't normally run at such high power, I think, but I wonder about the RF network on these boards and its effect on BLE and WiFi performance.

@dpgeorge
Copy link
Member
dpgeorge commented Aug 7, 2024

If timeouts are more commonplace then maybe it is worth bumping up some of the timeouts, though.

From memory the main timeouts are on the initial connect, so it may be worth bumping those particular timeouts.

@projectgus
Copy link
Contributor Author

Thanks @dhalbert, maybe we should consider adjusting default power as well.

Weirdly I only saw the brownout reset running bluetooth tests, not any wifi ones. Although the wifi performance does seem a little lackluster (nothing I measured, just slow to associate with the AP - I expect there's a lot of packet loss).

So not sure what to put that down to.

@dpgeorge
Copy link
Member
dpgeorge commented Aug 7, 2024

Although the wifi performance does seem a little lackluster (nothing I measured, just slow to associate with the AP - I expect there's a lot of packet loss).

There is a MicroPython iperf3 implementation you can use to test network performance: mpremote mip install iperf3.

@xorbit
Copy link
Contributor
xorbit commented Aug 7, 2024

@xorbit Hi! I don't suppose you remember why you needed to increase the brownout detector voltage when you added C3 USB support?

No it's been a while, I don't remember why I added the brownout settings that I did. If I had to guess, it's probably because I was using an ESP32-C3-MINI-1 module which lists the minimum supply voltage as 3.0V in section 4.2. Interestingly, the ESP32-C3 itself also lists 3.0V as minimum supply voltage in section 5.2.

Personally I would feel like properly keeping the chip in a known good state by brownout reset might be preferred over marginal/intermittent operation, but that's straying into policy, so that's for Damien to decide. I could understand trying to support cheap boards as well as possible, on the other hand if it's "working" but flaky it could also damage MicroPython's reputation if someone tried it.

@projectgus
Copy link
Contributor Author

Thanks @xorbit, appreciate the insight into your reasoning. Seems sensible!

I could understand trying to support cheap boards as well as possible, on the other hand if it's "working" but flaky it could also damage MicroPython's reputation if someone tried it.

I can see this reasoning, although actually I think it could work both ways here. The board does appear to work (with poor but functional RF performance) on the default ESP-IDF settings. On MicroPython it currently randomly resets due to the BOD, and it doesn't do that on ESP-IDF and likely won't do that on Arduino, platform.io, etc. if the ESP-IDF defaults are used. So the naive conclusion could be that there's a problem with MicroPython.

Although I totally agree that these are poor quality boards and we shouldn't go out of our way to support them.

(An aside, I'm convinced one of the reasons ESP8266 had an early reputation for being flaky was the generally garbage ESP-01 breakouts that often only had one tiny ceramic cap on them. It's amazing a Wi-Fi radio works at all in that environment, let alone works mostly OK!)

@xorbit
Copy link
Contributor
xorbit commented Aug 7, 2024

You are right, BOR reset looks flaky as well, bad connection is more functional. I agree the generic image should use the IDF defaults.

Commit a66bd7a added the
ESP32_GENERIC_C3_USB board (now merged with ESP32_GENERIC_C3) and changed
the brownout detector from the default level 7 (~2.51V) to level 4
(~2.92V).

Raising the level again seems to fix random BOD resets on some of the
cheaper ESP32-C3 dev boards (that likely skimp on power supply
capacitance).

Specifically, this change prevents random resets running multi_bluetooth
tests on ESP32-C3 "SuperMini" board.

Also removed from the LOLIN_C3_MINI board as it seems this config is a copy
of the generic one.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
@dpgeorge dpgeorge force-pushed the bugfix/esp32c3_brownout_detector branch from 8c4db65 to e71a324 Compare August 16, 2024 03:31
@dpgeorge
9F53 Copy link
Member

Rebased on master (IDF 5.2.2 changes) and tested WiFi on ESP32-C3-DevKitC-02.

@dpgeorge dpgeorge merged commit e71a324 into micropython:master Aug 16, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0