ubuntu 18.04
1.准备uboot源码和交叉编译工具链
交叉编译工具链网盘地址:http://pan.baidu.com/s/1hsf22fq
tar xvf gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz
sudo mv gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf /opt/
增加路径
下载编译Uboot
git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current
#or git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-spi-experimental
cd u-boot
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_800x480LCD_defconfig
#or make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero480x272LCD_defconfig
#or make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_defconfig
make ARCH=arm menuconfig
time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 2>&1 | tee build.log
发生问题,编译没有通过没有找到LicheePi的配置文件,从网上重新下载uboot
地址 u-boot:https://github.com/Lichee-Pi/u-boot/archive/v3s-current.zip
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LicheePi_Zero_defconfig
添加网卡驱动
选择 Device Drivers —>
选择 Network device support —> 并选中 Allwinner Sun8i Ethernet MAC support
-
修改dts
/arch/arm/dts/sun8i-v3s-licheepi-zero.dts:
根据diff命令在相应位置添加
diff --git a/arch/arm/dts/sun8i-v3s-licheepi-zero.dts b/arch/arm/dts/sun8i-v3s-licheepi-zero.dts
index 3d9168c..b8b9fc3 100644
--- a/arch/arm/dts/sun8i-v3s-licheepi-zero.dts
+++ b/arch/arm/dts/sun8i-v3s-licheepi-zero.dts
@@ -49,6 +49,7 @@
compatible = "licheepi,licheepi-zero", "allwinner,sun8i-v3s";
aliases {
+ ethernet0 = &emac;
serial0 = &uart0;
};
@@ -81,3 +82,14 @@
usb0_id_det-gpio = <&pio 5 6 GPIO_ACTIVE_HIGH>;
status = "okay";
};
+
+&emac {
+ phy = <&phy0>;
+ phy-mode = "mii";
+ allwinner,use-internal-phy;
+ allwinner,leds-active-low;
+ status = "okay";
+ phy0: ethernet-phy@0 {
+ reg = <1>;
+ };
+};
sun8i-v3s.dtsi:
diff --git a/arch/arm/dts/sun8i-v3s.dtsi b/arch/arm/dts/sun8i-v3s.dtsi
index ebefc0f..cb81dd5 100644
--- a/arch/arm/dts/sun8i-v3s.dtsi
+++ b/arch/arm/dts/sun8i-v3s.dtsi
@@ -96,6 +96,11 @@
#size-cells = <1>;
ranges;
+ syscon: syscon@01c00000 {
+ compatible = "allwinner,sun8i-h3-syscon","syscon";
+ reg = <0x01c00000 0x34>;
+ };
+
mmc0: mmc@01c0f000 {
compatible = "allwinner,sun7i-a20-mmc";
reg = <0x01c0f000 0x1000>;
@@ -208,6 +213,17 @@
interrupt-controller;
#interrupt-cells = <3>;
+ 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";
@@ -270,6 +286,20 @@
status = "disabled";
};
+ 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";
+ };
+
gic: interrupt-controller@01c81000 {
compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic";
reg = <0x01c81000 0x1000>,
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make
失败原因... not fount,进入目录其实是有这个工具的.网上查是版本问题要安装python
再次编译ok
二、修改为tf卡启动
1、在解压好的u-boot文件夹下输入以下命令(这个是默认设置):
现修改u-boot的一些配置,让他能够从TF卡启动:
修改u-boot源码文件夹下的 include/configs/sun8i.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"
ARCH=arm make menuconfig
ncurses.h no such file
问题的解决:
在Ubuntu下,“apt-get install libncurses5-dev”安装上ncurses库即可。
没有改动用的是默认设置。
编译完成后,在当前目录下生成了u-boot-sunxi-with-spl.bin,可以烧录到8K偏移处启动。
要读卡器,sd卡,分区,烧录到sd卡.
安装gparted
打开gparted后,先选择sd卡,默认是ubuntu的硬盘
要选取消挂载sd卡,删除sd卡分区后才能新建分区
创建两个分区
(1) 建立第一个分区,大小32M(可以随意填写),,格式FAT16,命名kernal(可自己修改)。
(2)建立第二个分区,用尽剩余空间(默认即可),格式ext4,命名为rootfs。
选Apply
dd命令 后面的of=/dev/sdb 不要写成/dev/sdb1
也不用把sdb1设为boot-flag
退卡.
插卡到开发板,上电
uboot启动成功。
解决uboot
*** Warning - bad CRC, using default environment
参考
加入uboot设置,然后保存ok
setenv bootcmd "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;"
setenv bootargs "console=ttyS0,115200 panic=5 mtdparts=spi32766.0:1M(uboot),64k(dtb),4M(kernel),-(rootfs) rootwait root=/dev/mmcblk0p2 earlyprintk rw vt.global_cursor_default=0"
测试以太网
出现*** ERROR: `ipaddr' not set ,设置一下开发板的ip就可以了.
=> ping 192.168.0.141
*** ERROR: `ipaddr' not set
ping failed; host 192.168.0.141 is not alive
=> setenv ipaddr 192.168.0.2
=> ping 192.168.0.141
Using ethernet@1c30000 device
host 192.168.0.141 is alive