I have been trying to get the TCP stack to work with the ASF4 drivers from Atmel from SAME70, and I am having a ton of problems, mainly with “interface.c”, it seems I have to rewrite it from the ground up, and I do not have a lot of Networks knowledge to do that properly.
I have used a version of the driver provided here on the forum, but that uses ASF3 drivers.
Has anyone been successful in getting FreeRTOS TCP stack running with the new drivers from Atmel?
Hi Sofian. If you want, write an email to me: hein [at] htibosch [dot] net
Developing an Ethernet driver involves lots of technical details, and it will be quicker if we handle this by email.
I have FreeRTOS ported and running well on SAME54 (using ASF4 / Atmel START), and would like to add FreeRTOS+TCP. I have looked at Atmel’s lwIP demo (for SAME54, which has MAC/PHY drivers that work with ASF4). I also have looked at FreeRTOS+TCP demo for SAM4E (which uses ASF3 drivers).
Can you forward or reply with any suggestions - I expect I’ll have same issues that Sofian had.
After a lot of help from Hein I was able to get it all running on both ASF3 and ASF4 for the SAME70-Xplained board with SAME70Q21A not B.
Below are links for example projects, one using ASF3, it’s a very simple example. The second is using ASF4, aka Atmel Start.
They both start looking for a DHCP server upon wake up for a valid connection, if not found they will switch to the defined static IP.
Details on the ASF4 project:
UART using the debug board at 115200 baud, this should give you periodic statistics.
After TCP connection you will see the IP address, connect to it using telnet at port 2008, it has FreeRTOS+CLI implemented there, type “help” for the command list.
You can use Atmel Start to add drivers but make sure to do the following afterwards:
Never allow modifications on the FreeRTOS files even if it asks.
Never allow modifications on FreeRtosConfig.h
Modify the linker scripts as shown in directory: Device_Startup. Read “AddMeToldFiles.txt”
Add “#include “application_include.h”” to “driver_init.h”
add “init_application();” into “void system_init(void)” in file “driver_init.c”
if you see file name “main.c” in root directory remove it.
If you decide to get the FreeRTOS+TCP part into your project make sure to change the linkerscript to accomedate the change, mainly defining the following right after the .text part of memory. :
Please note that the gmac driver included with FreeRTOS+TCP for SAME70 cannot run with CACHE enabled, at least not yet, maybe Hein can comment on this, and if you do get it running please let us know.
Hi, I ran the ASF4 files, and that works. Impressive!
But I saw that the project was build on FreeRTOS version 9, not the newest version 10. Any plan to change this? They use two different lisenses, so I am a little afraid to mix between them. Should I downgrade my entire project to version 9? Thinking…
By the way, I think the D-cache “problem” should be solved by using TCM. I believe it is just a matter of adding the proper attribute to all memory shared by interrupts and tasks. I have the TCM working with DMA etc. Works perfectly. Furthermore. all interrupt code should also have the attribute for TCM set, as it will make it faster. The entire FreeRTOS and TCP stack would benefit by running from the TCM.
I have tried to generate an executable using the SAME70-Xplained-FreeRTOS+TCP_ASF4.zip file using Eclipse.
In my attempt however to create a project I have found that the file sam.h, and the others that this file includes, are not present. There are several c files that include sam.h
The problem was solved by having these files copied from a FreeRTOS distribution.
Ids it possible that project that you have created has a link to a directory outside your project?
I’m also facing another regarding the definition of Gmac in NetworkInterface.c (line 255).
typedef struct gmac_device {
/** Pointer to HW register base */
Gmac *p_hw;
I cannot find the file that defines Gmac! Any ideas about this?
I found gmac.h in fact 2 of them… one full of defines in instance and another with IOs and defines in component.
They are both included by same70q21.h which also includes many files in component and in instance.
I was seeing the file SAME70-Xplained-FreeRTOS+TCP_ASF4.zip has a complete solution but it seems to be dependable of an instalation of FreeRTOS and ASF.
Would this be the case?
Hi Eduardo, I also get lost here. Hopefully there are other users who can shed some light on this.
I know about the 2 occurrences of gmac.h : one is a description of registers and hardware, the other contains prototypes of functions and variables.
I published a driver that is compatible with SAME70 as well as SAM4E here
Maybe that works better for you.
Whait I did is take a copy of gmac.c, change it to my wishes, and called it gmac_SAM.c, c.q.
gmac_SAM.h. But when you compile that interface, you may well get stuck on compilation errors because the version of your frame doesn’t fit. Sigh…
The problem is that the Atmel Framework changes more quickly that we have the time to adapt the existing +TCP drivers.
I’ve got the SAME70 main_blinky program working with 10.3.0. I’m now adding +TCP and have come across a few minor issues. I’m happy to capture these on Github or elsewhere if that’s preferred.
I needed to add the xCheckLoopback prototype and function to the FreeRTOS_ARP.[ch] files per this post on SourceForge. With xCheckLoopback successfully incorporated into FreeRTOS_ARP.[ch], I’ve now removed tcp_loopback.c from the project.
The provided NetworkInterface.c file for SAM4E/SAME70 uses a (seemingly) outdated usGenerateProtocolChecksum function. The function in NetworkInterface.c is missing the second size_t uxBufferLength parameter. The calling function vGMACGenerateChecksum is called from gmac_dev_write in the provided gmac_SAM.c driver. Am I correct in my understanding that the ul_size (length of the frame) parameter in gmac_dev_write could be passed to vGMACGenerateChecksum to be used as the uxBufferLength parameter in usGenerateProtocolChecksum? I’m not entirely sure if the ‘frame length’ is equal to the ‘buffer size’ in this case.
I’ll have a go at getting the basic TCP echo example working in the meantime.
Implementing xCheckLoopback()` is only useful if you plan to send packets to your own (MAC-) address. It was a try-out, and I never found the time to get it into mainline.
usGenerateProtocolChecksum(): sorry, yes the later implementation also wants to know the length of the packet. This call should do it.