Winbond W25N library example on ESP32 will not compile

Trying out the Winbond W25N library so I can use the NAND based SPI flash W25N01GVZEIG with the ESP32. Use case is to store GPS ASCII strings and/or GPS binary data (Ublox UBX protocol) to flash.

The example "WriteString" that comes with the library does not compile on any ESP32 board but it compiles ok with many AVR boards.

Arduino V1.8.19

Winbond W25N * 0.2.5 (latest)

Errors I get are:

error: invalid conversion from 'char*' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
   SPI.transfer(cmdbuf, sizeof(cmdbuf));

error: invalid conversion from 'char*' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
   SPI.transfer(buf, dataLen);

My fallback option is to use the NOR based W25Q with the same footprint but these have less flash.

Does anyone have some tips for me to try to get this library compiling?

SPI.transfer expects an uint8_t (aka byte) for the first argument. So where that line is, change it to (corrected)

SPI.transfer((uint8_t*)cmdbuf, sizeof(cmdbuf));

Thankyou!

Adding (uint8_t*) to each line that was causing the error fixed the problem.
There was a typo in your example with unit8_t (instead of uint8_t) so that threw me for a while. In the end this worked well.

SPI.transfer((uint8_t*)cmdbuf, sizeof(cmdbuf));

For others trying this out, the SPI bus was too fast in the example "WriteString". Hardware was PCB board and tracks less than 20mm long.
Slowing the SPI bus by changing
SPI.beginTransaction(SPISettings(80000000, MSBFIRST, SPI_MODE0)); to SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));

Made the example work well.

Apologies for that, the text was correct, the code not :frowning: I will correct the code line.

You can mark your thread as "solved" by clicking the solution checkbox under the most useful post. That will let others know that a solution was provided that solved the problem.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.