【海思篇】【Hi3516DV300】五、linux有线网口调试

目的:熟悉uboot下有线网口;让更多的爱好者了解海思、加入海思。

目录

1 配置linux kernel的设备树

1)修改dts上的phyaddr配置

2)打开HIETH_GMAC

2 开启DHCP Client支持

1)打开busybox的udhcpc

2)配置udhcpc的默认脚本

3 测试


1 配置linux kernel的设备树

1)修改dts上的phyaddr配置

(我的是0,hi3516dv300默认是1)

cd Hi3516CV500_SDK_V2.0.1.1/osdrv/opensource/kernel/linux-4.9.y-smp/arch/arm/boot/dts

vi hi3516dv300-demb.dts

&mdio0 {
        hisilicon,phy-reset-delays-us = <10000 20000 150000>;
#if 0
        phy0: ethernet-phy@1 {
                reg = <1>;
        };
#else
        phy0: ethernet-phy@0 {
                reg = <0>;
        };
#endif
};

注意:如果改好了,编译后并不会生效,因为重新make后会从linux压缩包中解压覆盖了上面被修改的配置,所以我的解决办法是将linux-4.9.y-smp/arch/arm/boot/dts目录下自己配置好后的hi3516dv300-demb.dts文件保存到Hi3516CV500_SDK_V2.0.1.1/osdrv/opensource/kernel下,文件名称不变;然后修改osdrv下Makefile,如HIETH_GMAC中的Makefile(不重复贴了)。

2)打开HIETH_GMAC

cd Hi3516CV500_SDK_V2.0.1.1/osdrv/opensource/kernel/linux-4.9.y-smp

make ARCH=arm CROSS_COMPILE=arm-himix200-linux- menuconfig

【海思篇】【Hi3516DV300】五、linux有线网口调试_第1张图片

注意:如果改好了,编译后并不会生效,因为重新make后会从linux压缩包中解压覆盖了上面被修改的配置,所以我的解决办法是将linux-4.9.y-smp目录下自己配置好后的.config文件保存到Hi3516CV500_SDK_V2.0.1.1/osdrv/opensource/kernel下,重命名为hi3516dv300_smp_defconfig;然后修改osdrv下Makefile,如下

##########################################################################################
#task [2]       build kernel
##########################################################################################
hikernel: prepare check_kernel
        @echo "---------task [2] build kernel"
        rm $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER) -rf
        tar xf $(PACKAGE) -C $(OSDRV_DIR)/opensource/kernel/
        mv $(OSDRV_DIR)/opensource/kernel/$(KERNEL_FULL_VER) $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER)
        pushd $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER);patch -p1 < ../$(KERNEL_PATCH);popd
        find $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER) | xargs touch
# add by wei
        cp $(OSDRV_DIR)/opensource/kernel/$(KERNEL_CFG) $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER)/arch/arm/configs/$(KERNEL_CFG)
        cp $(OSDRV_DIR)/opensource/kernel/hi3516dv300-demb.dts $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER)/arch/arm/boot/dts/hi3516dv300-demb.dts
# add by wei end
        make -C $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER) ARCH=arm CROSS_COMPILE=$(OSDRV_CROSS)- $(KERNEL_CFG)

        pushd $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER);\
                make ARCH=arm CROSS_COMPILE=$(OSDRV_CROSS)- uImage -j 20 >/dev/null;popd
        cp $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER)/arch/arm/boot/uImage $(OSDRV_DIR)/pub/$(PUB_IMAGE)/$(UIMAGE)

hikernel_clean:
        rm $(OSDRV_DIR)/opensource/kernel/$(KERNEL_VER) -rf

2 开启DHCP Client支持

1)打开busybox的udhcpc

cd Hi3516CV500_SDK_V2.0.1.1/osdrv/opensource/busybox/busybox-1.26.2

make ARCH=arm CROSS_COMPILE=arm-himix200-linux- menuconfig

【海思篇】【Hi3516DV300】五、linux有线网口调试_第2张图片

注意:如果改好了,编译后并不会生效,因为重新make后会从uboot.tgz压缩包中解压覆盖了上面被修改的配置,所以我的解决办法是将busybox-1.26.2目录下自己配置好后的.config文件保存到Hi3516CV500_SDK_V2.0.1.1/osdrv/opensource/busybox下,重命名为config_v200_a7_softfp_neon;然后修改osdrv下Makefile,如下

##########################################################################################
#task [4]       build busybox
##########################################################################################
hibusybox: prepare
        @echo "---------task [4] build busybox "
        rm $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER) -rf
        tar xzf $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER).tgz -C $(OSDRV_DIR)/opensource/busybox
        find $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER) | xargs touch
        cp $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER)/$(BUSYBOX_CFG) \
                $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER)/.config
#add by wei
        cp $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_CFG) \
                $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER)/.config
#add by wei end
        pushd $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER)/;make -j 20 >/dev/null;popd
        make -C $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER) install
        cp -af $(OSDRV_DIR)/opensource/busybox/$(BUSYBOX_VER)/_install/* $(OSDRV_DIR)/pub/$(PUB_ROOTFS)

2)配置udhcpc的默认脚本

cd Hi3516CV500_SDK_V2.0.1.1/osdrv
vi rootfs_priv/usr/share/udhcpc/default.script

#!/bin/sh

# udhcpc script edited by Tim Riker 

[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1

RESOLV_CONF="/tmp/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"

case "$1" in
	deconfig)
		/sbin/ifconfig $interface 0.0.0.0
		;;

	renew|bound)
		/sbin/ifconfig $interface $ip $BROADCAST $NETMASK

		if [ -n "$router" ] ; then
			echo "deleting routers"
			while route del default gw 0.0.0.0 dev $interface ; do
				:
			done

			for i in $router ; do
				route add default gw $i dev $interface
			done
		fi

		echo -n > $RESOLV_CONF
		[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
		for i in $dns ; do
			echo adding dns $i
			echo nameserver $i >> $RESOLV_CONF
		done
		;;
esac

exit 0

chmod 750 rootfs_priv/usr/share/udhcpc/default.script

3 测试

插上网线接电进入linux系统。ping验证通过。

ifconfig eth0 up
udhcpc -i eth0 -b

ping 8.8.8.8

 

 

 

 

 

 

你可能感兴趣的:(【海思篇】【Hi3516DV300】五、linux有线网口调试)