zephyr: NXP RT1061: First Byte Missing When Reading from W25Q512NW via FlexSPI2 at 30 MHz
Describe the bug
Hi,
I’m working with a custom board based on the NXP RT1061 SoC. We have enabled the FlexSPI2 peripheral and connected it to a Winbond W25Q512NW NOR flash device. Due to board constraints and signal integrity considerations, we are operating the bus at ~30 MHz instead of the typical 133 MHz.
Below is the relevant device tree configuration:
&flexspi2 {
reg = <0x402a4000 0x4000>, <0x70000000 DT_SIZE_M(64)>;
status = "okay";
pinctrl-0 = <&pinmux_flexspi2>;
pinctrl-names = "default";
w25q512nw1: w25q512nw1@0 {
compatible = "nxp,imx-flexspi-nor";
size = <DT_SIZE_M(64 * 8)>;
reg = <0>;
spi-max-frequency = <DT_FREQ_M(30)>;
status = "okay";
jedec-id = [ef 60 20];
erase-block-size = <4096>;
write-block-size = <1>;
cs-hold-time = <10>;
cs-setup-time = <10>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
w25q512nw1_partition: partition@0 {
label = "NOR1";
reg = <0x00000000 DT_SIZE_M(64)>;
};
};
};
};
Setting spi-max-frequency = <DT_FREQ_M(30)>; alone was not sufficient to enforce the desired frequency. I also had to manually configure the PLL and clock settings in the board initialization code:
CLOCK_DisableClock(kCLOCK_FlexSpi2);
CLOCK_SetDiv(kCLOCK_Flexspi2Div, 7);
CLOCK_SetMux(kCLOCK_Flexspi2Mux, 2);
CLOCK_EnableClock(kCLOCK_FlexSpi2);
The driver for this flash uses the Fast Read Quad I/O (0xEC) command with 8 dummy cycles.
Problem:
When issuing read request, the first byte is consistently missing. The driver defaults to 8 dummy cycles, but according to the W25Q512NW datasheet (section 8.2.23 — Set Read Parameters), the device powers up with a default of 6 dummy cycles, and it specifies:
This likely happens because the flash expects 6 dummy cycles, but the RT interprets the first valid data byte as the last dummy cycle.
It’s unclear if 8 dummy cycles are valid at low frequencies when explicitly configured, but in practice, we observe data loss with the current driver setup.
Zephyr version 4.1.
Regression
- This is a regression.
Steps to reproduce
No response
Relevant log output
Impact
Annoyance – Minor irritation; no significant impact on usability or functionality.
Environment
No response
Additional Context
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 40 (40 by maintainers)
As I mentioned above, I’m just adjusting the dummy cycles - with 6 I get the expected result, but with 8 I consistently lose the first byte. I also see coherence issues in other tests I’ve run, but I haven’t yet been able to identify the root cause. Maybe you should consult with FlexSPI experts regarding the issue you encountered. Can you please open a ticket for that as well ?
I need move the code to ram and try to use 30M timing. will feedback