This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I'm trying to integrate the TCP server and the OSPI Flash IO example together to create a program where the following happens:
1. Receive data over TCP
2. Write it in OSPI Flash
3. Read it from OSPI Flash
4. Send the data back over TCP
The examples both run fine seperately, without problems. However the OSPI example is WITHOUT FreeRTOS, so when now integrating them, I think because of that writing to OSPI does not work.
For reference, this is my code, and I call the flashWriteData() and flashReadData() functions from the AppTcp_echoPckt function when receiving data from TCP, nothing special, data is received correctly.
#include <kernel/dpl/DebugP.h> #include "ti_drivers_open_close.h" #include "ti_board_open_close.h" #include <string.h> #include "app_qspi.h" #define APP_OSPI_DATA_SIZE (2048) #define APP_OSPI_FLASH_OFFSET_BASE (0x200000U) uint8_t gOspiTxBuf[APP_OSPI_DATA_SIZE]; /* read buffer MUST be cache line aligned when using DMA, we aligned to 128B though 32B is enough */ uint8_t gOspiRxBuf[APP_OSPI_DATA_SIZE] __attribute__((aligned(128U))); void ospi_flash_clear_buffers() { uint32_t i; for(i = 0U; i < APP_OSPI_DATA_SIZE; i++) { gOspiTxBuf[i] = 0U; gOspiRxBuf[i] = 0U; } } void printHex(uint8_t *buf, int len){ for(int i = 0; i < len; i++){ DebugP_log("%x ", buf[i]); } DebugP_log("\r\n"); } int32_t flashWriteData(uint32_t offset, uint8_t *txbuf, uint32_t len){ int32_t status = SystemP_SUCCESS; uint32_t blk, page; /* Fill buffers with known data, * find block number from offset, * erase block, write the data, read back from a specific offset * and finally compare the results. */ // Only for flash chip on AM243 offset += APP_OSPI_FLASH_OFFSET_BASE; DebugP_log("offset for writing is %x\r\n", offset); ospi_flash_clear_buffers(); memcpy(gOspiTxBuf, txbuf, len); Flash_offsetToBlkPage(gFlashHandle[CONFIG_FLASH0], offset, &blk, &page); status = Flash_eraseBlk(gFlashHandle[CONFIG_FLASH0], blk); if(status != SystemP_SUCCESS) { DebugP_log("Block Erase Failed at 0x%X offset !!!", offset); } if(SystemP_SUCCESS == status) { status = Flash_write(gFlashHandle[CONFIG_FLASH0], offset, gOspiTxBuf, APP_OSPI_DATA_SIZE); } if(status != SystemP_SUCCESS) { DebugP_log("Flash Write of %d bytes failed at 0x%X offset !!!\r\n", len, offset); } printHex(gOspiTxBuf, len); return status; } int32_t flashReadData(uint32_t offset, uint8_t *rxbuf, uint32_t len){ int32_t status = SystemP_SUCCESS; // Only for flash chip on AM243 offset += APP_OSPI_FLASH_OFFSET_BASE; DebugP_log("offset for reading is %x\r\n", offset); ospi_flash_clear_buffers(); status = Flash_read(gFlashHandle[CONFIG_FLASH0], offset, gOspiRxBuf, APP_OSPI_DATA_SIZE); if(status != SystemP_SUCCESS) { DebugP_log("Flash Read of %d bytes failed at 0x%X offset !!!", len, offset); } memcpy(rxbuf, gOspiRxBuf, len); printHex(gOspiTxBuf, len); return status; }
I also configured the Flash and OSPI in exactly the same way as in the example sysconfig. (I do have to disable PHY, because else it does not run, I think because of the use of Ethernet)
I have now two DMA's configured, one seperate one for Ethernet and one for OSPI. (PKTDMA_0 for Ethernet and BCDMA_0 for OSPI)
I get the following error: Flash Write of 5 bytes failed at 0x200000 offset !!!
Basicly saying that writing does not work, however the Flash_eraseBlk() and Flash_read() functions go without error.
So I have kept most of my code the same as in the example, just seperated read and write in seperate functions.
I feels like a WEL (write enable latch) type of problem, but the seperate OSPI example works fine, so I don't know where to look now.
Hi Xander,
Let me come back to you on this by Tuesday.
Best Regards,
Aakash
Hi Xander,
We have replicated the issue and raised an internal ticket for the same. Let me come back to you after we have our first analysis on the same.
Best Regards,
Aakash