How to get UID in external flash via QSPI?

Hi,

I'm using QSPI to control an external flash (w25q128).

Is there any API that can help me get the UID of the external flash?

For w25q128, there is a command for read the UID.

https://www.pjrc.com/teensy/W25Q128FV.pdf

SDK: NCS 2.3.0

Thanks.

Andy

Parents Reply Children
  • Thanks for your information.
    I implemented qspi_read_uid.
    And successfully read the UID of the external flash.

    Here is what I made:

    int qspi_read_uid(const struct device *dev,
                      uint8_t opcode, 
                      uint8_t *tx, uint8_t tx_len,
                      uint8_t *id, uint8_t id_len )
    {
        nrf_qspi_cinstr_conf_t cinstr_cfg = {
            .opcode = opcode,
            .length = NRF_QSPI_CINSTR_LEN_1B,
            .io2_level = true,
            .io3_level = true,
        };
    
        int ret = qspi_device_init(dev);
        nrfx_err_t res = NRFX_SUCCESS;
    
        if (ret != 0) {
            LOG_DBG("qspi_device_init: %d", ret);
            qspi_device_uninit(dev);
            return ret;
        }
    
        qspi_lock(dev);
        res = nrfx_qspi_lfm_start(&cinstr_cfg);
        if (res != NRFX_SUCCESS) {
            LOG_DBG("lfm_start: %x", res);
            goto out;
        }
    
        res = nrfx_qspi_lfm_xfer(tx, NULL, tx_len, false);
        if (res != NRFX_SUCCESS) {
            LOG_DBG("lfm_xfer addr: %x", res);
            goto out;
        }
    
        res = nrfx_qspi_lfm_xfer(NULL, id, id_len, true);
        if (res != NRFX_SUCCESS) {
            LOG_DBG("lfm_xfer read: %x", res);
            goto out;
        }
    
    out:
        qspi_unlock(dev);
        qspi_device_uninit(dev);
        return qspi_get_zephyr_ret_code(res);
    }
    
    

  • Thanks for your information.
    I implemented qspi_read_uid.
    And successfully read the UID of the external flash.

    Here is what I made:

    Great! And thanks for sharing the code you made :)

Related