PHY Auto-negotiation succeeds in SDK example but fails in new project

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PHY Auto-negotiation succeeds in SDK example but fails in new project

Jump to solution
11,326 Views
petrama
Contributor III

IDE: MCUXpresso IDE v11.4.1. Board: MIMXRT1024 EVK

SDK example that works: evkmimxrt1024_lwip_udpecho_bm

A new C project is created by selecting the same network middelware options and board components as selected for the SDK example. The *.mex file of the SDK example is imported with all configurations selected. (Strangely there is some sort of conflict with the LPUART1 pins, but those two rows are deleted.) Then code is updated. The complete source code of the SDK ex. main source file (lwip_udpecho_bm.c ) is copied to the main source file of the new empty project. The project is compiled and run. The code execution is now stuck on line

netif_add(&netif, &netif_ipaddr, &netif_netmask, &netif_gw, &enet_config, EXAMPLE_NETIF_INIT_FN, ethernet_input);

while the following text is written to the debug serial port:

PHY Auto-negotiation failed. Please check the cable connection and link partner setting.

I have debugged into the function status_t ENET_MDIO_Read in file fsl_enet_mdio.c where the call

result = ENET_MDIO_WaitTransferOver(base);

returns 2 (readonly ?)

I hope these clues can give someone an idea, why this new project won't auto-negotiate, while the imported SDK lwip_udpecho_bm example works like a charm with the same IP configuration?

0 Kudos
Reply
1 Solution
10,827 Views
petrama
Contributor III

Thanks,

I have now found the crucial difference between the .cproject files:

<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.crt.advproject.link.memory.sections.1186610869" name="Extra linker script input sections" superClass="com.crt.advproject.link.memory.sections" valueType="stringList">
<listOptionValue builtIn="false" value="isd=*(NonCacheable.init);region=SRAM_DTC;type=.data"/>

<listOptionValue builtIn="false" value="isd=*(NonCacheable);region=SRAM_DTC;type=.bss"/>
</option>

Extra linker scripts.PNG

The cproject file of the project created from scratch did not contain these two option values. If included LAN-connection works every time. But now the question is: What do these two linker sections mean and why are they crucial for LAN-communication via phy, mdio and lwip libraries?

 

Note: As discovered earlier for a full solution the preprocessor directive FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE must also be defined.

View solution in original post

Tags (1)
13 Replies
11,303 Views
petrama
Contributor III

Hello Jeremy

The SDK version of lwIP is 2.2.0. MDIO (-common, -enet) and PHY-device-ksz8081 is 2.0.0.

A copy/paste of lwip_udpecho_bm results in 50 compiler errors in lwip/doc/NO_SYS_SampleCode.c

I have included PHY make-files. In my new project: files are included twice. Apart from that the following directives appear exclusively in the make-file of the new project:

-DSDK_OS_BAREMETAL
-Wall
-sp

And these directives appear only in the imported SDK make-file:

-DFSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE
-DLWIP_DISABLE_PBUF_POOL_SIZE_SANITY_CHECKS=1
-DMCUXPRESSO_SDK

Another peculiarity is that the SDK Manager shows that the driver nic301 is not included in the SDK-example but it seems to be mandatory in the new project.

I hope this info is useful.

rgds petr

0 Kudos
Reply
11,296 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply.
I'd like to know the version no of the SDK library instead of the version of Lwip, as I've not found the ENET_MDIO_WaitTransferOver() function in the fsl_enet_mdio.c.
Further, I was a bit confused with your steps of creating a new C project, and can you list the steps in detail?
I remember you use the MCUXPresso IDE, which can generate relate makefile automatically, so I'm curious why you include some makefiles during porting.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
11,291 Views
petrama
Contributor III

Hi TIC

The SDK_2.x_MIMXRT 1024-EVK is version 2.10.0 (see attached).

I create a new project by activating the menu item: File | New | New C/C++ Project.

In SDK Wizard I select MCU MIMXRT 1024xxxxx and board evkmimxrt1024 and press Next

On the "Configure the project" page I select default settings. But in addition I select the same Middelware (lwIP_udpecho_raw, Enet ethernet interface, lwIP) and Board Components (mdio-common, medio-enet, phy-device-ksz8081, xip_board) as selected for the  lwip_udpecho_bm project. The *.mex file of lwip_udpecho_bm is then imported and code is updateded. 

The complete source code of the SDK example main source file (lwip_udpecho_bm.c ) is copied to the main source file of the new empty project.

Then compile and run(debug). I do not create or edit any makefiles. I have just compared the files of the two projects and noticed the mentioned differences in the makefiles. CRLF has been inserted into the previously attached makefiles in order to make them more readable for comparison.

Included is the file fsl_enet_mdio.c that contains the function ENET_MDIO_WaitTransferOver.

