rk3288实践:嵌入式Linux开发环境搭建

目录

一、硬件连接:

二、tftp服务器安装

简介:

目的:

安装:

使用:

三、NFS服务安装

安装:

目的:

使用方法:

四、启动时出现问题:


一、硬件连接:

三个设备ip都设置在一个网段192.168.1.x。

虚拟机桥接设置方式:编辑-虚拟网络编辑器。

问题1:uboot使用ping命令测试连接windows不通


可能原因:

没有设置有效ipaddr、ethaddr、clientip、gatewayip、serverip。

解决方法:

查看是否设置ip、mac、clientip地址。没有设置的则需要设置对应的环境变量

设置ip命令:setenv ipaddr 192.168.1.11 开发板ip

设置mac命令:一般不用设置。

设置clientip命令:setenv clientip 192.168.1.11 开发板ip

设置serverip命令:setenv clientip 192.168.1.10 虚拟机ip

二、tftp服务器安装

简介:

        tftp是一种文件传输协议,基于UDP端口69,一般Linux主机作为服务端,嵌入式开发板作为客户端。

目的:

        用来和虚拟机连接传输文件、下载内核文件等

安装:

安装tftp
sudo apt-get install tftp-hpa tftpd-hpa 
创建tftp服务器文件夹,改权限
mkdir -p /home/用户名/tftpboot 
chmod 777 /home/用户名/tftpboot 

编辑配置文件
sudo vim /etc/default/tftpd-hpa 

添加以下内容

TFTP_DIRECTORY="/home/用户名/tftpboot" 
TFTP_OPTIONS="-l -c -s" 

安装完成。

sudo service tftpd-hpa restart 重启tftp服务。

使用:

当tftp客户端 访问时会直接访问设置的文件夹/home/用户名/tftpboot。

示例:uboot命令tftpboot:

在实践中用到的两条命令tftpboot 0x01f00000 rk3288-firefly.dtb; tftpboot 0x02000000 zImage;

把tftp服务器 /tftpboot目录中的内核文件zImage下载到目标板内存的0x02000000地址中, 设备树文件rk3288-firefly.dtb下载到0x01f00000。

三、NFS服务安装

安装:

sudo apt-get install nfs-kernel-server 

sudo vim /etc/exports

/etc/exports 文件中添加以下内容用于指定nfs文件夹。

/home/用户名/nfs_rootfs    *(rw,nohide,insecure,no_subtree_check,async,no_root_squash) 

sudo service nfs-kernel-server restart 启动服务

目的:

开发板直接通过网络挂载 PC 机中的文件夹,一般用于挂载开发板的根文件系统。

使用方法:

uboot通过启动参数设置nfs信息。关于nfs部分,在内核文档里(Documentation/filesystems/nfs/nfsroot.txt)有详细说明

2.) Kernel command line
    -------------------
When the kernel has been loaded by a boot loader (see below) it needs to be told what root fs device to use. And in the case of nfsroot, where to find both the server and the name of the directory on the server to mount as root. This can be established using the following kernel command line parameters:
root=/dev/nfs
  This is necessary to enable the pseudo-NFS-device. Note that it's not a real device but just a synonym to tell the kernel to use NFS instead of a real device.
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
  If the `nfsroot' parameter is NOT given on the command line,
  the default "/tftpboot/%s" will be used.
  <server-ip>	Specifies the IP address of the NFS server.
		The default address is determined by the `ip' parameter
		(see below). This parameter allows the use of different
		servers for IP autoconfiguration and NFS.
  <root-dir>	Name of the directory on the server to mount as root.
		If there is a "%s" token in the string, it will be
		replaced by the ASCII-representation of the client's
		IP address.
  <nfs-options>	Standard NFS options. All options are separated by commas. The following defaults are used: port		= as given by server portmap daemon
			rsize		= 4096
			wsize		= 4096
			timeo		= 7
			retrans		= 3
			acregmin	= 3
			acregmax	= 60
			acdirmin	= 30
			acdirmax	= 60
			flags		= hard, nointr, noposix, cto, ac
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>

示例:

setenv bootargs root=/dev/nfs nfsroot=192.168.1.130:/home/book/nfs_rootfs rw ip=192.168.1.11;

①root=/dev/nfs 固定用法,告诉内核通过nfs启动。

②nfsroot=192.168.1.130:/home/book/nfs_rootfs 指定nfs地址

③rw ip=192.168.1.11;   指定客户端即开发板ip地址

-----------------------------------------------------------------------------------------------------------------

整条启动参数为:
=> setenv ipaddr 192.168.1.11; setenv serverip 192.168.1.130; tftpboot 0x01f00000 rk3288-firefly.dtb; tftpboot 0x02000000 zImage; setenv bootargs root=/dev/nfs nfsroot=192.168.1.130:/home/book/nfs_rootfs rw ip=192.168.1.11; bootz 0x02000000 - 0x01f00000

