Closed KonssnoK closed 1 year ago
@johnboiles , saw you are using winbond flashes in a PR. Did you manage to use the esp_flash_init correctly? Meaning, do you manage to have idf choose the winbond driver for your flash? Or you see it going to the generic driver as in our case? (If you manage to initialize correctly, could you share the initialization settings?)
Thanks!
Working on this. Apparently the difference between the SPi direct approach and the Flash_SPI driver is in the handling of the MISO pin.
The Flash driver is sending 4 bytes instead of 5 bytes, as requested by the JEDEC ID
4 BYTES FLASH Driver (reading unaligned FF)
5 BYTES SPI Driver (working)
Also the ESP Flash driver MISO is 1 by default (?)
Apparently some other chips do not have the 8 dummy clocks in the middle, some do... Considering winbond itself, which has both approaches
I'm using W25Q512JVEIQ
and I have flash detection enabled and auto-detection worked fine for me out of the box (of course with the capacity detection fix in place). Perhaps this is something specific to the 1gbit chips?
Here are the logs I see:
D (1650) FLASH_HAL: extra_dummy: 0
V (1653) memspi: raw_chip_id: 2040EF
V (1656) memspi: chip_id: EF4020
V (1660) memspi: raw_chip_id: 2040EF
V (1664) memspi: chip_id: EF4020
D (1667) spi_flash: trying chip: issi
D (1671) spi_flash: trying chip: gd
D (1674) spi_flash: trying chip: mxic
D (1678) spi_flash: trying chip: winbond
I (1682) spi_flash: detected chip: winbond
I (1687) spi_flash: flash io: dio
yes it's related to newest chips, which usually mean higher capacity. I think it's related to the command addressing line being 16 bits instead of 8, and this made them add 8 dummy bit clocks after the standard chip id command. As you can see above also macronix implements the same procedure.
we detached from espressif flash libraries for these kind of chips.
Using ESP32S3 Using Winbond W25N01GVZEIG Using ESP-IDF v4.4.2
If we initialize the Flash using esp-idf provided libraries we read the following wrong output:
Instead of 0xFFEFAA the Chip ID should be 0xEFAA21. If we use custom code and just the SPI bus we are able to read the correct CHIP_ID. We cannot use our custom code because we would like to use the wear leveling implementation from IDF.
We tried changing speed, input_delay, DMA enabled, and to follow the code until the general purpose spi command.
Here is the initialization code we used for using the flash apis:
Here is the extract from our custom code for reading the chip id which works: