开发板通过网线与路由器连接,电脑端连接同意路由器WiFi,确保在同一局域网。
1 Ubuntu终端
1.1 安装nfs-kernel-server
sudo apt install nfs-kernel-server
1.2 创建mount文件夹,xxx:用户名,nfs_server:共享文件夹
mkdir /home/xxx/nfs_server
1.3 修改etc文件夹下的exports文件,在etc文件夹进入终端
sudo gedit exports
在exports文件中添加
/home/xxx/nfs_server *(rw,sync,no_subtree_check,no_root_squash)
1.4 重启nfs服务
/etc/init.d/rpcbind restart
/etc/init.d/nfs-kernel-server restart
2 开发板端
2.1 通过xshell连接开发板
2.2 进入开发板后,在/mnt/建立挂载点mount point
mkdir /mnt/nfs
2.3 挂载nfs,网址为Ubuntu服务器网址(Ubuntu终端输入ifconfig查询)
mount -t nfs -o nolock -o tcp 192.168.0.119:/home/xxx/nfs_server /mnt/nfs
3 helloword验证
3.1 Ubuntu:在nfs_server文件夹进入终端创建hello.c
sudo touch hello.c
3.2 Ubuntu:编辑hello.c
sudo gedit hello.c
在hello.c中添加以下代码
#include <stdio.h>
void main(void)
{
printf("HELLO WORLD!");
}
3.3 Ubuntu:在nfs_server文件夹进入终端运行hello.c
aarch64-linux-gnu-gcc hello.c -o helloword
3.4 开发板:进入/mnt/nfs,输入
ls -l
可以看见hellword文件
3.5 开发板:运行hellword文件
./helloword
4 Ubuntu关闭防火墙
停止防火墙服务
sudo systemctl stop ufw.service
禁用防火墙服务
sudo systemctl disable ufw.service
确认防火墙服务已关闭
sudo ufw status