Other Parts Discussed in Thread: LP-AM243, SYSCONFIG
Tool/software:
Hi,
currently I am facing the problem that accesses to the flash on LP-AM243 board via octo (quad) SPI fail (some bytes are wrongly read as 0x00), if PHY mode and memcpy optimization (--use_memcpy=fast) are enabled.
Steps to reproduce:
- Use newest SDK "mcu_plus_sdk_am243x_09_02_01_05" and newest compiler "ti-cgt-armllvm_3.2.2.LTS".
- Import the example "ospi_flash_io_am243x-lp_r5fss0-0_nortos_ti-arm-clang".
- Set linker flag --use_memcpy=fast in project settings. Project->Properties->Build->Arm Linker->Advanced Options->Linker optimizations. Choose fast for --use_memcpy.
- Then adapt the example project by performing one of the following steps:
- Either disable DMA support in SysCfg tool for Flash/OSPI;
- Or change APP_OSPI_DATA_SIZE macro in ospi_flash_io.c to e.g. 512 (something smaller than 1024).
- One of the two steps above is needed so that the Flash_read() function of the Flash API will ultimately use memcpy(), otherwise (for copy operations > 1024 byte) the DMA will be used and the DMA works fine.
- Either disable DMA support in SysCfg tool for Flash/OSPI;
- Compile example (I used debug build) and load it with the debugger on the chip, or flash it, it does not matter.
- The example will fail with "ERROR: ospi_flash_io_compare_buffers:153: OSPI read data mismatch !!!"
The below screenshot illustrates what went wrong:
We have just jumped over the memcpy instruction. pSrc (an address inside flash; flash is mapped to 0x60000000) should be copied to pDst. We see at the right top that pSrc[7]==7, but pDst[7]==0 (I choose to only display the fist 10 values, so everything fits in one screen, there are also errors afterwards). Hence, there seems to be an issue with the optimized memcpy in combination with a flash address and the PHY mode of flash enabled. It works, if PHY mode is disabled.
Originally I stumbled upon this, because the EtherCAt Beckhoff example has the --use_memcpy=fast flag set by default. It also has the PHY mode disabled by default, but if you then enable it (and correct clock frequency settings, otherwise Flash_open() will already fail), flash reads start to fail.
I hope I have provided enough information. Feel free to ask, if anything is unclear. Thank you for your help.
Kind regards,
Martin
