cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F437 --> STM32F767 RTOS/LWIP Ethernet connection - 100BaseT problem

AlexF
Associate II

Hi,

I recently migrated an own board from a STM32F437 to a STM32F767 controller.

I use the HAL Library (and freeRTOS), and cubeMX to generate the code.

Everything worked fine with the M4 controller, but on the M7 controller, I only have a 10BaseT connection, a 100BaseT connection will not work at all!

Doesnt matter if I'm using autonegotiation or not...

I use a LAN8720A controller with RMII. The ioc file from cubeMX is migrated to the new processor. Everything else works fine (CAN, uart, spi, timers etc)

Can anybody figure out the problem?

Thanks in advance!

Alex

8 REPLIES 8
Piranha
Chief II

Check if PHY extended status register and speed/duplex flags are correct. Look for them at "Section 4: Extended PHY Registers" in stm32f7xx_hal_conf.h file.

thomfischer
Senior

Yes, known issue,

try this

/* Section 4: Extended PHY Registers */

 // ! corrected wrong cubemx values

#define PHY_SR                         ((uint16_t)0x1FU)   /*!< PHY status register Offset                     */

#define PHY_SPEED_STATUS               ((uint16_t)0x0004U) /*!< PHY Speed mask                                 */

#define PHY_DUPLEX_STATUS              ((uint16_t)0x0010U) /*!< PHY Duplex mask                                */

AlexF
Associate II

Okay, in the meanwhile I have the following facts:

Autonegotiation works with 100BaseTX full duplex. In this case the PHY_SR is 64 (0x40)

When I set 100BaseTX full duplex without autonegotiation PHY_SR is the same 0x40 after config, but I cant establish a connection.

When I read the definition of PHY_SR the 0x40 bit is RESERVED.

AlexF
Associate II

The Special Contraol and Status Register on adress 0x1f is:

Auto-Neg: 0x1058

100BaseT full: 0x0058

AlexF
Associate II

I still have problems, as

1) the ethernet connection is not always alright (sometimes after startup, it doesnt work at all),

2) and is never working with the fix setting 100 base T full duplex.

I am using the actual version of cubemx and atollic studio.

Every new inuput would be highly appreciated! Thank you!

Alex

AlexF
Associate II

I am not sure if I should post a new question.

My topics are now different:

I found out that the 100mbit/full duplex without autonegotiation has never been working on the M4 (I got wrong information, sorry!)

So I have the following problems left:

1) Autonegotiation Okay (auto switching to 100MBit full duplex), but the fixed setting with disabled autonegotiation and 100MBit full duplex doesnt work.

2 ) When I connect a switch between my laptop and the Stm32, it isnt working. If I initialise with a direct connection, then disconnect and put the switch in between, everything is working alright.

AlexF
Associate II

to inform everyone who looks for a solution to the problem 2) --> ethernet was not working with a switch, and also ethernet was not working when connected later. This thread helped me a lot: https://community.st.com/s/question/0D50X00009XkhxBSAR/initialize-lwip-with-ethernet-disconnected

Though I went the way over cubeMX, added LWIP_NETIF_STATUS_CHANGED and LWIP_NETIF_LINK_CALLBACK.

AlexF
Associate II

0690X000008iBMOQA2.pngI am struggling with the original thread: When I dont use autonegotiation, it doesnt work. Not on the M4, not on the M7.

If I use autonegotiation, 100MBaud full duplex is selected.

I use the following code in ethernetif.c, low_level_init()

#if 1

 heth.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE;

#else

 heth.Init.AutoNegotiation = ETH_AUTONEGOTIATION_DISABLE;

 heth.Init.DuplexMode = ETH_MODE_FULLDUPLEX;

 heth.Init.Speed = ETH_SPEED_100M;

#endif

 heth.Init.PhyAddress = LAN8742A_PHY_ADDRESS;

 heth.Init.RxMode = ETH_RXINTERRUPT_MODE;

 heth.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;

 heth.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII;

#if 1
  heth.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE;
#else
  heth.Init.AutoNegotiation = ETH_AUTONEGOTIATION_DISABLE;
  heth.Init.DuplexMode = ETH_MODE_FULLDUPLEX;
  heth.Init.Speed = ETH_SPEED_100M;
#endif
  heth.Init.PhyAddress = LAN8742A_PHY_ADDRESS;
  heth.Init.RxMode = ETH_RXINTERRUPT_MODE;
  heth.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
  heth.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII;

In the attached picture, there are my registers, for both fix and auto-negotiated.

Anyone has a clue? Every hint is appreciated.