FreeRTOSplus TCP STM32F4 Integration

I am new to FreeRTOSplus TCP. I have ported TCP in my project. I am not able to startup ethernet using plus TCP.
I am using DP83825IRMQ , its phy ID is read as : 0x2000a140 which is not defined in this library, so which cases do I need to follow for xHas_1F_PHYSPCS( uint32_t ulPhyID ) and xHas_19_PHYCR( uint32_t ulPhyID ) function.

Can anyone please provide any pointers what could have gone wrong.
For your reference, link to my repo


You should have a definition for PHY_ID_ DP83825I in the FreeRTOS-Plus-TCP\source\portable\NetworkInterface\include\phyHandling.h:

#define PHY_ID_ DP83825I        0x2000A140

Since DP83825I does not have Special Control Status register xHas_1F_PHYSPCS should return pdFALSE.

And xHas_19_PHYCR should return pdTRUE as DP83825I has 0x0019 address mapped to be PHYCR_Register.

--- a/source/portable/NetworkInterface/Common/phyHandling.c
+++ b/source/portable/NetworkInterface/Common/phyHandling.c
@@ -158,6 +158,7 @@ static BaseType_t xHas_1F_PHYSPCS( uint32_t ulPhyID )
         case PHY_ID_DP83TC811S:
         case PHY_ID_TM4C129X:
         case PHY_ID_MV88E6071:
+        case PHY_ID_ DP83825I:
             /* Has no 0x1F register "PHY Special Control Status". */
@@ -175,6 +176,7 @@ static BaseType_t xHas_19_PHYCR( uint32_t ulPhyID )
         case PHY_ID_LAN8742A:
         case PHY_ID_DP83848I:
         case PHY_ID_TM4C129X:
+        case PHY_ID_ DP83825I:
             xResult = pdTRUE;

I did that but still I am still stuck.
Is it something wrong with the way I initalized ?
I have just used

static uint8_t ucMACAddress[ 6 ] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };

static const uint8_t ucIPAddress[ 4 ] = { 10, 25, 10, 200 };
static const uint8_t ucNetMask[ 4 ] = { 255, 255, 255, 0 };
static const uint8_t ucGatewayAddress[ 4 ] = { 10, 25, 10, 1 };

static const uint8_t ucDNSServerAddress[ 4 ] = { 8, 8, 8, 8 };

FreeRTOS_IPInit( ucIPAddress, ucNetMask,cGatewayAddress,ucDNSServerAddress,            ucMACAddress );

here’s my config files
FreeRTOSConfig.h (5.5 KB)
FreeRTOSIPConfig.h (23.1 KB)

Tony’s solution looks all good to me.

Can you step through the code in phyHandling.c and see what happens? Does xPhyDiscover() find one PHY so that:

xPortCount = 1
ulPhyIDs = 0x2000a140

And what does xPhyConfigure() conclude?

Yes, it does detect a and the address is also same. but after debugging further I found that in Network Interface.c file some is wrong while creating prvEMACHandlerTask as I am not able to read xMacInitStatus and it is stuck on, after that. As mentioned here I also tried increasng stack size to 512 (previously 256) for EMAC task.

Are you using the stm32 ETH driver files provided in the FreeRTOS-Plus-TCP\source\portable\NetworkInterface\STM32Fxx or those directly taken from CubeMX?

I enabled ethernet from CubeMX and then deleted stm32f4x_hal.h and .c files.Using Ethernet library files provided by FreeRTOSplus.
You can also refer my code repo shown

here on first post.
Are my config file accurate for Ethernet on FreeRTOSplus TCP ?

Checking your project settings, it seems like the project is compiled with optimizations set highest for size, and probably the variable xMacInitStatus might be optimized out.

Suggest you to decrease the optimization level to lower/none and share your findings.

Also, try enabling ipconfigHAS_PRINTF and ipconfigHAS_DEBUG_PRINTF in your FreeRTOSIPConfig.h to print debug logs to maybe a UART console. You can refer to this sample project to set up the UART (STM32F4, but uses different PHY).

I set the project optimization setting to none.

priority defined for this task was more than the macro configMAX_PRIORITIES thats why it was stuck in task create function.
I increased the configMAX_PRIORITIES to 6 and was able to create that task.
Now I am stuck somewhere here :

I suspect it is due to interrupt configurations in FreeRTOSConifg file

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
PRIORITY THAN THIS! (higher priorities are lower numeric values. */

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See */
/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }	

My config files

Is there any recommended file that can align FreeRTOS and TCP stack with STM32F4 ?

This is because you are calling interrupt safe FreeRTOS API functions from ISRs that have logical priority higher than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. One reason for that assert should be the following lines in your code:

/* ETH interrupt Init */
HAL_NVIC_SetPriority(ETH_IRQn, 0, 0);

Which means ethernet interrupts are run at the highest priority.

Try lowering it to configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY or something logically lower (numerically higher).

For example:

HAL_NVIC_SetPriority(ETH_IRQn, 5, 0);

Is there any recommended file that can align FreeRTOS and TCP stack with STM32F4 ?

You could refer to the config files folder in this sample STM32F4 FreeRTOS+TCP project

Yes, It is working now, I am able to ping my STM board. Now ,If I want run a HTTP Client do I need to setup TCP or just provide TCP Send and receive function to coreHTTP library ?

Yes, It is working now, I am able to ping my STM board.

Thanks for reporting back.

If I want run a HTTP Client do I need to setup TCP or just provide TCP Send and receive function to coreHTTP library

Both, you could refer to the coreHTTP demos [example, plain text] and the associated documentation for examples.