[PATCH 4/4] RTEMS_USE_LWIP option to use lwip in RTEMS

Robin.Mueller robin.mueller.m at gmail.com
Mon Apr 12 09:56:15 UTC 2021


This adds a configuration option if lwIP is used instead of libbsd.
It works by specifying RTEMS_USE_LWIP in the config.ini file.

The option is still STM32H7 specific can could in principle be
reused for other BSPs. For the STM32H7, it allows the execution
of some operations necessary for lwIP to work properly.
---
 bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c | 16 ++++++++++------
 spec/build/bsps/arm/stm32h7/grp.yml      |  2 ++
 spec/build/bsps/arm/stm32h7/optlwip.yml  | 24 ++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 6 deletions(-)
 create mode 100644 spec/build/bsps/arm/stm32h7/optlwip.yml

diff --git a/bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c b/bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c
index 4f2634df5b..595a86205f 100644
--- a/bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c
+++ b/bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c
@@ -146,6 +146,10 @@
 /* Includes ------------------------------------------------------------------*/
 #include "stm32h7xx_hal.h"
 
+#ifdef __rtems__
+#include <bspopts.h>
+#endif
+
 /** @addtogroup STM32H7xx_HAL_Driver
   * @{
   */
@@ -361,10 +365,10 @@ HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth)
   /*------------------ MAC, MTL and DMA default Configuration ----------------*/
   ETH_MACDMAConfig(heth);
 
-#ifndef __rtems__
+#if RTEMS_USE_LWIP == 1
   /* SET DSL to 64 bit */
   MODIFY_REG(heth->Instance->DMACCR, ETH_DMACCR_DSL, ETH_DMACCR_DSL_64BIT);
-#endif /* __rtems__ */
+#endif
 
   /* Set Receive Buffers Length (must be a multiple of 4) */
   if ((heth->Init.RxBuffLen % 0x4U) != 0x0U)
@@ -2647,7 +2651,7 @@ static void ETH_MAC_MDIO_ClkConfig(ETH_HandleTypeDef *heth)
   */
 static void ETH_DMATxDescListInit(ETH_HandleTypeDef *heth)
 {
-#ifndef __rtems__
+#if RTEMS_USE_LWIP == 1
   ETH_DMADescTypeDef *dmatxdesc;
   uint32_t i;
 
@@ -2674,7 +2678,7 @@ static void ETH_DMATxDescListInit(ETH_HandleTypeDef *heth)
 
   /* Set Transmit Descriptor Tail pointer */
   WRITE_REG(heth->Instance->DMACTDTPR, (uint32_t) heth->Init.TxDesc);
-#endif /* __rtems__ */
+#endif /* RTEMS_USE_LWIP == 1 */
 }
 
 /**
@@ -2686,7 +2690,7 @@ static void ETH_DMATxDescListInit(ETH_HandleTypeDef *heth)
   */
 static void ETH_DMARxDescListInit(ETH_HandleTypeDef *heth)
 {
-#ifndef __rtems__
+#if RTEMS_USE_LWIP == 1
   ETH_DMADescTypeDef *dmarxdesc;
   uint32_t i;
 
@@ -2719,7 +2723,7 @@ static void ETH_DMARxDescListInit(ETH_HandleTypeDef *heth)
 
   /* Set Receive Descriptor Tail pointer Address */
   WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (((uint32_t)(ETH_RX_DESC_CNT - 1))*sizeof(ETH_DMADescTypeDef)))));
-#endif /* __rtems__ */
+#endif /* RTEMS_USE_LWIP == 1 */
 }
 
 /**
diff --git a/spec/build/bsps/arm/stm32h7/grp.yml b/spec/build/bsps/arm/stm32h7/grp.yml
index 2147cdec88..24e318c44b 100644
--- a/spec/build/bsps/arm/stm32h7/grp.yml
+++ b/spec/build/bsps/arm/stm32h7/grp.yml
@@ -41,6 +41,8 @@ links:
   uid: optenusart6
 - role: build-dependency
   uid: opthse
+- role: build-dependency
+  uid: optlwip
 - role: build-dependency
   uid: optlinkcmds
 - role: build-dependency
diff --git a/spec/build/bsps/arm/stm32h7/optlwip.yml b/spec/build/bsps/arm/stm32h7/optlwip.yml
new file mode 100644
index 0000000000..d85a75b68a
--- /dev/null
+++ b/spec/build/bsps/arm/stm32h7/optlwip.yml
@@ -0,0 +1,24 @@
+actions:
+- get-boolean: null
+- env-assign: null
+- define-condition: null
+build-type: option
+default: false
+default-by-variant: []
+enabled-by: true
+format: '{}'
+links: []
+name: RTEMS_USE_LWIP
+description: |
+  This flag allows lwIP to work properly based on the STM32 lwIP example.
+  The user must take care of the following steps in the application:
+   1. The lwIP DMA descriptors have to be placed into the .bsp_no_cache section instead
+      of custom sections.
+   2. The sections need to be aligned to 32 bytes (0x20) boundaries.
+  This can be achieved by appending
+    __attribute__((section(.bsp_no_cache),__aligned__(0x20)));
+  to the descriptor definitions.
+type: build
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2020 Robin Mueller
-- 
2.25.1



More information about the devel mailing list