V3S-Zero 网络篇章 Linux5.2

板子上的网口可不能白占着空间

进入主题

开启网口需要 修改Uboot Kernel 文件系统 缺一不可
5.2的内核对NET网络已经支持 所以修改较少

以下是基于TF卡试验的(同等也可以修改在Flash版本中)

Uboot

下载主线的Uboot源码

v3s-current
https://github.com/Lichee-Pi/u-boot.git

修改如下
修改include/configs/sun8i.h

/*
 * Include common sunxi configuration where most the settings are
 */
 /*一定要放下面*/
#include 

#define CONFIG_BOOTCOMMAND   "setenv bootm_boot_mode sec; " \
                            "load mmc 0:1 0x41000000 zImage; "  \
                            "load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-dock.dtb; " \
                            "bootz 0x41000000 - 0x41800000;"

#define CONFIG_BOOTARGS      "console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw  vt.global_cursor_default=0"


修改Dts文件

sun8i-v3s.dtsi 修改如下

	soc {
     
		compatible = "simple-bus";
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;
/*添加syscon*/
		syscon: syscon@01c00000 {
     
            compatible = "allwinner,sun8i-h3-syscon","syscon";
            reg = <0x01c00000 0x34>;
        };
		mmc0: mmc@01c0f000 {
     
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c0f000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC0>,
				 <&ccu CLK_MMC0>,
				 <&ccu CLK_MMC0_OUTPUT>,
				 <&ccu CLK_MMC0_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC0>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};
	pio: pinctrl@01c20800 {
     
			compatible = "allwinner,sun8i-v3s-pinctrl";
			reg = <0x01c20800 0x400>;
			interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
			clock-names = "apb", "hosc", "losc";
			gpio-controller;
			#gpio-cells = <3>;
			interrupt-controller;
			#interrupt-cells = <3>;
/*Pin添加RMII的描述*/
			emac_rgmii_pins: emac0@0 {
     
                    allwinner,pins = "PD0", "PD1", "PD2", "PD3",
                                    "PD4", "PD5", "PD7",
                                    "PD8", "PD9", "PD10",
                                    "PD12", "PD13", "PD15",
                                    "PD16", "PD17";
                    allwinner,function = "emac";
                    allwinner,drive = <SUN4I_PINCTRL_40_MA>;
                    allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
            };
			uart0_pins_a: uart0@0 {
     
				pins = "PB8", "PB9";
				function = "uart0";
				bias-pull-up;
			};

		gic: interrupt-controller@01c81000 {
     
			compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic";
			reg = <0x01c81000 0x1000>,
			      <0x01c82000 0x1000>,
			      <0x01c84000 0x2000>,
			      <0x01c86000 0x2000>;
			interrupt-controller;
			#interrupt-cells = <3>;
			interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
		};
		/*添加EMAC描述*/
		emac: ethernet@1c30000 {
     
            compatible = "allwinner,sun8i-h3-emac";
            reg = <0x01c30000 0x104>, <0x01c00030 0x4>;
            reg-names = "emac", "syscon";
            interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
            resets = <&ccu RST_BUS_EMAC>, <&ccu RST_BUS_EPHY>;
            reset-names = "ahb", "ephy";
            clocks = <&ccu CLK_BUS_EMAC>, <&ccu CLK_BUS_EPHY>;
            clock-names = "ahb", "ephy";
            #address-cells = <1>;
            #size-cells = <0>;
            status = "disabled";
        };
	};

sun8i-v3s-licheepi-zero.dts 修改如下

	model = "Lichee Pi Zero";
	compatible = "licheepi,licheepi-zero", "allwinner,sun8i-v3s";

	aliases {
     
		serial0 = &uart0;
		ethernet0 = &emac;
		spi0 = &spi0;
	};

	chosen {
     
		stdout-path = "serial0:115200n8";
	};

添加emac

&emac {
     
    phy = <&phy0>;
    phy-mode = "mii";
    allwinner,use-internal-phy;
    allwinner,leds-active-low;
    status = "okay";
    phy0: ethernet-phy@0 {
     
        reg = <1>;
    };
};

Uboot设备树修改如上即可

进入Uboot的menuconfig
修改
V3S-Zero 网络篇章 Linux5.2_第1张图片

Kernel

修改 设备树文件
sun8i-v3s-licheepi-zero.dts

	aliases {
     
		serial0 = &uart0;
		ethernet0 = &emac;
	};

&emac {
     
       phy-handle = <&int_mii_phy>;
       phy-mode = "mii";
       allwinner,leds-active-low;
       status = "okay";
};

menuconfig 修改
V3S-Zero 网络篇章 Linux5.2_第2张图片

文件系统

文件系统制作(Buildroot) 可以参考
https://blog.csdn.net/weixin_44205779/article/details/107330375

制作好的文件系统 需要修改Net相关描述

/etc/network/interfaces 下
添加

auto eth0
iface eth0 inet static
address 192.168.11.188
netmask 255.255.255.0
gateway 192.168.11.1

对应的PC主机
我用的Windows
需要关闭防火墙 或者改出入站规则
不然ping 不上

改完之后的效果如下:
V3S-Zero 网络篇章 Linux5.2_第3张图片

后面就可以愉快的使用网络了

你可能感兴趣的:(全志,网络,内核,kernel,linux)