<div dir="ltr"><br><br>On Fri, Apr 2, 2021 at 2:25 AM Robin Müller <<a href="mailto:robin.mueller.m@gmail.com">robin.mueller.m@gmail.com</a>> wrote:<br>><br>> Hi Vijay,<br>><br>> It looks interesting, but I am not really a LwIP expert. I might look into it once I have more time in 1-2 weeks.<br>> I only have a BBB and the STM32H7 as test HW right now, but I guess this is a good starting point.<br>That indeed is a good starting point.<br><br>> Does this mean that the lwIP repository contains the architecture specific sources shown above? (so the DMA descriptors basically and maybe the LAN device driver).<br>Yes, The architecture-specific sources (like the LAN driver) will go to the lwip repository. The repository isn't really that well structured yet but I would be working on getting it in shape and there's also interest from a GSoC student, so this might come in shape with combined efforts. :)<br><br>>The lwIP support would then be built as part of the BSP?<br><br>The BSP would be built without any specific network stack. The network stack is supposed to be built separately and then used with the BSP, which means all the network-related drives go into respective network stacks (lwip is one of these 3 network stacks). So far this is the plan and the legacy network drivers have already been moved to its own separate repository, so we'll take a similar approach for lwip as well<br><br>>And would it use the mainloop mode or the OS mode? The STM32 example I implemented uses the mainloop mode with NO_SYS defined to 1, so I am not familiar with the OS mode, but I guess it would make sense to use the OS mode, porting it to RTEMS.<br><br><div>Yes, it would make sense to use the OS mode. I guess the NO_SYS needs to be set to 0, which means it'll use the sys_arch definitions. We have an RTEMS port for the sys_arch, done by Pavel Pisa. You can find it here: <a href="https://git.rtems.org/vijay/rtems-lwip.git/tree/lwip/ports/os/rtems/arch/sys_arch.h">https://git.rtems.org/vijay/rtems-lwip.git/tree/lwip/ports/os/rtems/arch/sys_arch.h</a> . It could be possible that all the drivers use this port and extend the sys_arch module according to the requirements, but I'm not totally sure if or how that'll work out. If each driver needs to have a separate sys_arch file, we'll have to add it along with the drivers and find a way to select the correct sources for the given bsp. I think that using an ini or yaml config file to define the requirements would be a clean solution to teach waf which modules to build.</div><div><br></div><div>Thank you for working on getting lwip integrated with stm32 h7. This would be a great start for the rtems-lwip and I'm happy to work with you to get it merged to that repository. I have also found a BBB driver for lwip and I'll try to integrate that as well. We'll probably be able to get hardware tests from these two boards soon. :)</div><div><br></div><div><br></div><div>Best regards,</div><div>Vijay</div><div><br></div>><br>> Kind Regards<br>> Robin<br>><br>><br>> On Mon, 29 Mar 2021 at 22:25, Vijay Kumar Banerjee <<a href="mailto:vijay@rtems.org">vijay@rtems.org</a>> wrote:<br>>><br>>> On Mon, Mar 29, 2021 at 9:52 AM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br>>> ><br>>> > On Mon, Mar 29, 2021 at 6:17 AM Robin Mueller <<a href="mailto:robin.mueller.m@gmail.com">robin.mueller.m@gmail.com</a>> wrote:<br>>> > ><br>>> > > This patch adds support for the STM32H743ZI-Nucleo board<br>>> > > variation. This currently works by setting the STM32H743ZI_NUCLEO<br>>> > > flag in the config.ini flag<br>>> > ><br>>> > > It also adds basic lwIP support which can be enabled<br>>> > > with the flag STM32H7_ADD_LWIP. This enables certain functionalities<br>>> > > required for lwIP to work properly<br>>> > ><br>>> > > This patch also changes the default implementation<br>>> > > of HAL_GetTick to return the system tick by forwarding the call<br>>> > > to the respective RTEMS function.<br>>> > ><br>>> > > ---<br>>> > >  bsps/arm/stm32h7/console/console-usart3-cfg.c | 21 ++++++++++++++++<br>>> > >  bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c      | 16 ++++++++-----<br>>> > >  .../stm32h7/include/Legacy/stm32_hal_legacy.h |  4 +++-<br>>> > >  bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h | 11 ++++++++-<br>>> > >  bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h |  1 +<br>>> > >  bsps/arm/stm32h7/start/bspstart.c             |  2 +-<br>>> > >  bsps/arm/stm32h7/start/stm32h7-hal-eth.c      |  3 +--<br>>> > >  spec/build/bsps/arm/stm32h7/bspstm32h7.yml    |  4 ++++<br>>> > >  spec/build/bsps/arm/stm32h7/opth743nucleo.yml | 13 ++++++++++<br>>> > >  spec/build/bsps/arm/stm32h7/optlwip.yml       | 24 +++++++++++++++++++<br>>> > >  10 files changed, 88 insertions(+), 11 deletions(-)<br>>> > >  create mode 100644 spec/build/bsps/arm/stm32h7/opth743nucleo.yml<br>>> > >  create mode 100644 spec/build/bsps/arm/stm32h7/optlwip.yml<br>>> > ><br>>> > > diff --git a/bsps/arm/stm32h7/console/console-usart3-cfg.c b/bsps/arm/stm32h7/console/console-usart3-cfg.c<br>>> > > index b40f6da5aa..dc552610e1 100644<br>>> > > --- a/bsps/arm/stm32h7/console/console-usart3-cfg.c<br>>> > > +++ b/bsps/arm/stm32h7/console/console-usart3-cfg.c<br>>> > > @@ -25,12 +25,32 @@<br>>> > >   * POSSIBILITY OF SUCH DAMAGE.<br>>> > >   */<br>>> > ><br>>> > > +#ifdef __rtems__<br>>> > > +#include <bspopts.h><br>>> > > +#endif<br>>> > > +<br>>> > >  #ifdef HAVE_CONFIG_H<br>>> > >  #include "config.h"<br>>> > >  #endif<br>>> > ><br>>> > >  #include <stm32h7/hal.h><br>>> > ><br>>> > > +#if STM32H743ZI_NUCLEO == 1<br>>> > > +const stm32h7_uart_config stm32h7_usart3_config = {<br>>> > > +  .gpio = {<br>>> > > +    .regs = GPIOD,<br>>> > > +    .config = {<br>>> > > +      .Pin = GPIO_PIN_8 | GPIO_PIN_9,<br>>> > > +      .Mode = GPIO_MODE_AF_PP,<br>>> > > +      .Pull = GPIO_NOPULL,<br>>> > > +      .Speed = GPIO_SPEED_FREQ_LOW,<br>>> > > +      .Alternate = GPIO_AF7_USART3<br>>> > > +    }<br>>> > > +  },<br>>> > > +  .irq = USART3_IRQn,<br>>> > > +  .device_index = 2<br>>> > > +};<br>>> > > +#else<br>>> > >  const stm32h7_uart_config stm32h7_usart3_config = {<br>>> > >    .gpio = {<br>>> > >      .regs = GPIOB,<br>>> > > @@ -45,3 +65,4 @@ const stm32h7_uart_config stm32h7_usart3_config = {<br>>> > >    .irq = USART3_IRQn,<br>>> > >    .device_index = 2<br>>> > >  };<br>>> > > +#endif /*  STM32H743ZI_NUCLEO == 1 */<br>>> > > diff --git a/bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c b/bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c<br>>> > > index 4f2634df5b..6c3590bce8 100644<br>>> > > --- a/bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c<br>>> > > +++ b/bsps/arm/stm32h7/hal/stm32h7xx_hal_eth.c<br>>> > > @@ -146,6 +146,10 @@<br>>> > >  /* Includes ------------------------------------------------------------------*/<br>>> > >  #include "stm32h7xx_hal.h"<br>>> > ><br>>> > > +#ifdef __rtems__<br>>> > > +#include <bspopts.h><br>>> > > +#endif<br>>> > > +<br>>> > >  /** @addtogroup STM32H7xx_HAL_Driver<br>>> > >    * @{<br>>> > >    */<br>>> > > @@ -361,10 +365,10 @@ HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth)<br>>> > >    /*------------------ MAC, MTL and DMA default Configuration ----------------*/<br>>> > >    ETH_MACDMAConfig(heth);<br>>> > ><br>>> > > -#ifndef __rtems__<br>>> > > +#if STM32H7_ADD_LWIP == 1<br>>> ><br>>> > Someone else may be able to address whether we need to disable this<br>>> > stuff for 'non-lwip' builds of stm32. There is an ongoing effort to<br>>> > collect lwip drivers and lwip build as a library after building rtems,<br>>> > so maybe this will move eventually to the lwip driver repo when that<br>>> > gets into production.<br>>> ><br>>> Hi,<br>>><br>>> Yes, we're moving all the network stacks out of RTEMS so that a user<br>>> can choose their preferred network stack to work with RTEMS. The LWIP<br>>> repository is in initial state and it is gradually starting to include<br>>> the drivers. This lwip patch would be a great start of adding the<br>>> drivers and I'm happy to work with you to get it integrated into that<br>>> repository. Would you be interested in taking a look at it and adding<br>>> it to the rtems-lwip repository?<br>>> <a href="https://git.rtems.org/vijay/rtems-lwip.git/">https://git.rtems.org/vijay/rtems-lwip.git/</a><br>>><br>>> Once this is in a working state, this repository will be added to<br>>> rtems top directory as official rtems-lwip.<br>>><br>>><br>>> Best regards,<br>>> Vijay<br>>> > >    /* SET DSL to 64 bit */<br>>> > >    MODIFY_REG(heth->Instance->DMACCR, ETH_DMACCR_DSL, ETH_DMACCR_DSL_64BIT);<br>>> > > -#endif /* __rtems__ */<br>>> > > +#endif<br>>> > ><br>>> > >    /* Set Receive Buffers Length (must be a multiple of 4) */<br>>> > >    if ((heth->Init.RxBuffLen % 0x4U) != 0x0U)<br>>> > > @@ -2647,7 +2651,7 @@ static void ETH_MAC_MDIO_ClkConfig(ETH_HandleTypeDef *heth)<br>>> > >    */<br>>> > >  static void ETH_DMATxDescListInit(ETH_HandleTypeDef *heth)<br>>> > >  {<br>>> > > -#ifndef __rtems__<br>>> > > +#if STM32H7_ADD_LWIP == 1<br>>> > >    ETH_DMADescTypeDef *dmatxdesc;<br>>> > >    uint32_t i;<br>>> > ><br>>> > > @@ -2674,7 +2678,7 @@ static void ETH_DMATxDescListInit(ETH_HandleTypeDef *heth)<br>>> > ><br>>> > >    /* Set Transmit Descriptor Tail pointer */<br>>> > >    WRITE_REG(heth->Instance->DMACTDTPR, (uint32_t) heth->Init.TxDesc);<br>>> > > -#endif /* __rtems__ */<br>>> > > +#endif /* STM32H7_ADD_LWIP == 1 */<br>>> > >  }<br>>> > ><br>>> > >  /**<br>>> > > @@ -2686,7 +2690,7 @@ static void ETH_DMATxDescListInit(ETH_HandleTypeDef *heth)<br>>> > >    */<br>>> > >  static void ETH_DMARxDescListInit(ETH_HandleTypeDef *heth)<br>>> > >  {<br>>> > > -#ifndef __rtems__<br>>> > > +#if STM32H7_ADD_LWIP == 1<br>>> > >    ETH_DMADescTypeDef *dmarxdesc;<br>>> > >    uint32_t i;<br>>> > ><br>>> > > @@ -2719,7 +2723,7 @@ static void ETH_DMARxDescListInit(ETH_HandleTypeDef *heth)<br>>> > ><br>>> > >    /* Set Receive Descriptor Tail pointer Address */<br>>> > >    WRITE_REG(heth->Instance->DMACRDTPR, ((uint32_t)(heth->Init.RxDesc + (((uint32_t)(ETH_RX_DESC_CNT - 1))*sizeof(ETH_DMADescTypeDef)))));<br>>> > > -#endif /* __rtems__ */<br>>> > > +#endif /* STM32H7_ADD_LWIP == 1 */<br>>> > >  }<br>>> > ><br>>> > >  /**<br>>> > > diff --git a/bsps/arm/stm32h7/include/Legacy/stm32_hal_legacy.h b/bsps/arm/stm32h7/include/Legacy/stm32_hal_legacy.h<br>>> > > index c311c1618e..c4fa5d7151 100644<br>>> > > --- a/bsps/arm/stm32h7/include/Legacy/stm32_hal_legacy.h<br>>> > > +++ b/bsps/arm/stm32h7/include/Legacy/stm32_hal_legacy.h<br>>> > > @@ -420,7 +420,9 @@<br>>> > >  #define TYPEPROGRAMDATA_FASTBYTE      FLASH_TYPEPROGRAMDATA_FASTBYTE<br>>> > >  #define TYPEPROGRAMDATA_FASTHALFWORD  FLASH_TYPEPROGRAMDATA_FASTHALFWORD<br>>> > >  #define TYPEPROGRAMDATA_FASTWORD      FLASH_TYPEPROGRAMDATA_FASTWORD<br>>> ><br>>> > Can you instead use:<br>>> > #ifndef __rtems___<br>>> > > -#define PAGESIZE                      FLASH_PAGE_SIZE<br>>> > > +/* Commented out for the RTEMS BSP because there can be nameclashes with another<br>>> > > +similar defininition in limits.h */<br>>> > > +//#define PAGESIZE                      FLASH_PAGE_SIZE<br>>> > #endif<br>>> ><br>>> > >  #define TYPEPROGRAM_FASTBYTE          FLASH_TYPEPROGRAM_BYTE<br>>> > >  #define TYPEPROGRAM_FASTHALFWORD      FLASH_TYPEPROGRAM_HALFWORD<br>>> > >  #define TYPEPROGRAM_FASTWORD          FLASH_TYPEPROGRAM_WORD<br>>> > > diff --git a/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h b/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h<br>>> > > index d423e4f782..b608188b4f 100644<br>>> > > --- a/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h<br>>> > > +++ b/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h<br>>> > > @@ -21,6 +21,9 @@<br>>> > >  #ifndef __STM32H7xx_HAL_CONF_H<br>>> > >  #define __STM32H7xx_HAL_CONF_H<br>>> > ><br>>> > > +#ifdef __rtems__<br>>> > > +#include <bspopts.h><br>>> > > +#endif /* __rtems__ */<br>>> > >  #ifdef __cplusplus<br>>> > >   extern "C" {<br>>> > >  #endif<br>>> > > @@ -103,7 +106,13 @@<br>>> > >    *        (when HSE is used as system clock source, directly or through the PLL).<br>>> > >    */<br>>> > >  #if !defined  (HSE_VALUE)<br>>> > > -#define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */<br>>> > > +  #if STM32H743ZI_NUCLEO == 1<br>>> > > +    /*!< External oscillator clock for the STM32H743ZI Nucleo */<br>>> > > +    #define HSE_VALUE    ((uint32_t)8000000)<br>>> > > +  #else<br>>> > > +    /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */<br>>> > > +    #define HSE_VALUE    ((uint32_t)25000000)<br>>> > > +  #endif /* STM32H743ZI_NUCLEO == 1 */<br>>> > >  #endif /* HSE_VALUE */<br>>> > ><br>>> > >  #if !defined  (HSE_STARTUP_TIMEOUT)<br>>> > > diff --git a/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h b/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h<br>>> > > index e9fecc4aa0..b171f7dac7 100644<br>>> > > --- a/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h<br>>> > > +++ b/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h<br>>> > > @@ -27,6 +27,7 @@ extern "C" {<br>>> > ><br>>> > >  /* Includes ------------------------------------------------------------------*/<br>>> > >  #include "stm32h7xx_hal_def.h"<br>>> > > +#include "stm32h7xx_hal_dma.h"<br>>> > ><br>>> > >  /** @addtogroup STM32H7xx_HAL_Driver<br>>> > >    * @{<br>>> > > diff --git a/bsps/arm/stm32h7/start/bspstart.c b/bsps/arm/stm32h7/start/bspstart.c<br>>> > > index 2fc8133cca..d942fbdcb3 100644<br>>> > > --- a/bsps/arm/stm32h7/start/bspstart.c<br>>> > > +++ b/bsps/arm/stm32h7/start/bspstart.c<br>>> > > @@ -34,7 +34,7 @@<br>>> > ><br>>> > >  uint32_t HAL_GetTick(void)<br>>> > >  {<br>>> > > -  return 0;<br>>> > > +  return rtems_clock_get_ticks_since_boot();<br>>> > >  }<br>>> > ><br>>> > >  uint32_t stm32h7_systick_frequency(void)<br>>> > > diff --git a/bsps/arm/stm32h7/start/stm32h7-hal-eth.c b/bsps/arm/stm32h7/start/stm32h7-hal-eth.c<br>>> > > index 46475f4316..36363f84a5 100644<br>>> > > --- a/bsps/arm/stm32h7/start/stm32h7-hal-eth.c<br>>> > > +++ b/bsps/arm/stm32h7/start/stm32h7-hal-eth.c<br>>> > > @@ -64,8 +64,7 @@ static const stm32h7_gpio_config gpioa = {<br>>> > >    }<br>>> > >  };<br>>> > ><br>>> > > -void<br>>> > > -HAL_ETH_MspInit(ETH_HandleTypeDef *heth)<br>>> > > +void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)<br>>> > why this change?<br>>> ><br>>> > >  {<br>>> > >    stm32h7_clk_enable(STM32H7_MODULE_ETH1MAC);<br>>> > >    stm32h7_clk_enable(STM32H7_MODULE_ETH1TX);<br>>> > > diff --git a/spec/build/bsps/arm/stm32h7/bspstm32h7.yml b/spec/build/bsps/arm/stm32h7/bspstm32h7.yml<br>>> > > index 80e13472c8..89b5a3c00d 100644<br>>> > > --- a/spec/build/bsps/arm/stm32h7/bspstm32h7.yml<br>>> > > +++ b/spec/build/bsps/arm/stm32h7/bspstm32h7.yml<br>>> > > @@ -247,6 +247,10 @@ links:<br>>> > >    uid: ../../optconsolebaud<br>>> > >  - role: build-dependency<br>>> > >    uid: ../../optconsoleirq<br>>> > > +- role: build-dependency<br>>> > > +  uid: opth743nucleo<br>>> > > +- role: build-dependency<br>>> > > +  uid: optlwip<br>>> > >  - role: build-dependency<br>>> > >    uid: ../grp<br>>> > >  - role: build-dependency<br>>> > > diff --git a/spec/build/bsps/arm/stm32h7/opth743nucleo.yml b/spec/build/bsps/arm/stm32h7/opth743nucleo.yml<br>>> > > new file mode 100644<br>>> > > index 0000000000..2c4176bf00<br>>> > > --- /dev/null<br>>> > > +++ b/spec/build/bsps/arm/stm32h7/opth743nucleo.yml<br>>> > > @@ -0,0 +1,13 @@<br>>> > > +actions:<br>>> > > +- get-boolean: null<br>>> > > +- define-condition: null<br>>> > > +build-type: option<br>>> > > +default: false<br>>> > > +default-by-variant: []<br>>> > > +enabled-by: true<br>>> > > +format: '{}'<br>>> > > +links: []<br>>> > > +name: STM32H743ZI_NUCLEO<br>>> > > +description: |<br>>> > > +  Nucleo board. Use 8 MHz HSE external clock and different pins for the UART console.<br>>> > > +type: build<br>>> > > diff --git a/spec/build/bsps/arm/stm32h7/optlwip.yml b/spec/build/bsps/arm/stm32h7/optlwip.yml<br>>> > > new file mode 100644<br>>> > > index 0000000000..04613a3bb6<br>>> > > --- /dev/null<br>>> > > +++ b/spec/build/bsps/arm/stm32h7/optlwip.yml<br>>> > > @@ -0,0 +1,24 @@<br>>> > > +actions:<br>>> > > +- get-boolean: null<br>>> > > +- env-assign: null<br>>> > > +- define-condition: null<br>>> > > +build-type: option<br>>> > > +default: false<br>>> > > +default-by-variant: []<br>>> > > +enabled-by: true<br>>> > > +format: '{}'<br>>> > > +links: []<br>>> > > +name: STM32H7_ADD_LWIP<br>>> > > +description: |<br>>> > > +  This changes the code to allow lwIP to work properly based on the STM32 lwIP example.<br>>> > > +  The user must take care of the following steps in the application:<br>>> > > +   1. The lwIP DMA descriptors have to be placed into the .bsp_no_cache section instead<br>>> > > +      of custom sections<br>>> > > +   2. The sections need to be aligned to 32 bytes (0x20) boundaries<br>>> > > +  This can be achieved by appending<br>>> > > +    __attribute__((section(.bsp_no_cache),__aligned__(0x20)));<br>>> > > +  to the descriptor definitions.<br>>> > > +type: build<br>>> > > +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause<br>>> > > +copyrights:<br>>> > > +- Copyright (C) 2020 Robin Mueller<br>>> > > --<br>>> > > 2.23.0.windows.1<br>>> > ><br>>> > > _______________________________________________<br>>> > > devel mailing list<br>>> > > <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>>> > > <a href="http://lists.rtems.org/mailman/listinfo/devel">http://lists.rtems.org/mailman/listinfo/devel</a><br>>> > _______________________________________________<br>>> > devel mailing list<br>>> > <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>>> > <a href="http://lists.rtems.org/mailman/listinfo/devel">http://lists.rtems.org/mailman/listinfo/devel</a></div>