Winbond W25Q256JVFM flash parameters with ESP32 doubt

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
RcoreL
 
Posts: 3
Joined: Tue May 14, 2024 8:35 am

Winbond W25Q256JVFM flash parameters with ESP32 doubt

Post by RcoreL »

Hello!

I am trying to connect the ESP32-WROOM-32UE with one winbond W25Q256JVFM flash using Dual SPI.I want to use this flash in addition to the internal flash of the ESP32, i mean, i want to use 2 flash at the same time.
I need to fill these variables that appear on the adafruit library (flash_devices.h):

Code: Select all

#define W25Q256JV                                                              
  {                                                                            
    .total_size = (1UL << 25), /* 32 MiB */                                    
    .start_up_time_us = 5000, .manufacturer_id = 0xef,                     
    .memory_type = 0x70, .capacity = 0x19, .max_clock_speed_mhz = 133,         
    .quad_enable_bit_mask = 0x00, .has_sector_protection = true,              
    .supports_fast_read = true, .supports_qspi = true,                         
    .supports_qspi_writes = true, .write_status_register_split = false,        
    .single_status_byte = false, .is_fram = false,                             
  }
  
I am pretty sure that connections are right because al receive some information of the flash (written below).

I look for all the data in the datasheet (https://www.winbond.com/resource-files/ ... 032017.pdf) but it is not really clear. I need to know what to fill in all these gaps and prove if it is actually right with my flash model.

The only data i think is correct is: Manufacturer_id: 0xef / Memory_type: 0x70 /Capacity: 0x19. Because i use the program to ask it to the flash and it returns me this value.

Can someone help me to find and how to know what to write in here? Have i to change anything else in these files?

Thank you so much for your help!

User avatar
adafruit_support_mike
 
Posts: 67672
Joined: Thu Feb 11, 2010 2:51 pm

Re: Winbond W25Q256JVFM flash parameters with ESP32 doubt

Post by adafruit_support_mike »

The Adafruit_SPIFlash library doesn't support dual SPI, only single data line and quad data. In addition, it looks like the library doesn't support QSPI on the ESP32.

Try dropping back to single SPI and see if you can get the chip to respond that way.

User avatar
RcoreL
 
Posts: 3
Joined: Tue May 14, 2024 8:35 am

Re: Winbond W25Q256JVFM flash parameters with ESP32 doubt

Post by RcoreL »

Thank you for your answer adafruit_support_mike!

First, i want to fix the code i sent before. I am using now this define block:

Code: Select all

// Settings for the Winbond W25Q256JV 32MiB SPI flash.
// https://www.winbond.com/resource-files/w25q256jv%20spi%20revg%2008032017.pdf
#define W25Q256JVFM                                                              \
  {                                                                            \
    .total_size = (1UL << 25), /* 32 MiB */                                    \
        .start_up_time_us = 5000, .manufacturer_id = 0xef,                     \
    .memory_type = 0x70, .capacity = 0x19, .max_clock_speed_mhz = 133,         \
    .quad_enable_bit_mask = 0x00, .has_sector_protection = true,              \
    .supports_fast_read = true, .supports_qspi = true,                         \
    .supports_qspi_writes = true, .write_status_register_split = false,        \
    .single_status_byte = false, .is_fram = false,                             \
  }
  
Created array of cutom flash devices as:

Code: Select all

static const SPIFlash_Device_t my_flash_devices[] = {
     W25Q256JVFM,
};
In my code is inited as:

Code: Select all

#define EXTFLASH_SS     15
spi = std::make_shared<SPIClass>(HSPI);
flashTransport = std::make_shared<Adafruit_FlashTransport_SPI>(EXTFLASH_SS, spi.get());
flash = std::make_shared<Adafruit_SPIFlash>(flashTransport.get());
fatFS = std::make_shared<FatVolume>();
if (!flash->begin(my_flash_devices, flashDevices)) {
    DBLOG_ERROR("Error, failed to initialize external flash chip!");
    return inited;
}
And after that, I'm using the speed test example in github https://github.com/adafruit/Adafruit_SP ... edtest.ino to erase, write, read and compare what is written.
- I modified the library file Adafruit_SPIFlashBase.cpp, changing this line:

Code: Select all

#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_RP2040)
to

Code: Select all

#if 0
The idea is try to execute the init sequence for the flash, and avoid the default behavior in ESP32.

- In the file Adafruit_FlashTransport_SPI.h, we've added the custom pins and define the alternate pins:

Code: Select all

#define ALTERNATE_PINS

// Define ALTERNATE_PINS to use non-standard GPIO pins for SPI bus
#ifdef ALTERNATE_PINS
  #define HSPI_MISO   4
  #define HSPI_MOSI   2
  #define HSPI_SCLK   14
  #define HSPI_SS     15
#else
  #define HSPI_MISO   12
  #define HSPI_MOSI   13
  #define HSPI_SCLK   14
  #define HSPI_SS     15
#endif
- In the file Adafruit_FlashTransport_SPI.cpp, in begin function, we've changed the line:

Code: Select all

_spi->begin();
to:

Code: Select all

#ifndef ALTERNATE_PINS
    //initialise hspi with default pins
    _spi->begin();
#else
   //alternatively route through GPIO pins
    _spi->begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_SS); //SCLK, MISO, MOSI, SS
