惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - midhillzhou

windows 11关闭防火墙 以使得 外部的开发板可以主动发起ping通电脑 windows上excel运行macro之后出现错误 在linux上移植sgdisk 在linux上移植phytool + 调试tja1103 以太网phy 使用gdb调试user程序 之 某个线程的调用栈 在uboot中修改tja 1103以太网phy from slave to master porting perf性能观测工具 porting 开源memtester uboot 2020版本下gpio命令的使用 + linux下的libgpiod lib库的移植使用 ubi文件系统的 制作 + 挂载 + 若干问题 i2c指令使用 + 仿照开源i2ctransfer实现的自己的i2ctransfer windows下outlook 撤回邮件 安装repo 使用lauterbach debug uboot之重定位 uboot中各种memory读写命令 uboot nand flash dump 环境变量 + 制作环境变量分区 + 代码结构详解 uboot bootm代码详解图 Beyond Compare 进行二进制文档的比对时,怎么去对齐(转载) notepad++分析log小技巧 使用继电器控制开发板上下电 uboot debug小技巧
uboot中调试景略以太网phy JL3111A2-NA
midhillzhou · 2026-04-24 · via 博客园 - midhillzhou

型号:JL3111A2-NA

Phy address: 0x03

1.首先在uboot下读取下phy的id

uboot$ mii write 0x03 0x0d 0x0001
uboot$ mii write 0x03 0x0e 0x0002
uboot$ mii write 0x03 0x0d 0x4001
uboot$ mii read 0x03 0x0e        
937C

查看datasheet,可以发现上面读出来的数值和datasheet一致,至少说明mdio接口是好的。

image

2.由于景略phy对端的phy设备是主,所以我们这里设置为slave

uboot$ mii write 0x03 0x0d 0x0001    //设置为slave
uboot$ mii write 0x03 0x0e 0x0834
uboot$ mii write 0x03 0x0d 0x4001
uboot$ mii write 0x03 0x0e 0x8000 

mii write 0x03 0x0e 0xc000 (设置为master)

mii write 0x03 0x0e 0x8000 (设置为slave)

image

景略提供的sample code代码体现如下

// Master or Slave [1.0x834]
#define REG_BASE_T1_PMAPMD_CONTROL   0x0834
#define PMA_MASTER_SLAVE               BIT(14)
#define CFG_FORCE_MASTER               0x1
#define CFG_FORCE_SLAVE                0x0

 3.由于我们想设置成千兆,看下目前的phy是否为千兆

uboot$ mii write 0x03 0x0d 0x0001   //上电默认,读出来千兆
uboot$ mii write 0x03 0x0e 0x0000
uboot$ mii write 0x03 0x0d 0x4001         
uboot$ mii read 0x03 0x0e
0040

mii write 0x03 0x0e 0x2000(设置为百兆)

image

景略提供的sample code代码体现如下

// Speed [1.0x0]
#define REG_PMAPMD_CONTROL1          0x0000
#define PMA_SOFT_RESET                 BIT(15)
#define PMA_SPEED_MASK                 (BIT(13) | BIT(6))
#define PMA_SPEED_1000                 BIT(6)
#define PMA_SPEED_100                  BIT(13)
#define CFG_FORCE_SPEED_1000           0x1
#define CFG_FORCE_SPEED_100            0x0

 4.由于我们想使用rgmii模式,看下现在的模式

uboot$ mii write 0x03 0x0d 0x0003  //上电默认,rgmii
uboot$ mii write 0x03 0x0e 0x8000
uboot$ mii write 0x03 0x0d 0x4003
uboot$ mii read 0x03 0x0e
0240                               //已经是默认rgmii

景略提供的sample code代码体现如下

// PHY Mode [3.0x8000]
#define REG_COMMON_USER_CONFIG0      0x8000
#define USER_SYSTEM_MODE_MASK          (BIT(3) | BIT(2) | BIT(1) | BIT(0))
#define ENABLE_TSEN                    BIT(5)
#define ENABLE_LED_0                   BIT(6)
#define ENABLE_LED_1                   BIT(7)
#define RGMII_COPPER                   0x0
#define SGMII_COPPER                   BIT(0)
#define MII_COPPER                     BIT(1)
#define RvMII_COPPER                   (BIT(1) | BIT(0))
#define RGMII_SGMII_PHY                BIT(2)
#define RGMII_SGMII_MAC                (BIT(2) | BIT(0))
#define RMII_COPPER                    (BIT(2) | BIT(1))

5.一切设定已经结束,下面最终的一步是 通过softreset生效刚刚的配置

uboot$ mii write 0x03 0x0d 0x0001  //soft reset
uboot$ mii write 0x03 0x0e 0x0000
uboot$ mii write 0x03 0x0d 0x4001
uboot$ mii write 0x03 0x0e 0x8040

由于是通过softreset bit位 self clean,自动清除来告知我们soft reset生效,所以可以查看一下是否已经self clean

uboot$ mii write 0x03 0x0d 0x0001  //check soft reset self clean
uboot$ mii write 0x03 0x0e 0x0000
uboot$ mii write 0x03 0x0d 0x4001
uboot$ mii read 0x03 0x0e
0040

景略提供的sample code代码体现如下

// soft reset [1.0x0]
#define REG_PMAPMD_CONTROL1          0x0000
#define PMA_SOFT_RESET                 BIT(15)
#define PMA_SPEED_MASK                 (BIT(13) | BIT(6))
#define PMA_SPEED_1000                 BIT(6)
#define PMA_SPEED_100                  BIT(13)
#define CFG_FORCE_SPEED_1000           0x1
#define CFG_FORCE_SPEED_100            0x0

6.好了,现在就可以看下link status了

uboot$ mii write 0x03 0x0d 0x0001 //check link status
uboot$ mii write 0x03 0x0e 0x0001
uboot$ mii write 0x03 0x0d 0x4001
uboot$ mii read 0x03 0x0e
0000

注意这里显示失败了,确实显示失败了,为什么?

link状态是低锁存,第一次读把低(0)的状态清除,第二次读到的是正确状态。

所以我们需要再读一次才能看到现在的link状态。

这一种设计并不是景略独有的,各大phy都通过这种精妙的设计来反映 曾经发生过link down,这样才能捕获是否以前快速发生过link down

uboot$ mii write 0x03 0x0d 0x0001 //check link status
uboot$ mii write 0x03 0x0e 0x0001
uboot$ mii write 0x03 0x0d 0x4001
uboot$ mii read 0x03 0x0e
0004

image

景略提供的sample code代码体现如下

// Link Status [1.0x1]
#define REG_PMAPMD_STATUS1           0x0001
#define PMA_LINK_STATUS                BIT(2)

7.至此一个完整的通过uboot命令行让phy link up的过程结束。

整个过程截图如下

image

附录一:后续之当对端改为slave后,我们将phy改为master,然后使phy link up

下面是试验截图,这里就不再赘述了,唯一想要强调的就是 任何设置的生效,都要进行soft reset

image

附录二:调整phy的rx,tx delay,以满足时序要求

// RGMII Delay, XMII Loopback [3.0x8800]
#define REG_XMII_UCFG0               0x8800
#define RMII_CLOCK_IN                  BIT(1)
#define ENABLE_XMII_LOOPBACK           BIT(2)
#define ENABLE_XMII_SSC                BIT(7)
#define ENABLE_RGMII_RX_DELAY          BIT(14)
#define ENABLE_RGMII_TX_DELAY          BIT(15)
m57$ mii write 0x03 0x0d 0x0003
m57$ mii write 0x03 0x0e 0x8800
m57$ mii write 0x03 0x0d 0x4003
m57$ mii read 0x03 0x0e
C830   /tx,rx delay均已打开