Skip to main content
Graduate II
October 18, 2024
Solved

STM32H750B - TouchGFX and Ethernet

  • October 18, 2024
  • 1 reply
  • 4092 views

Hi

Using the following tools:

TouchGFX Designer 4.24.0

CubeIDE 1.16.1 and

CubeMx 6.11.0

 

I have attempted to build a system with ethernet capability.

 

I added the ethernet peripheral, LwIP compiled it without any errors, but the ethernet does not work.  The router it is connected to does not "see" the MAC address and fails to assign an IP address. I have DHCP enabled.

 

I bolted Adam Berlinger's code into one of my projects

Adams Ethernet

 

and that worked fine, with DHCP but the I cannot get the latest CubeMX build to work.

 

I have used the same board and cable that I used with Adams ethernet code for the new build so it's not the hardware.

Is the latest CubeMX build supposed to at least connect to a router and allow a ping test or do I have to do something else. The touchGFX code is working fine.

To be quite frank I find the ST Ethernet firmware and builds to be a nightmare.  You basically have to be an experienced network engineer first to understand the jargon. SMTP, DHCP etc which is never spelled out in full in the cube help panel and secondly to work your way through the code which is like spaghetti to find out what is going wrong.  LwIP is very clever, but its documentation is a joke considering how widely it is used.  Compared to a system like FreeRTOS which has excellent documentation, a vibrant forum and heap and heaps (pardon the pun) of examples, LwIP is more like a hackers bad dream. Its been around for over twenty years yet the documentation is sparse to say the least.

The Wiki content for the socket API is just a regurgitation of the header file for the macro or function. Here is the entry for setsocketopt:

 

Snag_15592871.png

Now I'm guessing that setsockopt sets some options for the socket the application programmer is trying to instantiate. But it doesn't explain that, or what the various macro parameters do and what valid inputs they can be.

I am guessing that s is the socket handle, but what the rest of them are is beyond me. An application Programming Interface needs a lot more than code it needs an explanation of what the function does, when you should use it and what its parameters are.

Surely someone in ST could come up with some code that would provide simple things like ubiquitous for ethernet such as  DHCP, mDNS, SNTP and a simple socket interface without the applications programmer needing to do a PhD in advanced network engineering. The hardware works fine, but the software...

From my little rant the perceptive among you probably sense I am just a little frustrated. I reckon I have spent more time trying to get ethernet to work than I have spent on all the other peripherals combined.

Am I being silly, am I missing something? What do others think?

 

Kind regards

Rob

 

    This topic has been closed for replies.
    Best answer by STea

    Hello @Garnett.Robert ,

    Did you try to implement the second suggestion on the FreeRTOS forum other than the first workaround. 

    Can you share with us the project version with FreeRTOS only reproducing the issue as on a fresh project with the same setting for FreeRTOS as yours I'm unable to reproduce this problem the rand function is working as expected. 
    Regards 

    1 reply

    ST Employee
    October 18, 2024

    Hello @Garnett.Robert ,

    Thank you for sharing your experience. I get that it can be quite challenging with Ethernet and related Middleware such as LWIP for the first time without initialization to basic networking concepts .i also agree with you on the basis that LWIP documentation lacks some details in the functions description but we try to explain its basics and ways of using it with our own documentation such as this AN3966 UM1713  AN3102 with LWIP concepts applicable on all STM32 series and a lot of examples using LWIP in community knowledge base such as the article you tried written by Adam and other example present in CubeFirmwareH7.and we are continently working on making the Ethernet Programming easier thro examples and documentation so any suggestions would be appreciated.
    From your problem description I don't get exactly where you get stuck at and what is not working exactly.
    If you could share with us more details about your software environment your IOC file and the relevant code changes apported to the generated it will help us investigate this issue.
    Regards 

    Graduate II
    October 20, 2024

    Hi, ST

     

    Thankyou for your reply.

     

    I will arc up the example I created and trace the program flow with the debugger to attempt to find the issue.  The problem is that this is a very time consuming process.  I will also have a look at the documents you listed although I am pretty sure I have read at least one of them.

     

    I have got the ethernet to work with an F7 board with a very old version of Cube, probably ten years or more ago but as I remember that was quite a struggle to. One of the problems I encountered since was that the ethernet driver has changed so much. Some functions that were provided in the older versions are no incorporated in new releases.  it is such a moving target.

     

    I think ST should work with AWS's Richard Barry and port in FreeRTOS+TCP.  Some people have got this working on STF4 and H7 platforms.  FreeRTOS+TCP may not have everything that LwIP does, but it is simpler and the documentation is much better.  Also the support by Richard and his colleagues is excellent. In my view developers  are never going to use an ST micro as the basis for some complex communications application, all you need is basic functions, DHCP, mDNS, sockets, SNTP, SMTP and IGCP and these should be set up to work out of the box.

    You should be able to ping the thing, get date and time, bring up a web page and move data around at modest rates.

    The reason I want to use ethernet is to for remote time stamped logging data  and to set the RTC so time-stamping can use network time to set the clock so that clock setting functions don't have to be provided to the user.  No one has to set the time on their mobile phone anymore or worry about IP addresses.

     

    I did think of trying ThreadX as a number of people claim that LwIP works better with this, however my understanding is that TouchGFX only works with FreeRTOs so ThreadX is only an option for headless systems.

     

    On another topic. A lot of people complain about the HAL_Drivers, I like them. With the exception of the ethernet driver they are generally easy to follow and if they don't provide the exact functionality you need you can clone and modify them.  You can speed them up by stripping out unused functionality and doing small optimisations. I also like the CubeMX suite and TouchGFX.  CuibeIDE has some great features, rtos aware, profiling, the Build analyser etc which are easy to use and very powerful.  I started embedded programming using Keil uVision which was robust, but the analytical functions were lacking.  I had to write a .map analyser for uVision to do the same thing that the Build Analyser does. Nobody wants to wade through fifty or more pages of a map file to get the info they want.

     

    Kind regards

    Rob

    Graduate II
    October 20, 2024

    Hi , i agree, that MX not prepare working peripheral code , but this is normal , it create only first hw level init.

    Too @STea appnotes have zero lines about MX setup to do it simpler.

    You need forget , that this exist here. But when you preffer realy worked envi choice for example GitHub - stm32duino/STM32Ethernet: Arduino library to support Ethernet for STM32 based board