rgds petr

0 Kudos
Reply
11,271 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Thanks for your reply and clarification.
Firstly, it can't create a complete TCP, Ping, or UDP demo from 0 via the SDK Wizard tool, it still needs the developer to modify the main(), add some macros, etc prior to meeting his demand.
Next, from my experience, you'd better use the Lwip demos as the template for further development, or you can make a copy of the above Lwip demos as the template.
The attachment is the copy of lwip_udpecho_bm demo benefit from the copy and paste feature of the MCUXPresso IDE.
Hope it helps.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
11,267 Views
petrama
Contributor III

Hi TIC

Thank you for your reply and project copy. I did of cause also copy code and macros of the lwip example to the new project. This I also stated in the first message of this thread. But I forgot to include that step in the previous message, but I have now done so. You see it is in bold italics.

I am astonished that the recommended procedure for building a project that utilizes network functionality is to extend a SDK demo. The specific problem here is that the demos are written in C not C++ and my experience is that, it causes problems changing a program from C to C++. You have to start-out as a C++ project. Therefore, I need to create a new project and add network functionality to that. But in the above as a first step, I have chosen to make a new C-program work first and then move on to a new C++ program later.

rgds petr

11,254 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply and the post illustrates the way of converting the Eclipse C project into C++ project, it may be helpful to you.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
11,222 Views
petrama
Contributor III

Thank you, Jeremy for the C => C++ project conversion recipe. But I actually found the cause of the problem. It was staring right at me. As mentioned earlier some defines were not set in the new project. One in particular is critical: FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE. I don't know what it means, but if defined, then auto-negotiation works . In the topic SDK - preprocessor defined symbols you suggest to search MCUXpresso SDK API Reference Manual  for this very symbol. I did so, but there was no hits. 

rgds petr

11,014 Views
petrama
Contributor III

Sadly, I have to modify my "solution": The define FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE is necessary to ensure that execution exits from the call to "netif_add(&netif,no, ...)", but that doesn't mean that a successful negotiation has taken place. My experience show, that in order for a new lwip project to communicate the EVK-board must first be "initialized" by running one of the lwip-SDK demos. After that new projects can be installed and run successfully. This is also the case if the EVK-board has been completely reset (GUI Flash Tool "mass erase" with SW8 temporarily set to SW8-3 = 0, SW8-4 = 1). A complete reset is sometimes necessary to overcome the error situation, that is quite frequent, where DEBUG or GUI Flash Tool continuously report flash erase errors (check sum) or if the device (EVK-board) is not detected.

So, the hunt is still on: What is it, that the lwip-demos do that prepares the board for ethernet communication? Is it something that is written to the boot sector? Or is it some hidden pins, that remain active also after a new program has been loaded?

 

Tags (2)
0 Kudos
Reply
10,863 Views
petrama
Contributor III

I have learned now that, if I use the .cproject file of the SDK-demo (with project name corrected of cause)  then the LAN communication works. I am trying to find the crucial difference between the files, but it is quite hard. Any ideas?

0 Kudos
Reply
10,830 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply.
- .project is where Eclipse starts whenever it opens up the project: it tells the workbench what plugins are needed.
- .cproject contains the settings specific to the CDT: your project's choice of build configurations, toolchains, individual tools, and so on.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
10,828 Views
petrama
Contributor III

Thanks,

I have now found the crucial difference between the .cproject files:

<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.crt.advproject.link.memory.sections.1186610869" name="Extra linker script input sections" superClass="com.crt.advproject.link.memory.sections" valueType="stringList">
<listOptionValue builtIn="false" value="isd=*(NonCacheable.init);region=SRAM_DTC;type=.data"/>

<listOptionValue builtIn="false" value="isd=*(NonCacheable);region=SRAM_DTC;type=.bss"/>
</option>

Extra linker scripts.PNG

The cproject file of the project created from scratch did not contain these two option values. If included LAN-connection works every time. But now the question is: What do these two linker sections mean and why are they crucial for LAN-communication via phy, mdio and lwip libraries?

 

Note: As discovered earlier for a full solution the preprocessor directive FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE must also be defined.

Tags (1)
10,810 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
In the ethernetif0_init() function, the RX and TX buffer descriptors should reside in the NonCacheable RAM, otherwise, it will encounter an issue if the NonCacheable RAM is missing.

jeremyzhou_0-1643079416275.png


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

11,306 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
1) Why this new project won't auto-negotiate, while the imported SDK lwip_udpecho_bm example works like a charm with the same IP configuration?
-- Before jumping to a conclusion, I was wondering if you can introduce version no of the SDK library, further, in MCUXPresso IDE, I'd like to suggest you use the copy and paste function to create a template demo project, instead of porting some files from zero.

jeremyzhou_0-1640573863141.png

Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply