TA的每日心情 | 开心 2022-4-12 14:51 |
---|
签到天数: 163 天 连续签到: 1 天 [LV.7]常住居民III
|
目录
安装系统... 2
常用指令... 3
开发板使用tftp传送hello简单例程... 3
编译内核... 5
下载、复制内核... 5
编译linux-at91. 5
编译buildroot. 6
在u-boot下使用tftp烧写文件系统失败... 8
在windows系统下使用SAM-BA烧写文件... 10
开发板使用NFS功能调试hello例程... 12
SAMA5D3 Embedded Study 初阶段2
因为是初学嵌入式,可能有些语句不符合专业术语,请大家勿喷
[url=]安装系统[/url]
在使用ubuntu时编译buildroot总是出现错误,安装的是ubuntu 11.04 64位系统,分配磁盘大小为默认值约20G;根据“阿青1987”博客中提到的kali系统,决定重新安装kali系统,在官网下载32位kali镜像文件kali-linux-1.1.0a-i386.iso,并在电脑上重新格式化硬盘分区,安装时选择磁盘大小为整个分区约60G,防止出现ubuntu在编译sama5d3 linux内核时,提示磁盘空间不足;安装完成后,配置电脑IP地址、更新系统、安装输入法等;
在终端下输入uname –a,查询系统版本号:
root@allen:/var/nfs# uname -a
Linux allen 3.18.0-kali3-686-pae #1 SMP Debian 3.18.6-1~kali2 (2015-03-02) i686 GNU/Linux;
配置电脑网口
root@allen:/etc# ifconfig
eth0 Link encap:Ethernet HWaddr 00:26:9e:6f:64:a2
inet addr:192.168.0.103 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::226:9eff:fe6f:64a2/64 Scopeink
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26853 errors:0 dropped:0 overruns:0 frame:0
TX packets:4849 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2196168 (2.0 MiB) TX bytes:419322 (409.4 KiB)
Interrupt:17
lo Link encapocal Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:66 errors:0 dropped:0 overruns:0 frame:0
TX packets:66 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3928 (3.8 KiB) TX bytes:3928 (3.8 KiB)
root@allen:/etc# gedit /etc/network/interfaces
root@allen:/etc# /etc/init.d/networking restart
[....] Running /etc/init.d/networking restart is deprecated because it may not re-enable[warn interfaces ... (warning).
[ ok ] Reconfiguring network interfaces...done.
root@allen:/etc# /etc/init.d/network-manager restart
[ ok ] Stopping network connection manager: NetworkManager.
[ ok ] Starting network connection manager: NetworkManager.
168.195.6.254为网关IP地址
root@allen:/etc# ping 168.195.6.254
PING 168.195.6.254 (168.195.6.254) 56(84) bytes of data.
64 bytes from 168.195.6.254: icmp_req=1 ttl=128 time=0.320 ms
64 bytes from 168.195.6.254: icmp_req=2 ttl=128 time=0.333 ms
安装网页浏览器flash插件,在flash官网选择linux版本后下载,解压缩后复制插件
tar xzvf install_flash_player_11_linux.i386.tar.gz
cp libflashplayer.so /usr/lib/mozilla/plugins/
安装完输入法后,添加中文输入后正常使用
[url=]常用指令[/url]
Cd .. 跳转到上一目录
cp –r 复制文件夹
tar -jcvf test.tar.bz2 test 打包后以bzip2压缩
tar -zxvf test.tar.gz 打包后gz压缩
tar xvf test.tar.bz2 解压缩tar.bz2文件
tar xzvf test.tar.gz 解压缩tar.gz文件
rm –rf 删除文件或目录,不可恢复
编译文本常用nano,vi,gedit,leafpad;
在nano下ctrl+x为退出,ctrl+o为保存;
在vi下,命令模式,x为删除当前字符,dd可能是删除整行,“:q!”为不保存退出,“:wq”保存退出
在gedit,leafpad下,操作和记事本一样,非常方便
[url=]开发板使用tftp[/url]传送hello简单例程
tftp共享目录在/var/tftpboot
root@allen:~# ls /var/tftpboot/
hello hello.c
交叉编译工具目录/opt/arm-cross/
export PATH=/opt/arm-cross/arm-2009q3/binPATH
不能将交叉编译工具放在桌面,声明后arm-none-linux-gnueabi-gcc -v 查不到版本号
放在/opt/arm-cross后正常
gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67)
重新启动sama5d3 xplained开发板,等待系统加载完成后,输入root密码,进入终端
sama5d3_xplained login: root
更改千兆网口IP配置文件
root@sama5d3_xplained:~# vi /etc/network/interfaces
将“iface eth0 inet dhcp”语句注销,添加静态IP信息
#150524
#iface eth0 inet dhcp
iface eth0 inet static
address 168.195.6.12
netmask 255.255.255.0
gateway 168.195.6.254
#150523c
查看IP信息
root@sama5d3_xplained:~# ifconfig
eth0 Link encap:Ethernet HWaddr 7a:a8:46:56:60:6c
inet addr:168.195.6.12 Bcast:168.195.6.255 Mask:255.255.255.0
inet6 addr: fe80::78a8:46ff:fe56:606c/64 Scopeink
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:398 (398.0 B)
Interrupt:26 Base address:0x8000
lo Link encapocal Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
使用tftp传送文件
root@sama5d3_xplained:~# cd ..
root@sama5d3_xplained:/home# cd ..
root@sama5d3_xplained:/# ls
bin dev home media proc sbin tmp var
boot etc lib mnt run sys usr www
root@sama5d3_xplained:/# mkdir test
root@sama5d3_xplained:/# cd test/
root@sama5d3_xplained:/test# tftp -g -l hello 168.195.6.232
tftp: server error: (1) File not found
root@sama5d3_xplained:/test# tftp -g -l hello 168.195.6.232
tftp: server error: (1) File not found
root@sama5d3_xplained:/test# tftp -g -l hello 168.195.6.232
root@sama5d3_xplained:/test# ls
hello
root@sama5d3_xplained:/test# chmod 777 hello
root@sama5d3_xplained:/test# ./hello
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
root@sama5d3_xplained:/test#
图片1如下:
[url=]编译内核[/url]
[url=]下载、复制内核[/url]
将在ubuntu系统下载的内核文件压缩,复制到kali操作系统硬盘下;使用tar –jcvf将文件压缩为tar.bz2格式,
tar -jcvf at91bootstrap.tar.bz2 at91bootstrap
tar -jcvf u-boot-at91.tar.bz2 u-boot-at91/
tar -jcvf linux-at91.tar.bz2 linux-at91/
tar -jcvf buildroot-at91.tar.bz2 buildroot-at91/
并修改权限,原来测试时,在buildroot-at91目录下,make clean时会提示没有权限
chmod 777 at91bootstrap.tar.bz2 u-boot-at91.tar.bz2 linux-at91.tar.bz2 buildroot-at91.tar.bz2
分别编译上述文件,根据linux4sam网站更新内容,交叉编译工具使用的是arm-none-linux-gnueabi-
创建的sama5d3文件夹下放内核,如图片12所示:
交叉编译工具目录,如图片13所示
[url=]编译linux-at91[/url]
在编译linux-ar91 uImage时出现如下问题:
1.
root@allen:~/sama5d3/buildroot-at91# make sama5d3_xplained_defconfig
/bin/bash: /root/sama5d3/buildroot-at91/output/build/buildroot-config/conf: 无法执行二进制文件
make: *** [sama5d3_xplained_defconfig] 错误 126
因为linux-at91是复制ubuntu下的.tar.bz2文件,可能编译环境不同,在make clean后通过
2.
make ARCH=arm CROSS-COMPILE=arm-none-linux-gnueabi- zImage成功,在uimage时总是提示如下:
UIMAGE arch/arm/boot/uImage
"mkimage" command not found - U-Boot images will not be built
make[1]: *** [arch/arm/boot/uImage] 错误 1
make: *** [uImage] 错误 2
在网上查找资料,解释如下:使用make uImage编译生成的内核能由uboot引导,编译时会用到mkimage工具,出现这种错误是因为编译器无法找到mkimage工具,该工具在uboot/tools目录下,复制文件mkimage后,编译成功
root@allen:~/sama5d3# cp /root/sama5d3/u-boot-at91/tools/mkimage /opt/arm-cross/arm-2009q3/bin
root@allen:~/sama5d3# cd linux-at91/
root@allen:~/sama5d3/linux-at91# make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage
……
UIMAGE arch/arm/boot/uImage
Image Name: Linux-3.10.0+
Created: Thu Jun 4 08:45:45 2015
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3850808 Bytes = 3760.55 kB = 3.67 MB
Load Address: 20008000
Entry Point: 20008000
Image arch/arm/boot/uImage is ready
图片4如下:
所有生成的文件,我都修改了权限,如u-boot-at91下uboot.bin文件
root@allen:~/sama5d3/linux-at91# chmod 777 arch/arm/boot
root@allen:~/sama5d3/linux-at91# ls arch/arm/boot
bootp compressed dts Image install.sh Makefile uImage zImage
[url=]编译buildroot[/url]
编译buildroot,在ATMEL官网和linux4sam网站上提供的binary,都提示不支持nfs功能,在打印信息中有如下内容:
creating NFS state directory: done
NFS daemon support not enabled in kernel
$ make sama5d3_xplained_defconfig
在menuconfig选项中添加nfs支持,
$ make menuconfig
1)添加 gdb server (Toolchain -> Copy gdb server to the Target)
2)去掉Kernel的编译 (Kernel -> Linux Kernel)
3)修改默认编译器(Target packages -> Text editors and viewers -> 去掉vim 选择nano)
4)添加NFS支持(Target packages -> FileSystem and flash utilities -> nfs-utils)
编译过程中,出现如下选项:
Which edition of Qt do you want to use ?
Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.
选择o,开源
This is the Qt for Embedded Linux Open Source Edition.
You are licensed to use this software under the terms of
the Lesser GNU General Public License (LGPL) versions 2.1.
You are also licensed to use this software under the terms of
the GNU General Public License (GPL) versions 3.
Type '3' to view the GNU General Public License version 3.
Type 'L' to view the Lesser GNU General Public License version 2.1.
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.
Do you accept the terms of either license? 选择yes,接受许可
可能选择的选项也不正确,请大家参考
选择之后,创建rootfs.nfs成功,但有些提示
echo " cp fs/ubifs/ubinize.cfg . ; echo "image=/root/sama5d3/buildroot-at91/output/images/rootfs.ubifs" >> ./ubinize.cfg ; /root/sama5d3/buildroot-at91/output/host/usr/sbin/ubinize -o /root/sama5d3/buildroot-at91/output/images/rootfs.ubi -m 0x800 -p 0x20000 -s 2048 ubinize.cfg ; rm ubinize.cfg" >> /root/sama5d3/buildroot-at91/output/build/_fakeroot.fs
chmod a+x /root/sama5d3/buildroot-at91/output/build/_fakeroot.fs
/root/sama5d3/buildroot-at91/output/host/usr/bin/fakeroot -- /root/sama5d3/buildroot-at91/output/build/_fakeroot.fs
rootdir=/root/sama5d3/buildroot-at91/output/target
table='/root/sama5d3/buildroot-at91/output/build/_device_table.txt'
ubinize: volume size was not specified in section "ubifs", assume minimum to fit image "/root/sama5d3/buildroot-at91/output/images/rootfs.ubifs"59805696 bytes (57.0 MiB)
cp support/misc/target-dir-warning.txt /root/sama5d3/buildroot-at91/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
对于提示不太明白,不过总算编译通过,查看生成的根文件
root@allen:~/sama5d3/buildroot-at91# ls output/images/
rootfs.cpio rootfs.jffs2 rootfs.tar rootfs.ubi rootfs.ubifs
[url=]在u-boot[/url]下使用tftp烧写文件系统失败
重启sama5d3 xplained开发板后,敲击空格键进入u-boot环境下,通过tftp指令传送buildroot生成的根文件rootfs.ubi;
查看环境变量
U-Boot> printenv
baudrate=115200
bootargs=console=ttyS0,115200 earlyprintk mtdparts=atmel_nand:256k(bootstrap)ros
bootcmd=nand read 0x21000000 0x180000 0x80000;nand read 0x22000000 0x200000 0x60
bootdelay=3
ethact=gmac0
stderr=serial
stdin=serial
stdout=serial
Environment size: 427/131067 bytes
配置千兆网口IP信息,电脑IP地址为168.195.6.232
U-Boot> set ipaddr 168.195,6,12
U-Boot> set ethaddr 00:08:dc:06:03:01
U-Boot> set serverip 168.195.6.232
U-Boot> saveenv
Saving Environment to NAND...
Erasing redundant NAND...
Erasing at 0x100000 -- 100% complete.
Writing to redundant NAND... done
配置IP信息后,系统重启
U-Boot> reset
resetting ...
RomBOOT
图片3如下
重启后重新查看IP配置
Hit any key to stop autoboot: 0
U-Boot> printenv
baudrate=115200
bootargs=console=ttyS0,115200 earlyprintk mtdparts=atmel_nand:256k(bootstrap)ros
bootcmd=nand read 0x21000000 0x180000 0x80000;nand read 0x22000000 0x200000 0x60
bootdelay=3
ethact=gmac0
ethaddr=00:08:dc:06:03:01
ipaddr=168.195,6,12
serverip=168.195.6.232
stderr=serial
stdin=serial
stdout=serial
Environment size: 502/131067 bytes
PING主机IP地址
U-Boot> ping 168.195.6.232
gmac0: PHY present at 7
gmac0: Starting autonegotiation...
gmac0: Autonegotiation timed out (status=0x7949)
gmac0: link down (status: 0x7949)
macb0: PHY present at 0
macb0: Starting autonegotiation...
macb0: Autonegotiation timed out (status=0x7849)
macb0: link down (status: 0x7849)
ping failed; host 168.195.6.232 is not alive
U-Boot> ping 168.195.6.232
gmac0: PHY present at 7
gmac0:7 is connected to gmac0. Reconnecting to gmac0
gmac0: Starting autonegotiation...
gmac0: Autonegotiation complete
gmac0: link up, 100Mbps full-duplex (lpa: 0x45e1)
Using gmac0 device
host 168.195.6.232 is alive
图片2如下:
传送文件,先将文件写到RAM,再传送到nandflash
U-Boot> tftp 0x82000000 rootfs.ubi
gmac0: PHY present at 7
gmac0:7 is connected to gmac0. Reconnecting to gmac0
gmac0: Starting autonegotiation...
gmac0: Autonegotiation complete
gmac0: link up, 100Mbps full-duplex (lpa: 0x45e1)
Using gmac0 device
TFTP from server 168.195.6.232; our IP address is 168.195.6.12
Filename 'rootfs.ubi'.
Load address: 0x82000000
Loading: T ##
##############################################################
1.2 MiB/s
done
图片17如下:
Bytes transferred = 64487424 (3d80000 hex)
擦除nandflash根文件系统扇区
U-Boot> nand erase 0x800000 0x3d80000
NAND erase: device 0 offset 0x800000, size 0x3d80000
Erasing at 0x4560000 -- 100% complete.
OK
从RAM写入到nandflash时失败,提示信息如下
U-Boot> nand write.i 0x82000000 0x800000 0x3d80000
NAND write: device 0 offset 0x800000, size 0x3d80000
data abort
MAYBE you should read doc/README.arm-unaligned-accesses
pc : [<2fb5c23c>] lr : [<2fb601b0>]
sp : 2bb1bc20 ip : 2fb6013c fp : 82000000
r10: 2bb1bcc0 r9 : 2ffb95f4 r8 : 2bb1bf30
r7 : 000186a0 r6 : 2ffb92c8 r5 : 2ffb9388 r4 : 2ffb95a8
r3 : 00000000 r2 : 00000800 r1 : 82000000 r0 : 2ffb9388
Flags: Nzcv IRQs off FIQs off Mode SVC_32
Resetting CPU ...
resetting ...
RomBOOT
[url=]在windows[/url]系统下使用SAM-BA烧写文件
对于提示信息不太明白,笨人有笨招,就想到用sam-ba重新烧写编译出的binary,
先拔掉开发板上的NAND-CS跳冒,再给开发板上电,然后打开sam-ba软件,选择nandflash
1.sendboot
sama5d3_xplained-nandflashboot-uboot-3.7.2-rc2.bin
2.0x40000
u-boot.bin
3.0x180000
at91-sama5d3_xplained.dtb
4.0x200000
zImage
5.0x800000
rootfs.ubi
详细步骤请参考linux4sam网站内容
关于linux内核uImage好像是zImage的镜像,比zImage多64个字节;我烧写时选择的zImage
烧写完成,出现error信息
烧写完成,重启开发板,按下RESET键后,进入开发板linux系统,打印信息如下:
Welcome to Buildroot
出现如下error信息
buildroot login: UBI error: ubi_open_volume: cannot open device 0, volume 0, error -16
图片14如下:
敲击空格或enter键后进入buildroot
Welcome to Buildroot
buildroot login: root
login[1261]: root login on 'ttyS0'
[root@buildroot ~]#
图片15如下:
输入root密码后,进入开发板系统,查看文件目录、日期、系统版本号
login[1272]: root login on 'ttyS0'
[root@buildroot ~]# cd ..
[root@buildroot /]# cd ..
[root@buildroot /]# ls
bin/ home/ lib32@ mnt/ root/ sys/ var/
dev/ init* linuxrc@ opt/ run@ tmp/
etc/ lib/ media/ proc/ sbin/ usr/
[root@buildroot /]# date
Mon Jan 1 01:11:20 UTC 2007
不能查看日历
[root@buildroot /]# cal 2015
-sh: cal: command not found
[root@buildroot /]# cal
-sh: cal: command not found
[root@buildroot /]# cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 1 (v7l)
BogoMIPS : 262.96
Features : swp half thumb fastmult vfp edsp thumbee vfpv3 vfpv3d16 tls vf
pv4
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc05
CPU revision : 1
Hardware : Atmel SAMA5 (Device Tree)
Revision : 0000
Serial : 0000000000000000
[root@buildroot /]# uname -a
Linux buildroot 3.10.0+ #6 Thu Jun 4 08:30:53 CST 2015 armv7l GNU/Linux
图片16如下:
对于输出的error信息,UBI error: ubi_open_volume: cannot open device 0, volume 0, err
or -16 gluebi,在网上查找资料后,修改linux-at91配置,make menuconfig后,在Device Drivers > Memory Technology Device(MTD)support >Enable UBI Unsorted block images >
选项下,勾掉gluebi,未测试
图片5如下:
[url=]开发板使用NFS[/url]功能调试hello例程
使用tftp,需要把主机tftpboot目录下文件传送到开发板;选用NFS,开发板一侧只要将主机的NFS目录挂载到本地的/mnt下后,在主机编译好程序后将bin文件放在主机的NFS目录下,而相应的开发板一侧就可以在/mnt下得到最新的程序,在开发板上输入“./hello”即可运行例程
1.
主机测试nfs功能,主机IP地址为168.195.6.232
root@allen:/etc# cd ..
root@allen:/# mount -t nfs 168.195.6.232:/var/nfs /mnt/
mount.nfs: mounting 168.195.6.232:/var/nfs failed, reason given by server:
No such file or directory
提示没有nfs目录
root@allen:/# mkdir /var/nfs
root@allen:/# mount -t nfs 168.195.6.232:/var/nfs /mnt/
root@allen:/# touch /var/nfs/tt.c
root@allen:/# ls /mnt
tt.c
2.
主机编译hello.c文件
root@allen:/# cd /var/nfs
编写的hello.c文件直接放在了nfs目录下
root@allen:/var/nfs# ls
hello hello.c tt.c
root@allen:/var/nfs# chmod 777 hello
root@allen:/var/nfs# ls
hello hello.c tt.c
root@allen:/var/nfs# leafpad hello.c
//编写hello.c文件
#include <stdio.h>
int main()
{
int i;
for(i=0;i<10;i++)
{
printf("Hello,sama5d3_xplained! 150523 \n");
}
return 0;
}
通过交叉编译工具编译文件
root@allen:/var/nfs# arm-none-linux-gnueabi-gcc hello.c -o hello –static
图片9如下:
3.
开发板调试hello例程
验证开发板nfs功能,先配置开发板IP
[root@buildroot /]# chmod 777 /etc/network/interfaces
chmod: /etc/network/interfaces: Read-only file system
[root@buildroot /]# sudo chmod 777 /etc/network/interfaces
-sh: sudo: command not found
提示错误,interfaces文件只读,不能修改,就简单配置开发板IP地址
[root@buildroot /]# ifconfig eth0 168.195.6.12
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[root@buildroot /]# macb f0028000.ethernet eth0: link up (100/Full)
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[root@buildroot /]# ifconfig
eth0 Link encap:Ethernet HWaddr 26:B4:E0:51:5D7
inet addr:168.195.6.12 Bcast:168.195.255.255 Mask:255.255.0.0
inet6 addr: fe80::24b4:e0ff:fe51:5dd7/64 Scopeink
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:201 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11606 (11.3 KiB) TX bytes:468 (468.0 B)
Interrupt:26 Base address:0x8000
lo Link encapocal Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
图片6如下:
[root@buildroot /]# ping 168.195.6.232
PING 168.195.6.232 (168.195.6.232): 56 data bytes
64 bytes from 168.195.6.232: seq=0 ttl=64 time=1.201 ms
64 bytes from 168.195.6.232: seq=1 ttl=64 time=0.372 ms
64 bytes from 168.195.6.232: seq=2 ttl=64 time=0.346 ms
64 bytes from 168.195.6.232: seq=3 ttl=64 time=0.350 ms
64 bytes from 168.195.6.232: seq=4 ttl=64 time=0.361 ms
64 bytes from 168.195.6.232: seq=5 ttl=64 time=0.342 ms
64 bytes from 168.195.6.232: seq=6 ttl=64 time=0.356 ms
64 bytes from 168.195.6.232: seq=7 ttl=64 time=0.349 ms
64 bytes from 168.195.6.232: seq=8 ttl=64 time=0.340 ms
64 bytes from 168.195.6.232: seq=9 ttl=64 time=0.346 ms
--- 168.195.6.232 ping statistics ---
10 packets transmitted, 10 packets received, 0% packet loss
挂载主机nfs目录
[root@buildroot /]# mount -t nfs -o nolock 168.195.6.232:/var/nfs
mount: can't find 168.195.6.232:/var/nfs in /etc/fstab
[root@buildroot /]# ls
bin/ home/ lib32@ mnt/ root/ sys/ var/
dev/ init* linuxrc@ opt/ run@ tmp/
etc/ lib/ media/ proc/ sbin/ usr/
上述错误,后面没有添加本地目录/mnt
[root@buildroot /]# mount -t nfs -o nolock 168.195.6.232:/var/nfs /mnt/
[root@buildroot /]# ls
bin/ home/ lib32@ mnt/ root/ sys/ var/
dev/ init* linuxrc@ opt/ run@ tmp/
etc/ lib/ media/ proc/ sbin/ usr/
自动加载服务器nfs目录下文件,查看/mnt目录下文件信息
[root@buildroot /]# ls /mnt/
hello* hello.c tt.c
[root@buildroot /]# ./hello
-sh: ./hello: No such file or directory
上述错误是因为没有进入mnt目录
[root@buildroot /]# cd /mnt
[root@buildroot mnt]# ls
hello* hello.c tt.c
图片7如下:
开发板运行hello例程
[root@buildroot mnt]# ./hello
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
图片8如下:
修改主机hello.c文件内容,验证本机能否自动更新,在hello.c增加输出*********
[root@buildroot mnt]# ls
hello* hello.c tt.c
[root@buildroot mnt]# ./hello
********************************
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
Hello,sama5d3_xplained! 150523
********************************
hello.c文件内容如下:
#include <stdio.h>
int main()
{
int i;
for(i=0;i<32;i++)
{
printf("*");
}
printf("\n");
for(i=0;i<10;i++)
{
printf("Hello,sama5d3_xplained! 150604 \n");
}
for(i=0;i<32;i++)
{
printf("*");
}
printf("\n");
return 0;
}
图片10如下:
Kali桌面截图11如下:
Buildroot编译不通过,困扰了很长的时间,当时想着放弃nfs调试,就用tftp测试例程;在用kali系统学习过程中,遇到问题就通过网上搜索,终于尝试了下nfs功能;感觉在学习嵌入式过程中,一开始不需要学习怎么编译内核,直接编译例程可能上手会快一些,后续学习过程中慢慢接触内核。测试的内核文件binary,如有网友需要请发邮件wspytu@163.com。
学习心得,遇到问题不要退缩,在网上查找资料后问题总会解决
再次感谢爱板网论坛,感谢“阿青1987”提供的帮助!!!
Wspytu
150605 |
|