#endif
- It answers to JDEC IDS: ef 70 19 0
- We've also tried to uncomment the following code in function Adafruit_SPIFlashBase::begin(...) without success:

Code: Select all

// Turn off sector protection if needed
  /*if (_flash_dev->has_sector_protection)
    {
      writeEnable();
  
      uint8_t data[1] = {0x00};
      _trans->writeCommand(SFLASH_CMD_WRITE_STATUS, data, 1);
      //QSPI0.writeCommand(QSPI_CMD_WRITE_STATUS, data, 1);
  }*/
(note we've change the QSPI0 to _trans, and the QSPI_CMD_WRITE_STATUS to SFLASH_CMD_WRITE_STATUS).

To finish, using the speed test example of the adafruit library in github, calling the function "writeAndCompare(0xD1);". The example erases the first sector (Sector 0), then it writes the sector 0 with 0xD1 data and finally it reads the sector 0 and the result is this thing (not what i desire...):

Image

Thank you so much for reading me and trying to help me with this, appreciate it. :)
adafruit_support_mike wrote: Wed May 15, 2024 9:34 pm The Adafruit_SPIFlash library doesn't support dual SPI, only single data line and quad data. In addition, it looks like the library doesn't support QSPI on the ESP32.

Try dropping back to single SPI and see if you can get the chip to respond that way.

User avatar
RcoreL
 
Posts: 3
Joined: Tue May 14, 2024 8:35 am

Re: Winbond W25Q256JVFM flash parameters with ESP32 doubt

Post by RcoreL »

I solved it. The problem was clock's speed, i was using 80 Mhz and i need to reduce it to 2-10 Mhz because of something i doesn't know yet.

User avatar
adafruit_support_mike
 
Posts: 67672
Joined: Thu Feb 11, 2010 2:51 pm

Re: Winbond W25Q256JVFM flash parameters with ESP32 doubt

Post by adafruit_support_mike »

There are all sorts of problems associated with high-speed signal transmission. All wire has some amount of parasitic inductance and capacitance which make it harder for signals to change quickly. The effects of that usually become noticeable in the mid-megahertz range.

Electrical signal propagation follows the same equations as any other form of wave propagation, which means the signals can echo any time they see a sudden change in the impedance of the wire in front of them. Those effects are measured with 'scattering parameters' in the radio frequency world. Oscilloscope probes use special wire because 1m of plain coaxial cable will create 20MHz to 40MHz noise any time you apply a sudden change in voltage.

You also have to consider the length of the wiring compared to the wavelength of the signal moving through it. The wavelength for an 80MHz signal in vacuum is 3.75m, and electrical signals move through wire at about 70% the speed of light, putting the in-wire wavelength around 2.6m. That means the point 1.3m away from an 80MHz signal source will see low voltage any time the source itself sees a high voltage.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”