Note:
1. Linux PC 這邊指的是在 Window 筆電上執行 Vmware 中的 Ubuntu
2. NFS dir 指的是在 Linux PC 所開放的 NFS 的目錄
3. 目前環境設定 RPI 與 Linux PC 有連接共同的 router,並且互相可以 ping 對方
[Test environment]
1. Linux PC ubuntu-14.04.5-desktop-i386.iso
2. RPI OS: 2016-11-25-raspbian-jessie-lite
[Test step]
====== Linux PC =====
1. 首先在 ubuntu 透過 echo 指令輸入/etc/export的NFS dir設定,並且 restart NFS service
$ sudo echo "/prefix/rpi *(rw,all_squash,anonuid=1000,anongid=1000,sync)" >> /etc/export $ sudo /etc/init.d/nfs-kernel-server restart
2. 最後在這邊透過 ln 指令,把 /home/gj/git/rpi/tools/prefix 連結至 /prefix/rpi (不用事先mkdir /prefix/rpi)
$ mkidr /home/<your ID>/git/tools/prefix $ sudo ln -sf /home/<your ID>/git/rpi/tools/prefix /prefix/rpi
3.這邊範例 Linux PC 的 IP 是192.168.0.101
$ ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0c:29:aa:47:b3 inet addr:192.168.0.101 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:feaa:47b3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:90 errors:0 dropped:0 overruns:0 frame:0 TX packets:59 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:11673 (11.6 KB) TX bytes:7248 (7.2 KB) Interrupt:19 Base address:0x2000
====== RPI3 =====
1.這邊範例 RPI 的 IP 是192.168.0.102
pi@raspberrypi:~$ ifconfig wlan0 wlan0 Link encap:Ethernet HWaddr b8:27:eb:bc:b5:ae inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::5117:e94:2ada:39df/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8327 errors:0 dropped:7923 overruns:0 frame:0 TX packets:303 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1652921 (1.5 MiB) TX bytes:41780 (40.8 KiB)
2. 透過 mkdir 指令建立臨時的 /tmp/opt,並且對 Linux PC 的 /prefix/rpi 做 mount 動作
pi@raspberrypi:~$ sudo mkdir /tmp/opt pi@raspberrypi:~$ sudo mount -o nolock 192.168.0.101:/prefix/rpi /tmp/opt;
3.透過 touch 指令產生一個 test 檔案
pi@raspberrypi:~$ touch /tmp/opt/test pi@raspberrypi:~$ ls /tmp/opt/test -al -rw-r--r-- 1 pi pi 0 Oct 8 2017 /tmp/opt/test
[Test result]
1.爾後可以在 Linux PC 的 NFS dir 透過 ls 指令查看,果然的確有一個 test 檔案存在,證明有成功讓 Linux PC 與 RPI 共同使用 NFS dir
$ ls /prefix/rpi/ -l total 0 -rw-r--r-- 1 gj gj 0 Oct 8 11:36 test
2. 在Linux PC上,透過RPI Toolchain編譯的hello可以透過cp指令複製hello至/prefix/rpi
編譯hello程式是參考此文章: Ref. [進階] 安裝 Raspberry Pi 的 Toolchain
$ ls /home/gj/git/rpi/tools/hello -l -rwxrwxr-x 1 gj gj 5953 Oct 8 12:41 /home/gj/git/rpi/tools/hello $ cp /home/gj/git/rpi/tools/hello /prefix/rpi
3. 在 RPI 上,透過 file 指令檢查是否為 RPI Toolchain 所編譯出來的,爾後可以執行 ./tmp/opt/hello
pi@raspberrypi:/$ file /tmp/opt/hello /tmp/opt/hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.26, BuildID[sha1]=9aee406ad182c18654ad5b4ea2619bef790387e3, not stripped pi@raspberrypi:/$ ./tmp/opt/hello Hello World!
[Conclusion]
1. 這邊也可以在 RPI上 多加以下 command,可在 PC 上編譯好 lib 至 /prefix/lib 之後,即可以在 RPI 上的 program 即時連結 lib 使用。
pi@raspberrypi:~$ export LD_LIBRARY_PATH=/tmp/opt/lib
2. 若 RPI 不需要 mount NFS dir,可下以下指令取消 mount,以免突發網路斷線讓 NFS service crash。
pi@raspberrypi:~$ umount /tmp/opt
[Keywords]
mount, NFS,
jhanggj 2017/10/08 in Taipei
沒有留言:
張貼留言