-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[ESP32-C2] Flash chip speed set to 60 MHz, but SPI clock = 40 #8960
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
Comments
In the function arduino-esp32/cores/esp32/esp32-hal-cpu.c Lines 233 to 244 in 609a947
However this function is available on those platforms: Thus I would expect Edit: |
This makes me wonder, whether this PR I made last month was correct for the ESP32-C2. |
@me-no-dev |
sounds like you want to copy CLK out. It might be possible, yes. You just need to matrixOut the specific SPI_CLK signal to a GPIO of your choice. Also, I do not guarantee that such signals exist for the matrix, because those SPI buses are "reserved" only for Flash and PSRAM and are always routed directly to the predefined GPIOs. Going through the matrix has some speed penalties. |
I looked through the docs and not yet 100% sure it can't be done. This raises the question if anyone ever has seen ESP32-C2 units with external flash? |
OK, looks like I need to use And according to its documentation I need to pick one of the functions mentioned in Or do I need to use I find the documentation quite confusing as the docs clearly state where to look but those don't seem to refer to a function index, but rather some register (offset?). This define in |
I don't even have a C2 board yet 😆 |
I have bought a few of them from different vendors on Ali just to make sure I get the entire range from Espressif-original to the cheapest garbage available. Anyway, it is clear the flash is running at 60 MHz, and thus the reported SPI bus frequency is wrong. (and the IDF documentation for |
Hello, Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket. Thanks. |
Board
ESP32-C2
Device Description
4MB ESP32-C2
Hardware Configuration
Nothing attached
Version
latest master (checkout manually)
IDE Name
PlatformIO
Operating System
Windows 11
Flash frequency
60MHz
PSRAM enabled
no
Upload speed
115200
Description
Flash speed in the board definition is set to 60 MHz, but reported SPI clock speed is 40 MHz.
This is my code to get the SPI bus clock frequency:
Which returns this log on my (ESPEasy) system:
As can be seen, bit31 is not set to 0, and thus it is not equal to the system clock.
See:
arduino-esp32/cores/esp32/esp32-hal-spi.c
Lines 1502 to 1525 in 609a947
spi_clock register value of
0x7FC
=011111 111100
and thus onlyclkcnt_l
andclkcnt_h
are set, the rest is 0.Meaning
spiClockDivToFrequency()
returns just the APB frequency, which is 40 MHz.I also tested with SPI bus 0:
Here all bits of
spi_clock
are 0.I wonder whether this calculation and/or register interpretation is correct for the C2. (and others?)
Or perhaps the reported APB frequency is incorrect?
See:
arduino-esp32/cores/esp32/esp32-hal-cpu.c
Lines 157 to 166 in 609a947
As can be seen with the H2, this can be something other than 40 or 80 MHz, which makes perfect sense given the H2 runs at 96 MHz CPU clock.
So I wonder whether the defined APB clock frequency for the C2 is correct.
Maybe this one should be 60 MHz?
The APB clock for the C6 seems a bit odd, as it is defined as 40 MHz, while
MODEM_APB_CLK_FREQ
is 80 MHz. For all other platforms (except the H2) the APB clock has a higher frequency than the ROM (boot?) frequency and the same frequency asMODEM_APB_CLK_FREQ
when defined.N.B. my recent PR on the ESP-IDF repo to fix address calculation for
REG_SPI_BASE(i)
was incorrectly merged by the IDF team.So if you run it with the current implementation of the IDF code, you will get an out of bounds error as the base address always returns 0 with this incorrect code.
I'm using this for the
REG_SPI_BASE
:N.B.2 Not 100% sure about this for the ESP32-C6
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: