15AH, San Francisco

California, United States.

Send Your Mail At:

tianyingkejishe@sina.cn

Working Hours

Mon-Sat: 9.30am To 7.00pm

分类标题

Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et dolore feugait.

分类归档 MCU/MPU/GPU

【Ubuntu】飞腾s5000c移植国产网卡WX1860AL2驱动

硬件平台:

国产飞腾芯片s5000c-16

国产网讯网卡WX1860AL2

软件平台:

Distributor ID: Ubuntu
Description: Ubuntu Built with Buildroot, based on Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy

1、获取网卡驱动

直接从官网下载就好,本实现使用的版本:ngbe-1.2.7.zip

2、编译安装(一定要在目标机操作)

不同平台上编译,安装的命令不同:

Kylin V10/银河麒麟 操作系统:

编译:

make CHNOS=KYLIN

安装:

make CHNOS=KYLIN modules_install

或者

make CHNOS=KYLIN install

UOS 操作系统:

编译:

make CHNOS=UOS

安装

make CHNOS=UOS modules_install

或者

make CHNOS=UOS install

Euler 操作系统:

编译:

make CHNOS=EULER

安装:

make CHNOS=EULER modules_install

或者

make CHNOS=EULER install

其他平台操作系统:

编译:

make

安装:make modules_install

或者

make install

4) 加载驱动:

modprobe txgbe (仅安装完首次需要手动加载,若重启系统,系统会自动加载驱动)。

5)查看驱动是否加载成功:

[root@SW ~]# lsmod | grep txgbe

txgbe 208399 0

表明驱动已经加载上。

3、卸载驱动

1)显示已安装的驱动:

[root@localhost ~]# lsmod | grep txgbe

txgbe 385024 0

2)卸载驱动:rmmod txgbe

[root@localhost ~]# rmmod txgbe

3) 再次查看已安装的驱动,已经没有 txgbe 驱动。

[root@localhost ~]# lsmod | grep txgbe

4、参考资料

5、适配后的网卡驱动

[Arm]version magic ‘5.6.0-rc5+ SMP mod_unload ‘ should be…问题研究

1, 首先,为什么会出现修改了kernel重新编译后magic num改变
内核版本是如何生成的:

Linux 内核在进行模块装载时先完成模块的 CRC 值校验,再核对 vermagic 中的字符信息,linux版本在 include/generated/utsrelease.h中定义,文件中的内容如下:

#define UTS_RELEASE "4.9.123"

utsrelease.h是kernel编译后自动生成的,用户更改里面的内容不会有效果。
这个值可以通过修改最顶层的Makefile文件来修改。

VERSION = 4
PATCHLEVEL = 9                
SUBLEVEL = 123                
EXTRAVERSION =
...

init/version.c中,定义了kernel启动时的第一条打印信息:

/* FIXED STRINGS! Don't touch! */
const char linux_banner[] =
  "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
  LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";

const char linux_proc_banner[] =
  "%s version %s"
  " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
  " (" LINUX_COMPILER ") %s\n";

这里UTS_RELEASE在kernel编译时自动生成

init/main.casmlinkage __visible void __init start_kernel(void)函数中,有kernel启动的第一条打印信息,这条信息是dmesg命令打印出来:

pr_notice("%s", linux_banner);

驱动模块的version magic信息是怎么生成的:

4.x 内核下,在include/linux/vermagic.h中定义有VERMAGIC_STRING,如下:

#include <generated/utsrelease.h>
              
/* Simply sanity version stamp for modules. */
#ifdef CONFIG_SMP
#define MODULE_VERMAGIC_SMP "SMP "
#else
#define MODULE_VERMAGIC_SMP ""
#endif
#ifdef CONFIG_PREEMPT
#define MODULE_VERMAGIC_PREEMPT "preempt "
#else
#define MODULE_VERMAGIC_PREEMPT ""
#endif
#ifdef CONFIG_MODULE_UNLOAD
#define MODULE_VERMAGIC_MODULE_UNLOAD "mod_unload "
#else
#define MODULE_VERMAGIC_MODULE_UNLOAD ""
#endif 
#ifdef CONFIG_MODVERSIONS
#define MODULE_VERMAGIC_MODVERSIONS "modversions "
#else
#define MODULE_VERMAGIC_MODVERSIONS ""
#endif
#ifndef MODULE_ARCH_VERMAGIC
#define MODULE_ARCH_VERMAGIC ""
#endif  

#define VERMAGIC_STRING             \
  UTS_RELEASE " "             \
  MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT       \
  MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
  MODULE_ARCH_VERMAGIC

VERMAGIC_STRING不仅包含内核版本号,还包含有内核使用的SMP与preempt, MODULE_UNLOAD, 架构等配置信息。模块在编译时,我们可以看到屏幕上会显示”MODPOST”。

  <~/Documents/Demo/driver/debugfs> make
make -C ~/kernel/ SUBDIRS=~/Documents/Demo/driver/debugfs modules
make[1]: Entering directory '~/kernel'
  CC [M]  ~/Documents/Demo/driver/debugfs/my_debugfs.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      ~/Documents/Demo/driver/debugfs/my_debugfs.mod.o
  LD [M]  ~/Documents/Demo/driver/debugfs/my_debugfs.ko
make[1]: Leaving directory '~/kernel'

在此阶段, VERMAGIC_STRING会添加到模块的modinfo段。在内核源码目录下scripts\mod\modpost.c文件中可以看到模块后续处理部分的代码。模块编译生成后,通过modinfo my_debugfs.ko命令可以查看此模块的vermagic等信息。

  <~/Documents/Demo/driver/debugfs> modinfo my_debugfs.ko 
filename:      ~/Documents/Demo/driver/debugfs/my_debugfs.ko
license:        GPL
depends:        
vermagic:       4.9.123 SMP preempt mod_unload aarch64

4.x 内核下的模块装载器里保存有内核的版本信息,在装载模块时,装载器会比较所保存的内核vermagic与此模块的modinfo段里保存的vermagic信息是否一致,两者一致时,模块才能被装载。

为了使两个版本一致:可以把 依赖源码中的include/linux/vermagic.h中的UTS_RELEASE修改成与目标机器的版本一致,这样,再次编译模块就可以了。

内核模块版本和内核版本不一致的处理方法

2, 发现版本号会追加git的版本号,还有个“+”
向linux内核版本号添加字符/为何有时会自动添加“+”号,根据这篇文章,一步一步试一下

第一步:去掉git的附加信息
先在menuconfig中找到

  │ Symbol: LOCALVERSION [=]                                                                                                                                                                                   │  
  │ Type  : string                                                                                                                                                                                             │  
  │ Prompt: Local version - append to kernel release                                                                                                                                                           │  
  │   Location:                                                                                                                                                                                                │  
  │ (1) -> General setup                                                                                                                                                                                       │  
  │   Defined at init/Kconfig:81                                                                                                                                                                               │  
  │                                                                                                                                                                                                            │  
  │                                                                                                                                                                                                            │  
  │ Symbol: LOCALVERSION_AUTO [=n]                                                                                                                                                                             │  
  │ Type  : boolean                                                                                                                                                                                            │  
  │ Prompt: Automatically append version information to the version string                                                                                                                                     │  
  │   Location:                                                                                                                                                                                                │  
  │ (2) -> General setup                                                                                                                                                                                       │  
  │   Defined at init/Kconfig:91                                                                                                                                                                               │  
  │   Depends on: !COMPILE_TEST [=n]                                                                                                                                                                           │  
  │                                                           

关掉LOCALVERSION_AUTO并留空LOCALVERSION,发现git版本确实是不见了,但是‘+’还是存在。

第二步:去掉“+”号

scripts/setlocalversion文件中,找到以下语句:

# CONFIG_LOCALVERSION and LOCALVERSION (if set)
res="${res}${CONFIG_LOCALVERSION}${LOCALVERSION}"

# scm version string if not at a tagged commit
if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
  # full scm version string
  res="$res$(scm_version)"
else
  # append a plus sign if the repository is not in a clean
  # annotated or signed tagged state (as git describe only
  # looks at signed or annotated tags - git tag -a/-s) and
  # LOCALVERSION= is not specified
  if test "${LOCALVERSION+set}" != "set"; then
    scm=$(scm_version --short)
   # res="$res${scm:++}"	//××××××××××××××注释掉这句话××××××××××××
  fi
fi

下面是注释前后的对比

注释前
在这里插入图片描述

问题解决。

Note:在网上还看到两种方法,写在下面:第一种:menuconfig 的时候不要勾选,直接搜MODVERSIONS

注意不要选图中那行

第二种:modprobe –force-vermagic helloworld.ko

这个大家可以自行尝试一下

【摄像头】MT7628wifi摄像头使用说明

一、简介

wifi摄像头采用Linux系统,使用更灵活,功能更强大,采用ov5693传感器500万像素,高清自动聚焦。

二、接口定义

1、电源管脚

管脚1:DC5V 正极

管脚2:DC5V 正极

管脚3:GND 负极

2、串口管脚

管脚4:uart-rx

管脚5:uart-tx

管脚6:GND

3、网口管脚

管脚7:rx0-p

管脚8:rx0-n

管脚9:tx0-p

管脚10:tx0-n

三、应用软件

1、打开极光摄像头APP

2、点击“连接设备”

3、连接“RecologyPower”摄像头热点,返回主界面

4、点击镜头按键,观看视频

【lx2160】How to dynamically adjust MC log level using restool

Prerequisites: The board should be running Linux and connected to terminal console.

Note: For log level debug support, the restool version should be LSDK-2003-RC1 or above and MC version should be 10.20.0 or above.

To check restool version:

$ root@localhost:~# restool -v
restool LSDK-20.04

To check MC version:

root@localhost:~# restool -m
MC firmware version: 10.24.0

For debugging, use the ls-debug script available in the LSDK rootfs. There is no need to create the debug object.

ls-debug -h 
-h, –helpls-debug help information
-ts, –timestamp=XEnable/Disable timestamp printing, X is ON or OFF
-c, –console=XEnable/Disable printing in UART console, X is ON or OFF
-l, –log=XEnable/Disable printing in DDR log, X is ON or OF
-u, –uart=XSet UART ID of the console, X = [0 – 4], 0 = OFF
-ll, –level=XSet logging level, X = [0 – 5]0: Global1: Debug2: Info3: Warning4: Error5: Critical
-m, mem, –memoryDump information about memory modules available
dpxy.zDump information about MC respective object

For example, to enable logging in console with log level INFO:

$ ls-debug --log=on --console=on --level=2              
dpdbg.0 created
DDR log printing ON
UART console printing ON
Log level set to 2
$ root@localhost:~# ls-debug --memory
Memory dumped information available in MC log/console
$ root@localhost:~# cat `find /dev/ -name "*mc_console"`
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_get_obj for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dpdbg_open on DPDBG
[I, RESMAN]  Handling command: dpdbg_dump on DPDBG
[I, DPNI]  Memory info:
[I, DPNI]  MC DDR #1 cacheable memory
[I, DPNI]        Total: 134217728 bytes
[I, DPNI]        Used: 14802708 bytes
[I, DPNI]        Free: 119415020 bytes
[I, DPNI]  MC DDR #1 non-cacheable memory
[I, DPNI]        Total: 50331648 bytes
[I, DPNI]        Used: 27680 bytes
[I, DPNI]        Free: 50303968 bytes
[I, DPNI]  DMEM1 memory
[I, DPNI]        Total: 81920 bytes
[I, DPNI]        Used: 27168 bytes
[I, DPNI]        Free: 54752 bytes
[I, DPNI]  DMEM2 memory
[I, DPNI]        Total: 81920 bytes
[I, DPNI]        Used: 27168 bytes
[I, DPNI]        Free: 54752 bytes
[I, DPNI]  DDR #1 memory
[I, DPNI]        Total: 1610612736 bytes
[I, DPNI]        Used: 143163392 bytes
[I, DPNI]        Free: 1467449344 bytes
[I, DPNI]  PEB memory
[I, DPNI]        Total: 2097152 bytes
[I, DPNI]        Used: 524288 bytes
[I, DPNI]        Free: 1572864 bytes
[I, DPNI]  DP-DDR memory
[I, DPNI]        Total: 4294967296 bytes
[I, DPNI]        Used: 0 bytes
[I, DPNI]        Free: 4294967296 bytes
[I, RESMAN]  Handling command: dpdbg_close on DPDBG
[I, RESMAN]  Handling command: dprc_close for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_set_irq_mask for DPRC 1 on portal id 0
[I, RESMAN]  Handling command: dprc_set_irq_enable for DPRC 1 on portal id 0
root@localhost:~#

【Linux】Linux获取CPU处理器温度

1、通过读取系统文件节点获取相应CPU温度

cpu0:
cat /sys/class/thermal/thermal_zone0/temp
 
cpu1:
cat /sys/class/thermal/thermal_zone1/temp

2、读取cpu温度失败问题

RK3288使用TSADC(Temperature-Sensor ADC)来测量CPU温度,支持两种模式:
用户自定义模式: 主动控制读取温度.
自动模式: 自动检测温度,达到阀值就自动报告.

dts配置如下:

&tsadc {
rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */
rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */
status = "okay";
};

tsadc: tsadc@ff280000 {
compatible = "rockchip,rk3288-tsadc";
reg = <0x0 0xff280000 0x0 0x100>;
interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cru SCLK_TSADC>, <&cru PCLK_TSADC>;
clock-names = "tsadc", "apb_pclk";
assigned-clocks = <&cru SCLK_TSADC>;
assigned-clock-rates = <5000>;
resets = <&cru SRST_TSADC>;
reset-names = "tsadc-apb";
pinctrl-names = "init", "default", "sleep";
pinctrl-0 = <&otp_gpio>;
pinctrl-1 = <&otp_out>;
pinctrl-2 = <&otp_gpio>;
#thermal-sensor-cells = <1>;
rockchip,hw-tshut-temp = <95000>;
status = "disabled";
};

用指令读取CPU温度:cat sys/class/thermal/thermal_zone0/temp,会报错/system/bin/sh: cat: temp: Invalid argumen。

看开机log,发现有如下报错:

clk: couldn’t get clock 0 for /tsadc@ff280000

说明tsadc缺少clock,查看dts,确实是少了这块。

xin32k: xin32k {
    compatible = "fixed-clock";
    clock-frequency = <32768>;
    clock-output-names = "xin32k";
    #clock-cells = <0>;
};

以为这个时钟加上就好了,令人抓狂的是,就加了这么几行代码,机器竟然一直重启开不起机了。

加的这个地方是跟温度是相关的,那就从这个方面入手去思考找问题。会不会是检测到温度的过温阀值,导致重启的呢?

看硬件的连接上:

主控的OTP 引脚是有连接出来到pmic rk808的,如果这个阀值到了reset脚就会动作,然后重启。

由于没有硬性需求一定要这个温度到了阀值就重启的需求,这个时候可以把硬件上的连接电阻去掉,或者软件上把reset的io屏蔽掉。实际起作用的是:pinctrl-1 = <&otp_out>;
屏蔽掉,这时候机器就可以正常开机了。

再查看温度值:cat sys/class/thermal/thermal_zone0/temp
54111

就能正常读到温度值了。

不过不太能理解的是,配置里 rockchip,hw-tshut-temp = <95000>;是超过95度才重启,一开机应该也不会超过阀值才对,开机后读取的温度也就50°C。

【晶晨】romboot打印初步解析 amlogic开机错误分析

romboot打印初步解析
本解析说明适用于: gxb/gxl/txl/axg/txhd/gxlx/gxlx2/txlx/g12A/G12B/SM1/TM2/A1/C1/C2/SC2/T5/T5D/T7/S4

romboot中默认将其打印从AO uart这一路输出

以gxb nand 平台为例,其romboot的打印如下:

GXBB:BL1:08dafd:0a8993;FEAT:E0FC3184;POC:3;RCY:0;EMMC:800;NAND:85;SD:0;READ:0;CHK:0;

其可以拆分为如下部分:
1. GXBB:主芯片内部代号

2. BL1:08dafd:0a8993;FEAT:E0FC3184; bootrom相关启动信息,安全相关的同事会用到。

3. POC:3; Power on Config信息。表明设备启动顺序,可以参考下面的表格:

POC 1st Boot device 2nd Boot device 3rd Boot device 4th Boot device
0   USB SPI NAND/eMMC   SD Card
1   SPI NAND/eMMC   SD Card USB
2   USB NAND/eMMC   SD Card  -
3   NAND/eMMC   SD Card  USB     -

4. RCY:0; HDMI recovery接口读到的值,可以实现更改第一启动介质的目的,通常用于拯救烧错主存储介质的板子,在开发阶段尤为有用;

        0为无hdmi recovery小板;

        1为usb boot的hdmi recovery小板;

        2为sdcard boot的hdmi recovery小板;

5. EMMC:800;NAND:85;SD:0;READ:0;CHK:0

这个是默认的主存储介质的启动顺序,依序为EMMC->NAND->SD->USB,这里因为有烧好的启动卡插入,所以直接在sdcard这里跳了出来;

EMMC:800, 为emmc初始化过程,800表示报错,数值具体对应到emmc控制器的SD_EMMC_STATUS寄存器,此处800表示为resoponse timeout,这个报错信息无法看出是init过程中哪一条命令报错,最为有效的debug方式为接PA进行分析;

 
如果平台有焊接emmc,在初始化过程报了非0值,可以参照如下表格来确认是那条线的焊接不良;
Field
Name
Description
7:0
Rxd_err
RX data CRC error per wire,
for multiple block read, the CRC errors are Ored together.
8
Txd_err
TX data CRC error,
For multiple block write, any one of blocks CRC error.
9
Desc_err
SD/eMMC controller doesn’t own descriptor.
The owner bit is “0”, set cfg_ignore_owner to ignore this error.
10
Resp_err
Response CRC error
11
Resp_timeout
No response received before time limit.
The timeout limit is set by cfg_resp_timeout.
12
Desc_timeout
Descriptor execution time over time limit.
The timeout limit is set by descriptor itself.
Consider the multiple block read/write, set the proper timeout limits.
 
在焊接了emmc的情况下,EMMC初始化打印不为0,通常是hw相关的问题,需要顺序检查以下几个项目:
1. vcc/vccq的供电及上电顺序,二者上电间隔太长可能会引起emmc的初始化失败,详情可以咨询hw的fengjie(jie.feng@amlogic.com)
2. 如果是EMMC初始化报Resp_timeout/Resp_err,需请hw同事检查emmc的cmd线的连通性
3. 如果是EMMC初始化报Rxd_err/txd_err,需请hw同事检查对应的报错data线的连通性
**

Add @ 20180209

在G12A上,SD card的romboot初始化会首先检查GPIOC6的电平状态,如果为card未插入,则romboot会打印SD:20000 

**

NAND:85,为nand初始化过程报错,数值为错误码,常用错误码有

#define ERROR_NAND_TIMEOUT           0x81

#define ERROR_NAND_ECC                  0x82
#define ERROR_NAND_MAGIC_WORD   0x83
#define ERROR_NAND_INIT_READ        0x84
#define ERROR_NAND_BLANK_PAGE     0x85
 
SD:0;READ:0;CHK:0,为SD卡初始化OK,读取OK,并且校验OK;对于其他存储介质,在初始化OK后,同样会进行READ和CHK动作,返回值为0,则为OK,非0值,则有其各自对应的错误码,这里不做详细描述

【LX2160】增加SGMII新网口支持

一、Uboot支持网卡

1、修改设备树

vim components/firmware/uboot/arch/arm/dts/fsl-lx2160a-rdb.dts

&dpmac11 {
        status = "okay";
        phy-handle = <&sgmii_phy1>;
        phy-connection-type = "sgmii";
};

sgmii_phy1: ethernet-phy@3 {
                // RTL8211F PHY
                compatible = "ethernet-phy-id001c.c916", "ethernet-phy-id004d.d072";
                reg = <0x3>;
        };

2、修改驱动

vim components/firmware/uboot/board/freescale/lx2160a/eth_lx2160ardb.c

/*Begin:add by zhaobaoxing for sgmii*/
        srds_s2 = in_le32(&gur->rcwsr[28]) &
                  FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_MASK;
        srds_s2 >>= FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
        /*End:add by zhaobaoxing for sgmii*/

/*Begin:add by zhaobaoxing for sgmii*/
        if (get_board_rev() == 'C') {
                setup_eth_rev_c(srds_s2);
                goto next;
        }
        /*End:add by zhaobaoxing for sgmii*/

/*Begin:add by zhaobaoxing for sgmii*/
        switch (srds_s2){
        case 10:
                wriop_set_phy_address(WRIOP1_DPMAC11, 0,
                                      SGMII_PHY_ADDR1);
                printf("warning: zhaobaoxing for serdes2\r\n");
                break;
        default:
                printf("SerDes2 protocol 0x%x is not supported on LX2160ARDB\n",
                               srds_s2);
                //goto next;
                break;
        }
        /*End:add by zhaobaoxing for sgmii*/

3、修改功能宏定义

vim components/firmware/uboot/configs/lx2160ardb_tfa_defconfig

#CONFIG_DM_ETH=y

二、Linux支持网卡

1、修改设备树

&dpmac11 {
          phy-handle = <&sgmii_phy1>;
          phy-connection-type = "sgmii";
};

sgmii_phy1: ethernet-phy@3 {
     // RTL8211F PHY
     compatible = "ethernet-phy-id001c.c916", "ethernet-phy-id004d.d072";
     reg = <0x3>;
};

三、板卡配置

1、修改rcw文件

vim components/firmware/rcw/lx2160ardb_rev2/XGGFF_PP_HHHH_RR_19_5_2/rcw_2200_750_3200_19_5_2.rcw

SRDS_PRTCL_S1=3 #10G 8  #25G 17 CPRI-10G=3
SRDS_PRTCL_S2=10 #10 #CPRI 5 #-5GC #3#-BBU #5
SRDS_PRTCL_S3=3 #2

2、修改DPC文件

vim components/firmware/mc_utils/config/lx2160a/LX2160A-RDB/dpc-usxgmii.dts

 ports {
                        mac@3 {
                                /*Begin:changed by zhaobaoxing for 10G sfp+*/
                                /*link_type = "MAC_LINK_TYPE_PHY";
                                enet_if = "USXGMII";
                                */
                                /*End:changed by zhaobaoxing for 10G sfp+*/
                                link_type = "MAC_LINK_TYPE_FIXED";
                                enet_if = "XFI";
                        };

                        mac@4 {
                                /*Begin:changed by zhaobaoxing for 10G sfp+*/
                                /*link_type = "MAC_LINK_TYPE_PHY";
                                enet_if = "USXGMII";
                                */
                                /*End:changed by zhaobaoxing for 10G sfp+*/
                                link_type = "MAC_LINK_TYPE_FIXED";
                                enet_if = "XFI";
                        };

                        mac@11 {
                                link_type = "MAC_LINK_TYPE_PHY";
                        };

                        mac@17 {
                                link_type = "MAC_LINK_TYPE_PHY";
                        };
                        mac@18 {
                                link_type = "MAC_LINK_TYPE_PHY";
                        };
                };

3、修改dpl文件

vim components/firmware/mc_utils/config/lx2160a/LX2160A-RDB/dpl-eth.19.dts

connections {

                connection@1{
                        endpoint1 = "dpni@0";
                        endpoint2 = "dpmac@3";
                };

                connection@2{
                        endpoint1 = "dpni@1";
                        endpoint2 = "dpmac@4";
                };

                connection@3{
                        endpoint1 = "dpni@2";
                        endpoint2 = "dpmac@5";
                };

                connection@4{
                        endpoint1 = "dpni@3";
                        endpoint2 = "dpmac@6";
                };

                connection@5{
                        endpoint1 = "dpni@4";
                        endpoint2 = "dpmac@7";
                };

                connection@6{
                        endpoint1 = "dpni@5";
                        endpoint2 = "dpmac@8";
                };

                connection@7{
                        endpoint1 = "dpni@6";
                        endpoint2 = "dpmac@9";
                };

                connection@8{
                        endpoint1 = "dpni@7";
                        endpoint2 = "dpmac@10";
                };

                connection@9{
                        endpoint1 = "dpni@8";
                        endpoint2 = "dpmac@11";
                };

                connection@10{
                        endpoint1 = "dpni@9";
                        endpoint2 = "dpmac@12";
                };

                connection@11{
                        endpoint1 = "dpni@10";
                        endpoint2 = "dpmac@17";
                };

                connection@12{
                        endpoint1 = "dpni@11";
                        endpoint2 = "dpmac@18";
                };
        };

【RK3568】gmac增加SGMII支持

一、SGMII+PHY

1、修改设备树

  • combophy

其中属性 rockchip,sgmii-mac-sel 表示使用的是哪个 gmac:

&combphy1_usq {
     + rockchip,sgmii-mac-sel = <0>; /* Use gmac0 for sgmii */
     status = "okay";
};
  • xpcs
&xpcs {
     status = "okay";
};
  • gmac0
&gmac0 {
     phy-mode = "sgmii";
     rockchip,pipegrf = <&pipegrf>;
     rockchip,xpcs = <&xpcs>;
     snps,reset-gpio = <&gpio2 RK_PC2 GPIO_ACTIVE_LOW>;
     snps,reset-active-low;
     snps,reset-delays-us = <0 20000 100000>;
     assigned-clocks = <&cru SCLK_GMAC0_RX_TX>;
     assigned-clock-parents = <&gmac0_xpcsclk>;
     pinctrl-names = "default";
     pinctrl-0 = <&gmac0_miim>;
     power-domains = <&power RK3568_PD_PIPE>;
     phys = <&combphy1_usq PHY_TYPE_SGMII>;
     phy-handle = <&sgmii_phy>;
     status = "okay";
};
&mdio0 {
     sgmii_phy: phy@1 {
     compatible = "ethernet-phy-ieee802.3-c22";
     reg = <0x1>;
     };
};
  • gmac1
&gmac1 {
     phy-mode = "sgmii";
     rockchip,pipegrf = <&pipegrf>;
     rockchip,xpcs = <&xpcs>;
     snps,reset-gpio = <&gpio2 RK_PC2 GPIO_ACTIVE_LOW>;
     snps,reset-active-low;
     snps,reset-delays-us = <0 20000 100000>;
     assigned-clocks = <&cru SCLK_GMAC1_RX_TX>;
     assigned-clock-parents = <&gmac1_xpcsclk>;
     pinctrl-names = "default";
     pinctrl-0 = <&gmac1_miim>;
     power-domains = <&power RK3568_PD_PIPE>;
     phys = <&combphy1_usq PHY_TYPE_SGMII>;
     phy-handle = <&sgmii_phy>;
     status = "okay";
};
&mdio1 {
    sgmii_phy: phy@1 {
        compatible = "ethernet-phy-ieee802.3-c22";
        reg = <0x1>;
    };
};

2、openwrt系统

驱动补丁:

3、其它系统

无操作

二、SGMII+非PHY

1、修改设备树

&gmac1 {
        phy-mode = "sgmii";

        rockchip,pipegrf = <&pipegrf>;
        rockchip,xpcs = <&xpcs>;

        assigned-clocks = <&cru SCLK_GMAC1_RX_TX>;
        assigned-clock-parents = <&gmac1_xpcsclk>;

        power-domains = <&power RK3568_PD_PIPE>;
        phys = <&combphy2 PHY_TYPE_SGMII>;

        status = "okay";

        fixed-link {
                speed = <1000>;
                full-duplex;
        };
};

2、驱动补丁

三、回环测试

1000baseX 走强制模式,PCS会自己link up,而SGMII 需要协商link, 这种情况一般是switch端没有固定好1000baseX模式的,之前rtl8310 switch端也是更新了很多次固件
我建议可以主控端先做一下回环,飞线要尽量短,
//driver 包产生
CONFIG_NET_PKTGEN=y
cd /proc/net/pktgen/
echo “add_device eth0” > /proc/net/pktgen/kpktgend_0
echo “pkt_size 1440” > /proc/net/pktgen/eth0
echo “count 99999999” > /proc/net/pktgen/eth0
echo “dst_mac FF:FF:FF:FF:FF:FF” > /proc/net/pktgen/eth0
echo “start” > /proc/net/pktgen/pgctrl
通过这种方式产生包,ifconfig 查看统计,确认能收到包。

【lx2160】外围驱动修改

一、DDR调试


1、备份ddr_init.c platform.mk文件
2、修改ddir_init.c udimm参数,由codewarrior生成
3、在platform.mk增加CONFIG_DDR_NODIMM := 1

二、外设调试


1、IIC3调试
修改文件:rcw_2200_750_3200_19_5_2.rcw
修改内容:IIC3_PMUX=2改为0
2、增加OLED驱动
修改文件:fsl-lx2160a-rdb.dts
修改内容:增加
&i2c2 {
clock-frequency = <400000>;
pinctrl-names = “default”;
status = “okay”;
ssd1306: oled@3c {
compatible = “solomon,ssd1306fb-i2c”;
reg = <0x3c>;
//pwms = <&pwm 4 3000>;
//reset-gpios = <&gpio2 7>;
solomon,width = <128>;
solomon,height = <64>;
solomon,page-offset = <0>;
//solomon,com-lrremap;
solomon,com-invdir;
//solomon,com-offset = <0>;
//solomon,lookup-table = /bits/ 8 <0x3f 0x3f 0x3f 0x3f>;
};
};

3、增加5386驱动
注意事项:5386寄存器存在页的概念,需要先选择页,在读写寄存器值,
手册写着寄存器16位,其中前8位是页号,后8位是寄存器地址,数据手册存在误导。
修改文件:fsl-lx2160a-rdb.dts
修改内容:增加
si5386a: sync-clk@68 {
compatible = “newu,si5386a”;
reg = <0x68>;

    };

三、PCI调试


1、pic802
原理图电容型号搞错

四、以太网
1、10G光口调试
restool dpmac info dpmac.6
修改文件:dpc-usxgmii.dts
修改内容:改变
mac@3 {
/Begin:changed by zhaobaoxing for 10G sfp+/
/*link_type = “MAC_LINK_TYPE_PHY”;
enet_if = “USXGMII”;
*/
/End:changed by zhaobaoxing for 10G sfp+/
link_type = “MAC_LINK_TYPE_FIXED”;
enet_if = “XFI”;
};

2、千兆网卡调试
修改文件:fsl-lx2160a-rdb.dts
修改内容:增加
rgmii_phy1: ethernet-phy@1 {
/* AR8035 PHY */
compatible = “ethernet-phy-id001c.c916”, “ethernet-phy-id004d.d072”;
reg = <0x1>;
eee-broken-1000t;
};

五、RTC调试


修改文件:fsl-lx2160a-rdb.dts
修改内容:增加
rtc: rtc@51 {
compatible = “nxp,pcf8563”;
reg = <0x51>;
#clock-cells = <0>;
};