Skip to content

SPI Flash Memory W25Q64 Access Library for esp-idf

License

Notifications You must be signed in to change notification settings

maxgrim/esp-idf-w25q64

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp-idf-w25q64

SPI Flash Memory W25Q64 Access Library for esp-idf.
I ported from here.

Installation for ESP32

git clone https://github.com/nopnop2002/esp-idf-w25q64
cd esp-idf-w25q64
idf.py set-target esp32
idf.py menuconfig
idf.py flash

Installation for ESP32S2

git clone https://github.com/nopnop2002/esp-idf-w25q64
cd esp-idf-w25q64
idf.py set-target esp32S2
idf.py menuconfig
idf.py flash

You have to set this config value with menuconfig.

  • CONFIG_MISO_GPIO
    GPIO number(IOxx) to MISO.
  • CONFIG_MOSI_GPIO
    GPIO number(IOxx) to MOSI.
  • CONFIG_SCLK_GPIO
    GPIO number(IOxx) to SCLK.
  • CONFIG_CS_GPIO
    GPIO number(IOxx) to CS.

config-main

  • Default for ESP32

config-esp32

  • Default for ESP32-S2

config-esp32s2

API

// Start Flash
void spi_master_init(W25Q64_t * dev, int GPIO_CS);

// Get status register1
esp_err_t W25Q64_readStatusReg1(W25Q64_t * dev, uint8_t * reg1);

// Get status register2(Winbond only)
esp_err_t W25Q64_readStatusReg2(W25Q64_t * dev, uint8_t * reg2);

// Get Unique ID(Winbond only)
esp_err_t W25Q64_readUniqieID(W25Q64_t * dev, uint8_t * id);

// Get JEDEC ID(Manufacture, Memory Type,Capacity)
esp_err_t W25Q64_readManufacturer(W25Q64_t * dev, uint8_t * id);

// Check busy
bool W25Q64_IsBusy(W25Q64_t * dev);

// Set power down mode
esp_err_t W25Q64_powerDown(W25Q64_t * dev);;

// Set write enable
esp_err_t W25Q64_WriteEnable(W25Q64_t * dev);

// Set write disable
esp_err_t W25Q64_WriteDisable(W25Q64_t * dev);

// Read data from memory
uint16_t W25Q64_read(W25Q64_t * dev, uint32_t addr, uint8_t *buf, uint16_t n);

// First read data from memory
uint16_t W25Q64_fastread(W25Q64_t * dev, uint32_t addr, uint8_t *buf, uint16_t n);

// Erase data by Sector
bool W25Q64_eraseSector(W25Q64_t * dev, uint16_t sect_no, bool flgwait);

// Erase data by block(64KB)
bool W25Q64_erase64Block(W25Q64_t * dev, uint16_t blk_no, bool flgwait);

// Erase data by Block(32KB)
bool W25Q64_erase32Block(W25Q64_t * dev, uint16_t blk_no, bool flgwait);

// Erase all data
bool W25Q64_eraseAll(W25Q64_t * dev, bool flgwait);

// Write data to memory
int16_t W25Q64_pageWrite(W25Q64_t * dev, uint16_t sect_no, uint16_t inaddr, uint8_t* buf, int16_t n);

Wireing

# W25Q64 ESP32 ESP32S2
1 /CS -- GPIO5 GPIO34
2 MISO -- GPIO19 GPIO33
3 /WP -- 3.3V 3.3V
4 GND -- GND GND
5 MOSI -- GPIO23 GPIO35
6 SCK -- GPIO18 GPIO36
7 /HOLD -- 3.3V 3.3V
8 VCC -- 3.3V 3.3V

You can change it to any pin using menuconfig.
However, changing to some pins does not work properly.

Winbond

Device # of Bytes Address range # of 4K-Sectors # of 32K-Blocks # of 64K-Blocks JEDEC ID
W25Q80 1M 0x0FFFFF 256 32 16 EF-40-14
W25Q16 2M 0x1FFFFF 512 64 32 EF-40-15
W25Q32 4M 0x3FFFFF 1024 128 64 EF-40-16
W25Q64 8M 0x7FFFFF 2048 256 128 EF-40-17
W25Q128 16M 0xFFFFFF 4096 512 256 EF-40-18

W25Q80

W25Q80

  • Manufacturer:
    Byte1 : ManufacturerID(0xef=Winbond)
    Byte2 : MemoryType(0x40=SPI/0x60=QPI)
    Byte3 : Capacity(2^0x14=2^20=0x100000=1M Byte=8M Bit)
  • First 10Byte : ASCII 0-9
  • Next 32Byte : ASCII A-Z

W25Q16

W25Q16

W25Q32

W25Q32

W24Q64

W25Q64

W25Q128

W25Q128


MACRONIX

Device # of Bytes Address range # of 4K-Sectors # of 32K-Blocks # of 64K-Blocks JEDEC ID
MX25L3206E 4M 0x3FFFFF 1024 128 64 C2-20-16
MX25L6473E 8M 0x7FFFFF 2048 256 128 C2-20-17
MX25L12835F 16M 0xFFFFFF 4096 512 256 C2-20-18

MX25L3206E

MX25L3206E

  • Manufacturer:
    Byte1 : ManufacturerID(0xc2=Macronix)
    Byte2 : MemoryType(0x20)
    Byte3 : Capacity(2^0x16=2^22=0x400000=4M Byte=32M Bit)

MX25L6473E

MX25L6473E

MX25L12835F

MX25L12835F


Note

I tested these.
But I couldn't get it working.

  • GD25Q64
  • SST25VF016B
  • SST25VF032B

Note

There is a example to build a FAT file system on External SPI FLSAH Memory is available here.
The ESP32's onboard FLASH is 4MByte, and you can reserve up to about 3MByte of storage on the onboard FLASH.
With the large capacity SPI FLSAH Memory, you can add a large amount of storage.
This repository may no longer be needed.

About

SPI Flash Memory W25Q64 Access Library for esp-idf

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.0%
  • Makefile 1.5%
  • CMake 1.5%