Skip to main content
Visitor II
June 8, 2021
Solved

Can't Ping Device After Writing to QSPI w/ RTOS

  • June 8, 2021
  • 2 replies
  • 2731 views

I have full IwIP functionality inside a RTOS task due to this knowledge article:

How to create project for STM32H7 with Ethernet and LwIP stack working

I am able to erase, write, and read the QSPI flash using a BSP_QSPI test function inside main. This causes the IwIP stack to not initialize though. When l relocated the BSP_QSPI test function, to inside the default task, it caused both to stop working. I tried options of separating them into different tasks, changed task priorities, enabled QUADSPI global interrupt and increased heap/stack to no avail.

Hopefully it is just a silly solution l am overlooking.

BSP_QSPI test function:

void qspi_test(){

uint32_t address = 0;

char * writeData = "My Time NEO!";

char data[50] = {};

// Erase sector

BSP_QSPI_EraseBlock(0, address, MT25TL01G_ERASE_4K);

// Write data

BSP_QSPI_Write(0, (uint8_t*)writeData, address, 4096);

// Read data

BSP_QSPI_Read(0, (uint8_t*)data, address, 4096);

printf("QSPI Device: %s\r\n", data);

}

BSP_QSPI Configuration:

 BSP_QSPI_Init_t init;

 init.InterfaceMode = MT25TL01G_SPI_MODE;

 init.TransferRate = MT25TL01G_STR_TRANSFER;

 init.DualFlashMode = MT25TL01G_DUALFLASH_DISABLE;

 if (BSP_QSPI_Init(0, &init) != BSP_ERROR_NONE)

 {

    Error_Handler();

 }

Task:

void IwIP_init(void *argument)

{

 /* init code for LWIP */

 MX_LWIP_Init();

 /* USER CODE BEGIN 5 */

 /* Test erase, write, and read of QSPI module */

 qspi_test();

 /* Infinite loop */

 for(;;)

 {

osDelay(1);

 }

 /* USER CODE END 5 */

}

    This topic has been closed for replies.
    Best answer by DWill.4

    I figured out that changing my BSP_QSPI configuration to QPI_Mode, and Dual_Transfer resolved the issue.

    2 replies

    Graduate II
    June 8, 2021

    You're going to need to refine "not working" a tad.

    Debugging indicates what?

    Is it Hard Faulting? Do you have a useful routine reporting machine state?

    Do you have sections of code expecting the QSPI to be memory mapped?

    DWill.4Author
    Visitor II
    June 8, 2021

    Debugging is being caught in the Invalidate D-Cache section of code. It only seems to happen when stepping through it.

    It is not hard faulting, and there are no errors being thrown when compiling. Both work fine independently but not together.

    I'm using the Micron QSPI Nor chip which is memory mapped.

    Graduate II
    June 9, 2021

    Ok, so how is the switching between direct and memory mapping handled? Do you arbitrate usage? Does one of the tasks doing writing to this memory?

    Reading 4096 bytes into a 50 byte array is going to be a problem.

    You should use invalidate with caution, ideally use the "by address" version to limit side effects.

    DWill.4AuthorAnswer
    Visitor II
    June 9, 2021

    I figured out that changing my BSP_QSPI configuration to QPI_Mode, and Dual_Transfer resolved the issue.