-
Notifications
You must be signed in to change notification settings - Fork 121
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
Need to use a different SPI_MODE on ESP32 (SPI_MODE1) #57
Comments
Is this a bug in ESP32's SPI library? If so, it should be fixed there. |
Good question. Because I was told to try using a different mode, I assumed different architectures could define them differently. If there are standard definitions and this flash chip inherently should be mode 0, then you're probably right. This seems like something somebody would have noticed before though on their end. Would you expect this to be an arduino-esp32 issue, or an esp32 core issue? |
These modes absolutely are standard definitions (or at least de-facto standards - not necessarily something published by a standards organization like IEEE or JEDEC). SPI_MODE0 is supposed to do the same thing on all microcontrollers. If ESP32 is doing something different from everyone else, that's definitely a bug with ESP32. However, it's also possible there could be some other subtle problem. Very hard to know without a deep investigation by looking at the actual waveforms. |
That definitely makes sense. I submitted a ticket to them. Unfortunately I don't have a way to look at the waveforms (and honestly wouldn't really know what I'm looking at anyways). Hopefully somebody on there can verify whether the handling of the SPI modes is correct. |
Hi all, i found the problem, and it no in SPI mode.
Take first two bytes and an analyse them ...now in bin
and now i see only esp8266 in it. Sorry for my bad english.... Nice day.... |
@fa1ke5 - Thanks for the input. I looked at your investigation in #58, and tried changing the maximum speed parameter instead of the SPI mode: #define SPICONFIG SPISettings(26000000, MSBFIRST, SPI_MODE0) This appears to be working correctly now. While you may be right that some special definition for I think a few questions back to @PaulStoffregen
|
Did you copy all code of defines with low level functions, like this |
#define SPICONFIG SPISettings(26000000, MSBFIRST, SPI_MODE0) you are right, 26MHz is critical for MODE0. |
Do you suppose it works reliably across all chips? How about when the temperature changes? |
this is not temperature problem, its only esp32 hardware/SDK problem |
I think I have found documentation on what @fa1ke5 is referring to as the "critical" speed: If you scroll down a bit from there, you'll see a chart outlining the following frequency limits:
I haven't had a chance to go through the pinouts to trace it, but I'm going to assume the MEM_CS pin on Prop Shield isn't mapped to the ESP32 Pin 15 (CS0) through the Adafruit feather adapter (I'll verify this later, but it seems unlikely that we were lucky enough to have it map to the best pin, and the behavior is consistent). That implies we are going through the GPIO matrix, and have a limit of 26.6Mhz when not using the "dummy bit" workaround, and 40Mhz when using it. I also found this interesting header file: https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/driver/driver/spi_master.h At the top, it describes the SPI frequencies, and mentions that it will round down to the closest frequency. Since SerialFlash hard codes 50Mhz, it is rounded down to 40Mhz and fails. I tried specifying 30Mhz (which would round it down to 26Mhz), and it worked fine. Because we have a R/W workload with SerialFlash (not write-only), we probably shouldn't use the dummy-bit workaround. As such, I think the best course of action is to make the SPICONFIG configurable. I say this for 2 reasons:
I presume the best place to do this would be to add an overloaded begin() method that allows passing in an SPISettings from the user, and setting SPICONFIG there? I'd be happy to create a pull request for this if it makes sense. |
20MHz seems more reliable
Description
I am unable to read/write from the Teensy Prop Shield's flash storage on the ESP32. This appears to be because I need to use a different SPI_MODE. I initially reported the issue to arduino-esp32 , and @stickbreaker suggested I change the SPI mode. I found that
SPI_MODE1
worked properly, while SerialFlash'sSPICONFIG
usesSPI_MODE0
. This can be seen here.I'm happy to create a PR for this, but I'm not sure how you would want to see this resolved:
Steps To Reproduce Problem
I am using a Teensy Prop Shield attached to an Adafruit ESP32 Feather. A minimal sketch is provided below
Hardware & Software
Board: Adafruit ESP32 Feather
Shields / modules used: Teensy Prop Shield
Arduino IDE version: 1.8.8
Version info & package name (from Tools > Boards > Board Manager): arduino-esp32 (latest from git)
Operating system & version: Manjaro
Arduino Sketch
Errors or Incorrect Output
Below is the output of the sketch provided above. Note that I copied the check_signature method from SerialFlash, and added some debugginng to it to print out what it is writing and the result of immediately reading that write upon finding an erased flash chip.
The text was updated successfully, but these errors were encountered: