Hi,All:
I have a customized nRF52840 board with an external NOR Flash (W25Q64FV), and I have some confusion when conducting read and write data testing.
This is my device tree configuration:


This is my test code:
void flash_stress_test(void){
const struct device *flash_dev = DEVICE_DT_GET(FLASH_DEV);
if (!device_is_ready(flash_dev))
{
printk("QSPI Flash initialization failed. Please check the device tree pins\n");
return;
}
uint8_t write_buf[BUF_SIZE] = {0};
uint8_t read_buf[BUF_SIZE] = {0};
int ret;
uint32_t loop_cnt = 0;
printk("==== Start Flash stability testing ====\n");
if (TEST_LOOP_COUNT > 0)
{
printk("Preset total number of cycles: %d\n", TEST_LOOP_COUNT);
}
else
{
printk("Infinite loop mode, power off and stop\n");
}
while (1)
{
loop_cnt++;
printk("\n---------- The %u round of testing ----------\n", loop_cnt);
sys_rand_get(write_buf, BUF_SIZE);
printk("Generate random numbers:");
for(int i=0;i<BUF_SIZE;i++){
printk("0x%02X ", write_buf[i]);
}
printk("\n");
ret = flash_erase(flash_dev, TEST_OFFSET, 4096U);
if (ret != 0)
{
printk("【Error】Sector erase failed, err=%d Loop: %u\n", ret, loop_cnt);
while (1) k_sleep(K_SECONDS(1));
}
ret = flash_write(flash_dev, TEST_OFFSET, write_buf, BUF_SIZE);
if (ret != 0)
{
printk("【Error】Data write failed, err=%d Loop:%u\n", ret, loop_cnt);
while (1) k_sleep(K_SECONDS(1));
}
ret = flash_read(flash_dev, TEST_OFFSET, read_buf, BUF_SIZE);
if (ret != 0)
{
printk("【Error】Data read failed, err=%d Loop:%u\n", ret, loop_cnt);
while (1) k_sleep(K_SECONDS(1));
}
printk("read data:");
for (int i = 0; i < BUF_SIZE; i++)
{
printk("0x%02X ", read_buf[i]);
}
printk("\n");
if (memcmp(write_buf, read_buf, BUF_SIZE) != 0)
{
printk("【Error】Read and write data mismatch! Loop:%u\n", loop_cnt);
printk("Written data");
for (int i = 0; i < BUF_SIZE; i++)
{
printk("0x%02X ", write_buf[i]);
}
printk("\n");
while (1) {printk("Ddddd\n");k_sleep(K_SECONDS(1));}
}
printk("This round of verification has passed");
if (TEST_LOOP_COUNT != 0 && loop_cnt >= TEST_LOOP_COUNT)
{ break; }
k_sleep(K_MSEC(5));
}
printk("\n===== All %u round pressure tests passed, =====\n", loop_cnt);
}
然后向设备树添加:
writeoc = “pp4io”;
readoc = “read4io”;
启用Quad SPI时,所有数据输出均为数据0xFF,如图所示

注释后,所有读写数据都正常。我认为是:四联启用要求=“S2B1v1”;不起作用(QE)或其他原因。
另外,我的设备树配置是否正常,代码是否存在问题,请给我一些建议
谢谢