Skip to main content
Elwood Downey
Associate III
June 9, 2017
Question

example using HAL ETH without LWiP for raw ethernet frames?

  • June 9, 2017
  • 13 replies
  • 14049 views
Posted on June 09, 2017 at 20:41

[reposting after 30 days of no responses]

Hello all,

I have been making great progress using CubeMX and HAL for lots of things, now I want to try ethernet. My application is very simple, I only want to send and receive raw ethernet frames -- no UDP or TCP at all. I also prefer not to use LWiP for something so basic. Can anyone point me to an example of raw ethernet frame IO using just HAL? I will be using Nucleo F429ZI.

My requirements:

[ ] send a raw frame (source and destination MAC address, type IP and payload, total less than 1500 bytes)

[ ] receive interrupt upon receipt of a raw ethernet frame

My transactions are slow and simple, I do not even need any buffer queuing.

Thanks for any tips.

#raw-ethernet-frame

13 replies

Elwood Downey
Associate III
May 5, 2017
Posted on May 05, 2017 at 22:14

Hello all,

I have been making great progress using CubeMX and HAL for lots of things, now I want to try ethernet. My application is very simple, I only want to send and receive raw ethernet frames -- no UDP or TCP at all. I also prefer not to use LWiP for something so basic. Can anyone point me to an example of raw ethernet frame IO using just HAL? I will be using Nucleo F429ZI.

My requirements:

[ ] send a raw frame (source and destination MAC address, type IP and payload, total less than 1500 bytes)

[ ] receive interrupt upon receipt of a raw ethernet frame

My transactions are slow and simple, I do not even need any buffer queuing.

Thanks for any tips.

#raw-ethernet-frame #stm32f429 #hal
Tesla DeLorean
Guru
June 10, 2017
Posted on June 10, 2017 at 15:56

You'll likely need to separate the frame and initialization code from the layer above you don't want

        (##) HAL_ETH_TransmitFrame();

        (##) HAL_ETH_GetReceivedFrame(); (should be called into an infinite loop)

        (##) HAL_ETH_GetReceivedFrame_IT(); (called in IT mode only)

Tear what you need out of ethernetif.c

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Elwood Downey
Associate III
June 22, 2017
Posted on June 22, 2017 at 21:55

Thanks Clive. Making a temporary lwip project thengutting ethernetif.c was extremely helpful. I have it all working now, getting close to wire speeds both ways.

In case others see this thread in the future, here are a few observations:

* Phy address must be 0 for the

Nucleo F429ZI.

CubeMX 4.0 still sets it to 1 by default even though this was reported over a year ago in t

https://community.st.com/0D50X00009XkgfISAR

.

* Never could get HAL_ETH_TxCpltCallback to fire. Fortunately the tx descriptor states allow

reliable in-line retries.

*

The default MAC filters are such that

RxCplt will only fire on receipt of broadcast MAC FF:FF:FF:FF:FF:FF or the one passed to

HAL_ETH_Init().

* Speaking of MAC, the array to which

heth.Init.MACAddr is set in

MX_ETH_Init() really should be static so it can be used later.

angus schmaloer
Associate III
October 9, 2017
Posted on October 09, 2017 at 14:50

Hey,

I want to apply Ethernet on my stm32f779I-EVAL board, but i am very new to Ethernet.

I also don't want to use the lwIP driver, because i only want to send some json strings.

Do you have by any change an example program ready?

David Dk
Visitor II
December 6, 2017
Posted on December 06, 2017 at 11:40

Hi,

Downey.Elwood

eludar

any chance that one of you upload a minimal working example?

Best wishes, David

Aleksandar Radulovic
Visitor II
December 7, 2017
Posted on December 07, 2017 at 10:08

Hi David,

as far as enabling the TX callback is concerned, you can use the provided examples. In low_level_init() add the above mentioned two lines of code. For example, you can add them after initializing descriptors lists:

/* Initialize Tx Descriptors list: Chain Mode */

  HAL_ETH_DMATxDescListInit(&heth, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);

     

  /* Initialize Rx Descriptors list: Chain Mode  */

  HAL_ETH_DMARxDescListInit(&heth, DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);

 

  __HAL_ETH_DMA_ENABLE_IT(&heth, ETH_DMA_IT_T);

  __HAL_ETH_DMATXDESC_ENABLE_IT(&heth);

I haven't actually used the TX callback for real - I was just curious how to enable it...

Best regards,

Aleksandar

khaaal
Associate II
July 18, 2019

Is there an example of sending raw ethernet frames without lwip ?

khaaal
Associate II
July 18, 2019

Is there an example of sending raw ethernet frames without Lwip ?

nguen nguyen
Associate III
September 26, 2019
Piranha
Principal III
July 18, 2019

The solution is in a first answer: "Tear what you need out of ethernetif.c"

> Never could get HAL_ETH_TxCpltCallback to fire.

https://community.st.com/s/question/0D50X0000B2AG7FSQW/ethernet-send-complete-interrupt-not-triggered-in-stm32f7

ranran
Senior
September 26, 2019

Hi,

Can someone share the loopback example using HAL APIs (without LWIP) ?

Thank you

nguen nguyen
Associate III
September 26, 2019
nguen nguyen
Associate III
September 26, 2019
Akash_k
Associate III
October 19, 2019

Which software can we use for raw ethernet frames?

Piranha
Principal III
June 20, 2020

This code is simple and a good starting point for both - Ethernet and lwIP:

https://github.com/lsgunth/lwip_contrib