NRF52833 Custom Board SPI Flash

Hi, I work on custom board, which have NRF52833 and IS25LP016D SPI flash. I tried with SPI flash sample but SPI flash driver IS25LP016D was not found! err message show on putty. I add configuration to dts file. How can I solve it. 

MY CODE:

/*
 * Copyright (c) 2016 Intel Corporation.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr.h>
#include <drivers/flash.h>
#include <device.h>
#include <devicetree.h>
#include <stdio.h>
#include <string.h>

#if (CONFIG_SPI_NOR - 0) ||             \
    DT_NODE_HAS_STATUS(DT_INST(0, jedec_spi_nor), okay)
#define FLASH_DEVICE DT_LABEL(DT_INST(0, jedec_spi_nor))
#define FLASH_NAME "JEDEC SPI-NOR"
#elif (CONFIG_NORDIC_QSPI_NOR - 0) || \
    DT_NODE_HAS_STATUS(DT_INST(0, nordic_qspi_nor), okay)
#define FLASH_DEVICE DT_LABEL(DT_INST(0, nordic_qspi_nor))
#define FLASH_NAME "JEDEC QSPI-NOR"
#elif DT_NODE_HAS_STATUS(DT_INST(0, st_stm32_qspi_nor), okay)
#define FLASH_DEVICE DT_LABEL(DT_INST(0, st_stm32_qspi_nor))
#define FLASH_NAME "JEDEC QSPI-NOR"
#else
#error Unsupported flash driver
#endif

#if defined(CONFIG_BOARD_ADAFRUIT_FEATHER_STM32F405)
#define FLASH_TEST_REGION_OFFSET 0xf000
#elif defined(CONFIG_BOARD_ARTY_A7_ARM_DESIGNSTART_M1) || \
    defined(CONFIG_BOARD_ARTY_A7_ARM_DESIGNSTART_M3)
/* The FPGA bitstream is stored in the lower 536 sectors of the flash. */
#define FLASH_TEST_REGION_OFFSET \
    DT_REG_SIZE(DT_NODE_BY_FIXED_PARTITION_LABEL(fpga_bitstream))
#else
#define FLASH_TEST_REGION_OFFSET 0xff000
#endif
#define FLASH_SECTOR_SIZE        4096

void main(void)
{
    const uint8_t expected[] = { 0x55, 0xaa, 0x66, 0x99 };
    const size_t len = sizeof(expected);
    uint8_t buf[sizeof(expected)];
    const struct device *flash_dev;
    int rc;

    printf("\n" FLASH_NAME " SPI flash testing\n");
    printf("==========================\n");

    flash_dev = device_get_binding("IS25LP016D");

    if (!flash_dev) {
        printf("SPI flash driver %s was not found!\n",
               FLASH_DEVICE);
        return;
    }

    /* Write protection needs to be disabled before each write or
     * erase, since the flash component turns on write protection
     * automatically after completion of write and erase
     * operations.
     */
    printf("\nTest 1: Flash erase\n");

    rc = flash_erase(flash_dev, FLASH_TEST_REGION_OFFSET,
             FLASH_SECTOR_SIZE);
    if (rc != 0) {
        printf("Flash erase failed! %d\n", rc);
    } else {
        printf("Flash erase succeeded!\n");
    }

    printf("\nTest 2: Flash write\n");

    printf("Attempting to write %u bytes\n", len);
    rc = flash_write(flash_dev, FLASH_TEST_REGION_OFFSET, expected, len);
    if (rc != 0) {
        printf("Flash write failed! %d\n", rc);
        return;
    }

    memset(buf, 0, len);
    rc = flash_read(flash_dev, FLASH_TEST_REGION_OFFSET, buf, len);
    if (rc != 0) {
        printf("Flash read failed! %d\n", rc);
        return;
    }

    if (memcmp(expected, buf, len) == 0) {
        printf("Data read matches data written. Good!!\n");
    } else {
        const uint8_t *wp = expected;
        const uint8_t *rp = buf;
        const uint8_t *rpe = rp + len;

        printf("Data read does not match data written!!\n");
        while (rp < rpe) {
            printf("%08x wrote %02x read %02x %s\n",
                   (uint32_t)(FLASH_TEST_REGION_OFFSET + (rp - buf)),
                   *wp, *rp, (*rp == *wp) ? "match" : "MISMATCH");
            ++rp;
            ++wp;
        }
    }
}
MY PROJ.CONF:
CONFIG_STDOUT_CONSOLE=y
CONFIG_FLASH=y
CONFIG_SPI=y

MY SPI1 DTS:
spi1: spi@40004000 {
            #address-cells = < 0x1 >;
            #size-cells = < 0x0 >;
            reg = < 0x40004000 0x1000 >;
            interrupts = < 0x4 0x1 >;
            status = "okay";
            label = "SPI_1";
            sck-pin = < 0x9 >;
            mosi-pin = < 0x8 >;
            miso-pin = < 0x6 >;
            IS25LP016D@0 {
                compatible = "jedec,spi-nor";
                label = "IS25LP016D";
                reg = < 0x0 >;
                spi-max-frequency = < 0x7ed6b40 >;
                jedec-id = [ 9D 60 15 ];
                size = < 0x1000000 >;
            };
        };
MY NRF52833 PINS:
MY ERROR MESSAGES:
JEDEC SPI-NOR SPI flash testing
==========================
SPI flash driver IS25LP016D was not found!
Parents Reply Children
No Data
Related