Build 160112 feedback

jtbr wrote on Wednesday, May 18, 2016:

I thought I’d share my experience building this for an Atmel SAMV71Q21.

  1. The Atmel software framework (ASF) includes FreeRTOS 7.0.3 as the latest version, and that will not work with +TCP, as it is missing some functionality. I built with the latest 8.2.3.
  2. It’s important NOT to use the ASF module “PHY Ethernet MAC (GMAC) (driver)”, as this is superseded by the driver included in +TCP (under NetworkInterface/ATSAM4E). Otherwise the build will be tedious with conflicts, and it’s confusing as there are at least 5 gmac.h files. Hopefully the new driver is indeed compatible, but I haven’t gotten so far as to test yet.
  3. configMAC_INTERRUPT_PRIORITY needs to be defined in FreeRTOSConfig.h in order to build, but it’s not clear how to set this (relative to other priorities used by +TCP).
  4. FreeRTOS upgrade issues: configMAX_PRIORITIES needs to be an integer (with no casting [with older FreeRTOS it was ((unsigned portBASE_TYPE) 5) and that bonks]). If you want to use vTaskList(), you now need to set a new configUSE_STATS_FORMATTING_FUNCTIONS to 1.
  5. With respect to the instructions, it is also necessary to include src\freertos_plus-tcp\portable\NetworkInterface[microcontroller] in the include paths. And in case step 2 of the instructions is confusing, you need to build all the .c files in that directory (not just NetworkInterface.c).
  6. The code has a number of multiple declarations (FreeRTOS_netstat(), etc…) : it may be helpful to compile with -Wredundant-decls (in GCC) to find and eliminate them.
  7. FreeRTOS_Sockets.h erroneously uses #if __cplusplus instead of #ifdef __cplusplus.
  8. If you have certain warnings enabled in GCC, you’ll get hundreds of warnings about packed structs causing inefficient alignment. Under most circumstances these warnings are helpful, but not here. May I suggest using portable/Compiler/GCC/pack_struct_start.h to do this:
/* disable warnings about inefficient alignment caused by packed (they are deliberate here) */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
#pragma GCC diagnostic ignored "-Wpacked"

and at the end of pack_struct_end.h this:

/* restore diagnostics */
#pragma GCC diagnostic pop

rtel wrote on Thursday, May 19, 2016:

Thanks for the feedback. We have a SAM4E demo already, is the SAMV7 MAC
compatible with the SAM4E?

I would be grateful if you could post your code (at least the driver
level, if the application cannot be posted) to the FreeRTOS Interactive
site. We are aware of people using FreeRTOS+TCP on various chips and
would like to create a library of such things, but people seem to
‘forget’ to post their code:
http://interactive.freertos.org/forums/21211265-FreeRTOS-TCP

Comments below:

  1. configMAC_INTERRUPT_PRIORITY needs to be defined in FreeRTOSConfig.h
    in order to build, but it’s not clear how to set this (relative to
    other priorities used by +TCP).

You can use the SAM4E example as a reference here. In most cases you
would want to use the highest
priority from which FreeRTOS API functions can be called
, but it is
somewhat application dependent as the network might not be your highest
priority. The SAM4E demo has it set to
configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY.

  1. FreeRTOS upgrade issues: configMAX_PRIORITIES needs to be an integer
    (with no casting [with older FreeRTOS it was ((unsigned
    portBASE_TYPE) 5) and that bonks]). If you want to use vTaskList(),
    you now need to set a new configUSE_STATS_FORMATTING_FUNCTIONS to 1.

That cast is often getting in the way now, normally when the definition
is used in a pre-processor directive which doesn’t understand the cast.

  1. If you have certain warnings enabled in GCC, you’ll get hundreds of
    warnings about packed structs causing inefficient alignment. Under
    most circumstances these warnings are helpful, but not here. May I
    suggest using portable/Compiler/GCC/pack_struct_start.h to do this:
    |/* disable warnings about inefficient alignment caused by packed
    (they are deliberate here) / #pragma GCC diagnostic push #pragma
    GCC diagnostic ignored “-Wattributes” #pragma GCC diagnostic
    ignored “-Wpacked”|
    and at the end of pack_struct_end.h this:
    |/
    restore diagnostics */ #pragma GCC diagnostic pop|

Right. In this case packed structures is a necessity.

  1. The code has a number of multiple declarations (FreeRTOS_netstat(),
    etc…) : it may be helpful to compile with -Wredundant-decls (in
    GCC) to find and eliminate them.

Not sure about this one and will have to follow your suggestion to see.

  1. FreeRTOS_Sockets.h erroneously uses |#if __cplusplus| instead of
    |#ifdef __cplusplus|.

Fixed - thanks.

jtbr wrote on Thursday, May 19, 2016:

Thanks. The references about priorities are helpful.

I did not modify the driver; I believe the SAMV71 MAC is compatible with the SAM4E.

You might want to add the instruction to add the include path src\freertos_plus-tcp\portable\NetworkInterface\[microcontroller] in the website instructions for including in a project (you may not have seen that comment as I added it in an edit to the message before).