Good Find! I have worked with the rev. B chips before and never could get them working, glad to see someone figured it out. I’m new to the thread, but I did find an example of rtos+tcp long ago on a forum. I noticed the link has since been broken and uploaded a copy to git:
It works on the ATSAME70-XPLD board, and uses RTOS 10.0.
I just received the following question about the SAME70 network driver:
have you been able (or tried) to use the +TCP implementation
with DCache enabled? I’m trying to use a UART DMA process
which relies on DCache, so it looks like I’ll need to get DCache
functioning with the +TCP stack.
Answer: both should be possible, with and without DCache.samE70_flash.ld.zip (2.0 KB)
I am attaching my “samE70_flash.ld”, which defines :
at the very beginning of RAM. If I am not mistaken, that part of RAM has no caching.
So this should make it possible to enable data cache, while the +TCP driver still works.
Please verify if the beginning of RAM is really not cached.
A driver like Zynq also works well with cached memory: each time when memory is handed over from peripheral to host Xil_DCacheInvalidateRange() will be called.
When the host hands over RAM to the peripheral, Xil_DCacheFlushRange() will be called.
It is important that each object ( DMA descriptors and packet buffers ) has a length that is a multiple of a cache page, often 32 bytes:
__attribute__ ( ( aligned( 32 ) ) ) // align with DCache pages
__attribute__ ( ( section( ".first_data" ) ) ) // Allocate in the beginning of RAM
uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS * NETWORK_BUFFER_SIZE ];
FWIW, we have been using SAME70Q20B with KNZ8081 phy and cache enabled for over a year. We define a non-cached area of memory in the MMU and allocate the DMA buffers in that. A complication is that the standard newlib supplied for ARM M7 chips is compiled with unaligned memory accesses enabled, but they are not allowed when the memory is set to non-cached, and memcpy in particular does unaligned accesses.
David, thanks for these insights. That may help others who are on the same path.
with KNZ8081 phy
That should be KSZ8081, I suppose?
A complication is that the standard newlib supplied for ARM
M7 chips is compiled with unaligned memory accesses enabled
As you have seen, the +TCP driver only does aligned access to memory that is shared with DMA.
Do you think that this may cause other potential problems?
Thanks again to Hein for the ongoing support with the SAME70. I’ve continued my efforts to get DCache() working with +TCP, but haven’t had any success thus far. Per Hein’s earlier post, I declare a non-cached region of memory in my linker script as follows:
An obvious difference between my current approach and Hein’s listed above, is that my non-cached memory allocation is at the end of the memory region, after the heap allocation, whereas Hein’s is at the start. Could this be causing me issues?
With the above memory definition in place, I construct the various network buffers in gmac_SAM.c with the (seemingly) correct memory allocation (showing 2 below as illustration) :
Thank you very much for clarifying and providing your example code/project, it’s greatly appreciated. I believe I’ve accounted for the MPU/MMU in my project, as the non-cached region is configured as part my application’s init procedure. Apologies, I should have included this in my earlier post.
It’s important to note that the above currently works, provided I don’t have CONF_BOARD_ENABLE_CACHE set. As soon as I define CONFINE_BOARD_ENABLE_CACHE in my conf_board.h file, +TCP no longer appears to work, and I’m no longer able to ping the board.