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

v3.0.0 detects / defaults to wrong XTAL frequency on ESP32-D0WDQ6-V3 - millis and UART baud are not correct #9837

Closed
1 task done
PaulZC opened this issue Jun 12, 2024 · 10 comments · Fixed by #9844
Closed
1 task done
Labels
3.0 migration issue relates to migration from 2.X to 3.X version Type: 3rd party Boards
Milestone

Comments

@PaulZC
Copy link
Contributor

PaulZC commented Jun 12, 2024

Board

SparkFun ESP32 Thing

Device Description

The SparkFun ESP32 Thing is a 3rd Party Board based on the ESP32-D0WDQ6-V3 chip with a 26MHz XTAL

https://www.sparkfun.com/products/13907

image

Hardware Configuration

Only USB

Version

v3.0.0

IDE Name

Arduino IDE

Operating System

Windows

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

A full write-up, diagnosis and fix available at: sparkfun/ESP32_Thing_Plus#7

In cores below 3.0.0, the XTAL frequency was detected correctly. millis and UART baud rates were correct.

From 3.0.0, the XTAL frequency is detected as or defaults to 40MHz. millis and UART baud rates are off by a factor of 1.54.

Using the Serial_All_CPU_Freqs example:

For the 2.0.17 version it produces ...
CPU Freq = 240 MHz
XTAL Freq = 26 MHz
APB Freq = 80000000 Hz

For the 3.0.1 version it produces ...
CPU Freq = 240 MHz
XTAL Freq = 40 MHz
APB Freq = 80000000 Hz

We have a work-around:

#include "soc/rtc.h"

  rtc_clk_xtal_freq_update((rtc_xtal_freq_t)26);
  rtc_clk_cpu_freq_set_xtal();
  setCpuFrequencyMhz(240);

But it would be really nice if the core could be corrected / updated... Thanks!

Sketch

https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/Serial/Serial_All_CPU_Freqs/Serial_All_CPU_Freqs.ino

Debug Message

N/A

Other Steps to Reproduce

N/A

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@igrr
Copy link
Member

igrr commented Jun 12, 2024

Have ran into the same issue, seems like the setting has changed from

CONFIG_ESP32_XTAL_FREQ_AUTO=y

to
https://github.com/espressif/esp32-arduino-libs/blob/a6dac936bfcfa4c11468e003f550b41c76efeae6/esp32/sdkconfig#L1086

@me-no-dev
Copy link
Member

We could not keep the crystal to AUTO, because other things stopped working. I can not recall what was exactly breaking, but it was critical.

@PaulZC
Copy link
Contributor Author

PaulZC commented Jun 12, 2024

That might explain it! ;-) Many thanks Ivan. Best wishes.

@PaulZC
Copy link
Contributor Author

PaulZC commented Jun 12, 2024

Many thanks @me-no-dev,

I don't want this to soak up much of your time - especially as the ESP32-D0WDQ6-V3 is NRND, and I think this is the only SparkFun board with a 26MHz crystal, and the work-around works...

Maybe it could be possible to specify / override the XTAL frequency through boards.txt?

Best wishes,
Paul

@me-no-dev
Copy link
Member

Maybe it could be possible to specify / override the XTAL frequency through boards.txt?

Unfortunately this would require rework that is just not worth for a single type of board (I also do not know of another board with 26MHz crystal) which was manufactured in the very early ESP32 days. I have a few myself and would rather replace their crystals. Would have been great if we could keep the crystal to AUTO also. I tried to find out what was happening, but the change came in a PR with many, many changes and message was not so clear.

@igrr
Copy link
Member

igrr commented Jun 12, 2024

I also do not know of another board with 26MHz crystal

In my case it was with Heltec Lora boards, they used to come with 26 MHz XTALs. Unfortunately replacing an XTAL is not an option for me, but I went back to v2.0.x for the time being.

@me-no-dev
Copy link
Member

I went back to v2.0.x for the time being.

You could try the workaround above

@me-no-dev
Copy link
Member

me-no-dev commented Jun 12, 2024

Created PR with support for SparkFun ESP32 Thing: #9844

@igrr similar thing can be done for your board too (or even through menu that adds -DF_XTAL_MHZ=26)

@PaulZC
Copy link
Contributor Author

PaulZC commented Jun 13, 2024

Excellent - thank you @me-no-dev

@dfrodin
Copy link

dfrodin commented Jun 24, 2024

I am the developer who originally reported the "ESP32 Thing" board CPU frequency issue to Sparkfun. I've retested with the 3.0.2 version of the ESP32 library and everything is behaving correctly. Thanks for your efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 migration issue relates to migration from 2.X to 3.X version Type: 3rd party Boards
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants