天天看點

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 <configs/sunxi-common.h>

#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

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

檔案系統

檔案系統制作(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

後面就可以愉快的使用網絡了

繼續閱讀