简述:通过tftp服务复制内核和设备树到内存,挂载nfs根文件系统,启动内核。

启动过程如下

DDR Version 1.06 20171020
In
Channel a: DDR3 400MHz
Bus Width=32 Col=10 Bank=8 Row=15 CS=1 Die Bus-Width=16 Size=1024MB
Channel b: DDR3 400MHz
Bus Width=32 Col=10 Bank=8 Row=15 CS=1 Die Bus-Width=16 Size=1024MB
Memory OK
Memory OK
OUT
Boot1 Release Time: Apr 11 2018 10:32:58, version: 2.36
ChipType = 0x8, 229
mmc2:cmd19,256
SdmmcInit=2 0
BootCapSize=2000
UserCapSize=7456MB
FwPartOffset=2000 , 2000
mmc0:cmd5,32
SdmmcInit=0 0
BootCapSize=0
UserCapSize=15193MB
FwPartOffset=2000 , 0
StorageInit ok = 47454
LOADER Check OK! 0x0, 105551
tag:TOS    error,addr:0x4000
hdr 032c77e4 + 0x0:0x6d903ceb,0x2e73666b,0x00746166,0x00010402,
TOS    Check OK! 0x8400000, 192918
Enter Trust OS
INF [0x0] TEE-CORE:init_primary_helper:377: Initializing (1.1.0-316-g7b4ec90 #59 Wed May 30 08:26:33 UTC 2018 arm)

INF [0x0] TEE-CORE:init_primary_helper:378: Release version: 1.3

INF [0x0] TEE-CORE:init_primary_helper:379: Next entry point address: 0x0

INF [0x0] TEE-CORE:init_teecore:83: teecore inits done


U-Boot 2017.09 (Jul 13 2021 - 05:18:23 -0400)

Model: Firefly-RK3288
DRAM:  2 GiB
Relocation Offset is: 7de63000
MMC:   dwmmc@ff0c0000: 1, dwmmc@ff0f0000: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Model: Firefly-RK3288
switch to partitions #0, OK
mmc1 is current device
do_rkimg_test found IDB in SDcard
Boot from SDcard
get part misc fail -1
Net:
Warning: ethernet@ff290000 (eth0) using random MAC address - b6:9e:5e:84:ac:1b
eth0: ethernet@ff290000
Unknown command 'usb' - try 'help'
Hit any key to stop autoboot:  0
=>
=> setenv ipaddr 192.168.1.11
=> setenv serverip 192.168.1.130; tftpboot 0x01f00000 rk3288-firefly.dtb; tftpboot 0x02000000 zImage; setenv bootargs root=/dev/nfs nfsroot=192.168.1.130:/home/book/nfs_rootfs rw ip=192.168.1.11; bootz 0x02000000 - 0x01f00000
ethernet@ff290000 Waiting for PHY auto negotiation to complete.... done
Speed: 100, full duplex
Using ethernet@ff290000 device
TFTP from server 192.168.1.130; our IP address is 192.168.1.11
Filename 'rk3288-firefly.dtb'.
Load address: 0x1f00000
Loading: ######
         468.8 KiB/s
done
Bytes transferred = 74546 (12332 hex)
Speed: 100, full duplex
Using ethernet@ff290000 device
TFTP from server 192.168.1.130; our IP address is 192.168.1.11
Filename 'zImage'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ##########################
         2.2 MiB/s
done
Bytes transferred = 8009904 (7a38b0 hex)
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 0ffea000, end 0ffff331 ... OK
Adding bank: start=0x00000000, size=0x08400000
Adding bank: start=0x09200000, size=0x76e00000

Starting kernel ...


[    0.000000] Booting Linux on physical CPU 0x500
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu

四、启动时出现问题:

NFS挂载失败:

        提示end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,255)

分析:

        sudo    mount    -t    nfs    127.0.0.1:/home/book/nfs_rootfs        /mnt 挂载自己能成功。

解决:

        重新配置内核,勾选支持nfs,重新编译。参考文章

        

1、配置网络部分,主要是使能CONFIG_IP_PNP以在2中能够看到Root file system on NFS选项

Networking support

       Networking options

              TCP/IP networking

                            [*]IP: kernel level autoconfiguration

                                   [*] IP: DHCP support

                                   [*] IP: BOOTP support

                                  

2、配置开启nfs服务

File systems  --->     

       Network File Systems  --->

              <*> NFS client support

              [*] NFS client support for NFS version 3

 [*] NFS client support for the NFSv3 ACL protocol extension

              [*] NFS client support for NFS version 4 (EXPERIMENTAL)

              [*] NFS client support for NFSv4.1 (DEVELOPER ONLY)

              [*] Root file system on NFS 

更换重新配置的内核后通过nfs启动成功。

--------------------------------------------------------------------------------------------

注:内容参考《Firefly-RK3288开发板高级用户使用手册V1.2》

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值