-
Notifications
You must be signed in to change notification settings - Fork 0
sdk例程:3种以太网使用模式
minichao9901 edited this page Feb 3, 2024
·
8 revisions
这个在前面已经做了大量实验,一直用的这个模式。这里不在论述。需要补充说明一下的是,有2种方法可以正常工作:
- 方法1,直接替换xemacpsif_physpeed.c,其余都不用改。这个时候可以自协商到1Gbps速度,可以正常工作到1Gbps。
- 方法2,手动设置lwip的速度为100Mbps,并注释platform_zynq.c的部分内容,可以正常工作到100Mbps。进一步方法,手动设置lwip的速度为1Gbps,对于ps_eth也是可以正常工作的。(作为对比,模式2的ps_eth0通过emio出去,就到不了1Gbps。)
在图中,有个不确定的是reset_rtl_0这个信号是否必须?(这是送给PHY的复位信号)(补充说明:经过实验,这个信号可以去掉)
注意zynq的FCLK_CLK0需要设置为200MHz,这是gmii->rgmii的要求。
- 初始情况,什么都不替换,只设置ip地址保持与电脑一个网段。结果如下,会出现phy error。
![image](https://private-user-images.githubusercontent.com/61445559/302015300-93f58be9-db8c-4ca7-ad4b-97b9f630f40e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxODM1NjEsIm5iZiI6MTcyNTE4MzI2MSwicGF0aCI6Ii82MTQ0NTU1OS8zMDIwMTUzMDAtOTNmNThiZTktZGI4Yy00Y2E3LWFkNGItOTdiOWY2MzBmNDBlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDA5MzQyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNhMDI0MzExYWI1N2Q5YWQyYWYyMjI4YWM0NzM3NjI0MWNkMTdiNDdiNGYxMGE5ZjgzMDM1YThhODM5NWE2YzgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TQ-KP8oHL9vLMxKm8n-zprUCFnoh94WlahdSquwwBQc)
- 替换xemacpsif_physpeed.c文件,可以协商成功速度1000Mbps,但是连不上。(后来进一步做做实验发现,如果手动设置为100Mbps,不会出现phy error。因此这一步不是必须的,但是设置100Mbps是必须的。本质还是速度太快,时序跟不上。)
![image](https://private-user-images.githubusercontent.com/61445559/302015337-49ce4f9f-bc05-43d5-8576-8f3bcfdd1523.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxODM1NjEsIm5iZiI6MTcyNTE4MzI2MSwicGF0aCI6Ii82MTQ0NTU1OS8zMDIwMTUzMzctNDljZTRmOWYtYmMwNS00M2Q1LTg1NzYtOGYzYmNmZGQxNTIzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDA5MzQyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNlYTczNmM3OWM3MzA1MDA4NWRlYjQ5ZDFiMTZlMGFkZWM4N2FkMThiOGZmMjU2YmRjN2Y3NjE5YmMxZWZlOGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hBiLauLnSB4dLkWbObDM0o44JfSBW9NTm07U2teAOBQ)
- 设置lwip的速度为100Mbps(这一步是必须的),会出现反复重启。
![image](https://private-user-images.githubusercontent.com/61445559/302015552-516f8af8-6d03-4da8-9ebb-6c3af6f769f4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxODM1NjEsIm5iZiI6MTcyNTE4MzI2MSwicGF0aCI6Ii82MTQ0NTU1OS8zMDIwMTU1NTItNTE2ZjhhZjgtNmQwMy00ZGE4LTllYmItNmMzYWY2Zjc2OWY0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDA5MzQyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBiMzg0YWY1ZTNlNzQ5OTA1OGIzMWY4Mjg0MjcxZGY5YmM0ZDVmM2ZkMGU5OWI5ZDNlZGM5OTg0OTQ2ZmQwYzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7TpH6U1429Vrf7COxbtdHhZn2mj-Oo77Yzlah_DXUzg)
- 注释platform_zynq.c文件,如下部分内容。(这一步是必须的)
![image](https://private-user-images.githubusercontent.com/61445559/302015385-7174716e-db2b-43e1-bb33-a57b40c68cde.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxODM1NjEsIm5iZiI6MTcyNTE4MzI2MSwicGF0aCI6Ii82MTQ0NTU1OS8zMDIwMTUzODUtNzE3NDcxNmUtZGIyYi00M2UxLWJiMzMtYTU3YjQwYzY4Y2RlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDA5MzQyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE2ZjJiZDU0NTllYmQxMzAwZmEzNGExYmI4MjIxYjc2YmM2ODRkZDgyOWRmMzY4YmQwYzA3NzI0MjFmYTk3MTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.w9FZlDl-AS03UyS-uGQgg-yuVXKi5mZ_dvZia7nw7E4)
- 成功运行
![image](https://private-user-images.githubusercontent.com/61445559/302015468-f0f91e17-656e-4e98-83cd-99f7fa4c23ba.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxODM1NjEsIm5iZiI6MTcyNTE4MzI2MSwicGF0aCI6Ii82MTQ0NTU1OS8zMDIwMTU0NjgtZjBmOTFlMTctNjU2ZS00ZTk4LTgzY2QtOTlmN2ZhNGMyM2JhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDA5MzQyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWExNDVlNzQ2ZGEwY2U5ZDUwNmQ1M2VkODNhNjA0OGUzZTIwZDFhMmZmMzE4NWZiMzU5NjAzMjU5MjMwOWVjMGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7tBHb8zR9rl4IidRURc8KkBrdV1qfElKQT5Bp6pTjEA)
- 总结一下,其实只需要做2件事就可以了:a)手动设置速度为100Mbps,b)注释platform_zynq.c部分内容
- 只是zynq的选项不同,有了前面的经验,这个实验很快就搞定了。整个攻略和过程与前面的模式2(ps_eth0通过emio出去一模一样),这里就不再重复了。
- 必须指出的是,sdk非常聪明。如果选择的eth1,那么调用lwip_echo_server例程,它就宏定义用的就是eth1,不用自己手动做任何修改。
- 框图如下
![image](https://private-user-images.githubusercontent.com/61445559/302041683-110fb257-86e5-4546-96ef-3b5724f21468.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxODM1NjEsIm5iZiI6MTcyNTE4MzI2MSwicGF0aCI6Ii82MTQ0NTU1OS8zMDIwNDE2ODMtMTEwZmIyNTctODZlNS00NTQ2LTk2ZWYtM2I1NzI0ZjIxNDY4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDA5MzQyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJhMjE4MzRmMzdiMWU3Y2E3YWE2NjFiYzViODNhNDhiNjIyZTAxZjg4YjkzNDJlODYzNmUwZGIwNjhmZDhhNTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.0iH3Lb3MtAUfbRFgKm-Ooe9aDFq23XJDSVdTrWuWD_Q)
单独的文章已经讲过。
目前看,只有模式0才能到1Gbps速度,其余模式都到不了1Gbps速度。