diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index 6e319a0210..c79f09d058 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -171,7 +171,9 @@ static int32_t ETH_PHY_IO_WriteReg( uint32_t DevAddr, static void vClearOptionBit( volatile uint32_t * pulValue, uint32_t ulValue ); -static size_t uxGetOwnCount( ETH_HandleTypeDef * heth ); +#if ( ipconfigHAS_PRINTF != 0 ) + static size_t uxGetOwnCount( ETH_HandleTypeDef * heth ); +#endif /* FreeRTOS+TCP/multi : * Each network device has 3 access functions: @@ -494,7 +496,7 @@ static BaseType_t xSTM32H_GetPhyLinkStatus( NetworkInterface_t * pxInterface ) NetworkInterface_t * pxFillInterfaceDescriptor( BaseType_t xEMACIndex, NetworkInterface_t * pxInterface ) { - pxSTM32Hxx_FillInterfaceDescriptor( xEMACIndex, pxInterface ); + return pxSTM32H_FillInterfaceDescriptor( xEMACIndex, pxInterface ); } #endif @@ -999,26 +1001,28 @@ static void vClearOptionBit( volatile uint32_t * pulValue, } /*-----------------------------------------------------------*/ -static size_t uxGetOwnCount( ETH_HandleTypeDef * heth ) -{ - BaseType_t xIndex; - BaseType_t xCount = 0; - ETH_RxDescListTypeDef * dmarxdesclist = &heth->RxDescList; - - /* Count the number of RX descriptors that are owned by DMA. */ - for( xIndex = 0; xIndex < ETH_RX_DESC_CNT; xIndex++ ) +#if ( ipconfigHAS_PRINTF != 0 ) + static size_t uxGetOwnCount( ETH_HandleTypeDef * heth ) { - __IO const ETH_DMADescTypeDef * dmarxdesc = - ( __IO const ETH_DMADescTypeDef * )dmarxdesclist->RxDesc[ xIndex ]; + BaseType_t xIndex; + BaseType_t xCount = 0; + ETH_RxDescListTypeDef * dmarxdesclist = &heth->RxDescList; - if( ( dmarxdesc->DESC3 & ETH_DMARXNDESCWBF_OWN ) != 0U ) + /* Count the number of RX descriptors that are owned by DMA. */ + for( xIndex = 0; xIndex < ETH_RX_DESC_CNT; xIndex++ ) { - xCount++; + __IO const ETH_DMADescTypeDef * dmarxdesc = + ( __IO const ETH_DMADescTypeDef * )dmarxdesclist->RxDesc[ xIndex ]; + + if( ( dmarxdesc->DESC3 & ETH_DMARXNDESCWBF_OWN ) != 0U ) + { + xCount++; + } } - } - return xCount; -} + return xCount; + } +#endif /* if ( ipconfigHAS_PRINTF != 0 ) */ /*-----------------------------------------------------------*/ static void prvEMACHandlerTask( void * pvParameters ) @@ -1027,8 +1031,11 @@ static void prvEMACHandlerTask( void * pvParameters ) * be occupied. In stat case, the program will wait (block) for the counting * semaphore. */ const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL ); - size_t uxTXDescriptorsUsed = 0U; - size_t uxRXDescriptorsUsed = ETH_RX_DESC_CNT; + + #if ( ipconfigHAS_PRINTF != 0 ) + size_t uxTXDescriptorsUsed = 0U; + size_t uxRXDescriptorsUsed = ETH_RX_DESC_CNT; + #endif ( void ) pvParameters; diff --git a/source/portable/NetworkInterface/STM32Hxx/readme.md b/source/portable/NetworkInterface/STM32Hxx/readme.md index 6ea5356337..4df2b56f27 100644 --- a/source/portable/NetworkInterface/STM32Hxx/readme.md +++ b/source/portable/NetworkInterface/STM32Hxx/readme.md @@ -37,21 +37,22 @@ The following macro's are **not** used by the FreeRTOS driver: All memory that is shared between the CPU and the DMA ETH peripheral, should be located in special RAM area called ".ethernet_data". This shall be declared in -the linker file. +the linker file (.ld). It is possible to use the AXI SRAM for this, but RAM{1,2,3} are also connected to the Ethernet MAC. Here is an example of the changes to the linker file: - AXI_RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* .ethernet_data declared here. */ - .ethernet_data : + RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* should already exist in MEMORY section */ + + .ethernet_data : /* inside SECTIONS section, before /DISCARD/ */ { PROVIDE_HIDDEN (__ethernet_data_start = .); KEEP (*(SORT(.ethernet_data.*))) KEEP (*(.ethernet_data*)) PROVIDE_HIDDEN (__ethernet_data_end = .); - } >AXI_RAM + } >RAM_D1 Here is a table of 3 types of STH32H7 : @@ -69,6 +70,10 @@ Here is a table of 3 types of STH32H7 : Please make sure that the addresses and lengths are correct for your model of STM32H7xx. If you use a memory that is not supported, it will result in a DMA errors. +Don't redefine a new memory area (like AXI-SRAM, RAM_D1) if it already exists in the +MEMORY section, just take note of it's name for defining the section .ethernet_data later +in that same file. + In FreeRTOSIPConfig.h : Define the total number of network buffer descriptors, e.g. 64: