New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unified STM32 Network Interface #804
base: main
Are you sure you want to change the base?
Conversation
@htibosch @AniruddhaKanhere Looks like this one NetworkInterface should work for all of Fxx & Hxx. The biggest difference between the HAL drivers are the usage of a few register macros that are named differently, but we can easily abstract that out. I've tested on a F767ZI and can test a H755ZI-Q, but don't have a way to test H5 at the moment. |
@holden-zenith wrote:
If I'm not mistaken, I have an H747, F407, and F746 for testing. So e.g. when testing F407, I use the latest HAL drivers for that part? |
@htibosch yes, last time I checked the latest F4 & F7 Eth drivers were 100% the same, so it should work the same. Before you test, I just noticed the call to HAL_ETH_ReleaseTxPacket needs to be moved to EMAC_IF_TX_EVENT because it calls the non interrupt safe version of vReleaseNetworkBufferAndDescriptor. I was using vNetworkBufferReleaseFromISR in the HAL_ETH_TxFreeCallback, but I guess it needs to be handled in the task to be compatible with both buffer allocation methods. |
As you may have read, I also prefer to handle network buffers from a normal task, rather than from an interrupt. I just came across this test:
which could be used to choose the correct network buffer function.
Doesn't F7 have multiple TX buffers each with their own hardware priority? I never used that feature, but I did have to disable it explicitly. Would you mind to send me an email so I can ask you little things now and then? hein [at] htibosch [dot] net Thanks, |
|
||
void HAL_ETH_RxAllocateCallback( uint8_t **buff ) | ||
{ | ||
NetworkBufferDescriptor_t * pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( ETH_RX_BUF_SIZE, pdMS_TO_TICKS( 0 ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that HAL_ETH_RxAllocateCallback()
will only be called from a task-context?
And also, do you always use BufferAllocation_2.c
? I think we'll have to use that to make sure that uncached memory will be used by DMA.
HI @holden-zenith thanks for creating the change. |
@shubnil Historically the STM32 HAL Eth drivers have been awful, which is part of the reason why edited HAL drivers were provided with the NetworkInterface.c. The newer HAL drivers are 'better' and all STM32's from F4, F7, H5, H7 essentially use the same driver now. So with this, edited HAL drivers are no longer necessary, it will be much easier to update to accommodate for future HAL updates, only one NetworkInterface is needed, and I am getting about 20mbps higher on iperf. I left the legacy drivers for now since anything prior to F4 won't be getting the HAL update, so technically I suppose only the Fxx driver would be necessary to leave. |
@holden-zenith , do you have a new version of NetworkInterface.c to test? |
@htibosch I'll probably push it in the next few days. I've been able to max out the bandwidth at 95mbps but it's not consistent and depends on compilation optimization. So I need to spend some time looking through the disassembly before I push it. |
@holden-zenith What's the status of this? I have a Nucleo-H563ZI board and would like to use FreeRTOS+TCP but the current port implementation does not support H5 series. |
@bjsowa Actually it would be great if you could test it. I have used it successfully on an F7 but there is potential concern with how it compares to the older driver in terms of performance, at least when tested with an F4. I do not have an H5 at the moment to try it. |
@holden-zenith I made the driver work for my nucleo board (at least DHCP and ping replies seem to work). I also ported it to work for version 4.0.0 of FreeRTOS-Plus-TCP (as I want IPv6 support) by mimicking the changes made in #602 for the current driver. |
On bjsowa#1 I integrated the new driver with the CMake build system. You can use this for reference. |
@bjsowa oh nice that's great. I am working on testing an H7 too so all of F4, F7, H5, & H7 will have been tested. Seems to be at least usable on all of them for the time being. In theory it should perform at least as well as the last driver but iperf apparently has had mixed results so far. |
The earlier drivers for STM32Fxx and STM32Hxx used a copy of ST's HAL driver. The driver was optimised for efficiency/speed, and support for zero-copy was added. @holden-zenith created a unified driver that is based on today's HAL drivers. The driver files must be obtained from ST. I tried the new driver on STM32F4 and STM32F7, and found that iperf3 shows lower speeds, both TX and RX. I wonder what the influence is of the extra mutex? I've got no testing equipment where I am now. In August I can do a real-time analyses of both drivers. |
@bjsowa Thanks for trying out the release candidate versions of 4.0.0. Did you face any difficulties or issues with IPv6? Also curious to know if you use the multiple endpoint feature? |
@htibosch Here are the ping results of the latest version. It seems to have much better latency, at least for me. |
@holden-zenith wrote:
That looks very promising. Dit you already commit and push the changes? |
/bot run formatting |
@HTRamsey I see that you put a lot of effort lately on this PR. Are you planning to finish it in the near future? |
@bjsowa multicasting and filtering will be finished after the other PR gets merged. I thought about abandoning parts of the HAL and using registers but I am trying to see if ST will accept my PRs to fix the HAL problems. |
I tried the current version. Ping flood and iperf tests seem promising:
With the default settings, I got ~70 Mbps on Iperf. I am able to achieve ~94 Mbps after increasing Now for the things that don't work:
I assume IPv6 and MDNS might not work due to unfinished multicasting and filtering support. |
Regarding the broken network down event, the problem lies on the |
Good catch on |
remove xCheckLoopback() usage
@HTRamsey Are you dropping the development of this driver or are planning on opening another PR in place of this? |
@bjsowa I still use it personally but I think with how inconsistent the stm HAL drivers are it is hard to keep all of them working together without creating certain fixes based on what HAL version the user has. @tony-josi-aws what are your thoughts |
AFAIK this is the only driver that works on H5. Perhaps we could add this driver alongside existing STM drivers as an alternative and just note which versions of the HAL libraries it was tested with? |
At least it works nicely with Hxx and could replace it. |
Maintaining the STM32 network interface up to date with respect to different versions of HAL drivers is not easy, as you mentioned. We were discussing internally what could be a better alternative. What do you think about the idea of keeping the version of HAL Ethernet drivers that are tested to be working with this network interface part of the PR so that it could act as a reference for users who may want to use a different version of the HAL Ethernet driver? |
New Unified STM32 driver for F4, F7, H5, H7.
Description
Implementation of new STM32 drivers. Does not support f2.
Test Steps
Checklist:
Related Issue
#766
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.