记忆一隅

荔枝派Zero笔记(二)uboot编译

荔枝派Zero笔记(二)uboot编译
2021-04-28 · 3 min read
荔枝派 笔记

LicheePi Zero Notes -2 uboot compilation

初始配置

cd u-boot
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 
LicheePi_Zero_defconfig #载入模板配置文件

添加网口支持

  • 首先运行make menuconfig,在图形配置中根据以下目录选择Allwinner Sun8i Ethernet MAC support
Device Drivers —>
    Network device support —>
        Allwinner Sun8i Ethernet MAC support
  • 修改dts文件
    在目录u-boot/arch/dts目录下找到sun8i-v3s-licheepi-zero.dts,在aliases下添加ethernet0 = &emac;
    aliases {
 +             ethernet0 = &emac;
                serial0 = &uart0;
    };

在文件末尾添加:

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

在目录u-boot/arch/dts目录下找到sun8i-v3s.dtsi
首先在soc子节点内添加以下内容

syscon: syscon@01c00000 {
       	compatible = "allwinner,sun8i-h3-syscon","syscon"                     
		reg = <0x01c00000 0x34>;
};

soc子节点下的pio: pinctrl@01c20800节点下添加

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>;
};

最后在soc子节点内添加以下内容

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";
};

编译

make ARCH=arm menuconfig  #uboot配置命令
time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 2>&1 #编译

编译完成后,在当前目录下生成了u-boot-sunxi-with-spl.bin,可以烧录到8K偏移处启动

若编译报错./tools/binman/binman: not found,说明编译环境缺少python工具链、

sudo apt get install python