MicroPhase / antsdr-fw-patch

Repository of antsdr firmware make
27 stars 18 forks source link

QSPI addressing doesn't work in v0.35 #13

Closed daniestevez closed 6 months ago

daniestevez commented 7 months ago

I have found this issue while trying to program the QSPI with the Maia SDR firmware image from Linux running the v0.35 image.

The problem is that the >16MiB addressing of the 32MiB QSPI flash is not handled correctly. While reading and writing /dev/mtdblock? from Linux, accesses to the upper 16MiB wrap around and end up accessing the lower 16MiB. This causes that writing the FIT image to /dev/mtdblock3 overwrites the bootloader partition (the FIT image is 17 MiB).

Looking in the kernel sources used in v0.35, it seems that when using the Zynq QSPI controller, accesses are done with 3 byte addressing, so the EAR register needs to be set correctly for each access. However, spi_nor_write_ear() doesn't seem to handle correctly the Winbond QSPI used in the AntSDR E200. This device is handled using the generic case, and so write_enable() is not called. According to Section 8.2.7 in the datasheet, write enable needs to be done before modifying the EAR register.

In any case, modern versions of the Pluto firmware (such as v0.38) use a more recent kernel version in which the spi-nor code has been refactored. Perhaps this problem doesn't happen in the newer kernel version. Therefore, updating the kernel instead of patching the problem might be a better solution.

I haven't tested any of the potential solutions to this issue.

lone-boy commented 7 months ago

Yes, qspi cannot be used when it is larger than 16M. Please rest assured that we are working on building the latest version of plutov0.38, which will solve this problem.

daniestevez commented 6 months ago

This problem has been solved in the v0.38 branch. Closing.