Over a million developers have joined DZone.

Driver and Command Line Shell for Winbond W25Q128 16MByte Serial FLASH Device

DZone 's Guide to

Driver and Command Line Shell for Winbond W25Q128 16MByte Serial FLASH Device

Learn more about dealing with FLASH memory on your microcontrollers.

· IoT Zone ·
Free Resource

Modern microcontrollers come with plenty of internal FLASH memory. On the other side, many high-performance MCUs, such as the NXP i.MX RT, are ‘flashless’ because the silicon process for high-performance cores is not matching the FLASH memory technology, so they are using external serial SPI or Quad-SPI (QSPI) memory instead.

Winbond w25q128 breakout board

Winbond w25q128 Serial Flash Breakout Board

Why Not Use an External SPI FLASH for a ‘Normal’ Microcontroller, Too?

The typical usage of external SPI flash memory is using it to load or store data. With the addition of a small external device on the SPI bus, I can easily add several MBytes of memory to the microcontroller. Such SPI memory devices are very inexpensive; I ordered a few breakout modules with Winbond W25Q128 (16 MByte) from AliExpress for $1.50 each. The device uses the following pins:

  • VCC: 3.3V
  • GND
  • CS: SPI Chip Select

A red LED on the breakout module indicates if the board is powered.

Usually, I use micro-SD cards for logging data. They are easily available, provide nearly ‘unlimited’ storage, and, with the FatFS file system, I can easily exchange data with the host. But it needs space on the PCB and the SD card socket needs to be accessible. The socket is a mechanical component and has its costs; plus, it is not very reliable in an environment with vibrations and subject of corrosion. Using a FLASH chip might be the better solution.

I have created a driver with a command line interface: that way, I can read/write data of the SPI FLASH memory device. An Eclipse example project is available on GitHub (check the links at the end of this article).

The example is running on an ARM Cortex-M4 from NXP (Kinetis K20DX128), but it can easily be ported for any other microcontroller.

using w25q128 with k20dx128

using w25q128 with k20dx128

The project includes a command line Shell:

command line shell for serial flash

command line Shell for serial flash

With the Shell, I can read/write the serial flash:

serial flash read and write

serial flash read and write

The ‘status’ command gives information about the device found:

device status

device status


I have now a working driver for using the Winbond W25Q128 16 MByte serial/SPI flash chip. The driver is still in an early stage, and I might update it to support other Flash devices, too. With the command line interface, I can read/write the memory. In the next step, I plan to use the memory with a file system and include more about this in a future article. The project is available on GitHub (see links below).

Happy Winbonding!


iot ,tutorial ,microcontroller ,memory ,flash memory ,serial flash ,shell ,winbond ,driver ,command line

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}