This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840 DK - SDK16 - Not able to erase external FLASH memory blocks using QSPI

Hi everyone,

I am experimenting with the QSPI example provided with SDK 16. I am facing issues when I try to erase memory blocks or the entire chip.

1. First of all I try to erase the entire chip calling the functions below (either the first or the second one), however for both cases the system crashes end restarts.. 

err_code = nrf_drv_qspi_erase(NRF_QSPI_ERASE_LEN_ALL, 0);

err_code = nrfx_qspi_chip_erase();

2. The second problem I am facing is when I try to erase a specific memory block. The snippet bellow:

  1. Erases a 64KB memory block starting from address 0
  2. Writes 8 bytes to the memory starting from address 0
  3. Erases a 4KB memory block starting from address 4000
  4. Read the first 8 bytes of the memory
  5. Compares Tx and Rx

m_finished = false;
  err_code = nrf_drv_qspi_erase(NRF_QSPI_ERASE_LEN_64KB, 0); // NA - nrf_drv_qspi_erase,  Function for starting erasing of one memory block
  APP_ERROR_CHECK(err_code);
  WAIT_FOR_PERIPH();
  NRF_LOG_INFO("Process of erasing first block start");

  err_code = nrf_drv_qspi_write(m_buffer_tx, QSPI_TEST_DATA_SIZE, 0); // NA - nrf_drv_qspi_write,  Function for writing data to QSPI memory.
  APP_ERROR_CHECK(err_code);
  WAIT_FOR_PERIPH();
  NRF_LOG_INFO("Process of writing data start");

  m_finished = false;
  err_code = nrf_drv_qspi_erase(NRF_QSPI_ERASE_LEN_4KB, 4000); // NA - nrf_drv_qspi_erase,  Function for starting erasing of one memory block
  APP_ERROR_CHECK(err_code);
  WAIT_FOR_PERIPH();
  NRF_LOG_INFO("Process of erasing first block start");

  err_code = nrf_drv_qspi_read(m_buffer_rx, QSPI_TEST_DATA_SIZE, 0); // NA - nrf_drv_qspi_read,   Function for reading data from QSPI memory.
  WAIT_FOR_PERIPH();
  NRF_LOG_INFO("Data read");
  for (i = 0; i < QSPI_TEST_DATA_SIZE; i++) {
    NRF_LOG_INFO("Data %d. %d", i, m_buffer_rx[i])
  }

  NRF_LOG_INFO("Compare...");
  if (memcmp(m_buffer_tx, m_buffer_rx, QSPI_TEST_DATA_SIZE) == 0) // memcpy() is used to copy a block of memory from a location to another
  {
    NRF_LOG_INFO("Data consistent");
  } else {
    NRF_LOG_INFO("Data inconsistent");
  }

The problem is that when I write the memory (step 2) and then erase a block (step 3), the written data erased when the starting address (of nrf_drv_qspi_write() function) is between 0-4092. When I read the first 8 bytes of memory, I read nothing (255) as shown below.. And also comparing the Tx with Rx the data are inconsistent.. I cannot understand what is going on.. Iam not able to erase any memory block between the address range 8-4092 without losing the written data..

However when I use as a starting address >= 4096 to erase the memory block then surprisingly I do not have any problem. I can read the written data and comparing Tx with Rx the data are consistent

err_code = nrf_drv_qspi_erase(NRF_QSPI_ERASE_LEN_4KB, 4096);

  

Could you provide some help on these issues?

Thanks in advance

Nick

Parents
No Data
Reply
  • Thing is nobody reply if I create a new ticket. I just want to know do I have to do any extra steps to use on board external memory. 

    Like in sdk.config pins are undefined. I tried assigning pins in sdk config also. I read the data after erasing also it just gives 0x88 in all location not ff. Also generally working with flash, we have to enable the Write Enable before writing operation But i don't see any instruction in code to enable Write Operation.

    i am using the qspi example from nRF5 SDK for Thread v4.1

    How to debug ?

Children
Related