编写应用程序
cd ~/myPC2
$vim hello.c
#include <stdio.h>
int main(void)
{
printf("hello\r\n");
return 0;
}
编译
$aarch64‐linux‐gnu‐gcc ‐o hello hello.c
$file hello
hello: ELF 64‐bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld‐linux‐aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=11750d906493869a59fc04c6b176fcc1b4f5fa1c, with debug_info, not
stripped
$mkdir /disk3
$cd /root/Oriangepi/busybox‐1.30.1
$cp _install/ /disk3/nfs ‐r
安装nfs
$apt install nfs‐common
$vim /etc/exports
原am335x的nfs
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
##Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check)
hostname2(ro,sync,no_subtree_check)
##Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#/o
pt/ti-processor-sdk-linux-am335x-evm-05.02.00.10/targetNFS *
(rw,nohide,insecure,no_subtree_check,async,no_root_squash)
注释掉ti的,改自己的
/disk3/nfs *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)
重启nfs服务
/etc/init.d/nfs‐kernel‐server restart
将编译好的文件移到nfs目录
$mv ~/myPC2/ /disk3/nfs/
查看所有服务进程
service ‐‐status‐all
[ + ] acpid
[ - ] alsa-utils
[ - ] anacron
[ + ] apparmor
[ + ] apport
[ + ] avahi-daemon
[ - ] bluetooth
[ - ] console-setup.sh
[ + ] cron
[ + ] cups
[ + ] cups-browsed
[ + ] dbus
[ - ] dns-clean
[ + ] gdm3
[ + ] grub-common
[ - ] hwclock.sh
[ + ] irqbalance
[ + ] kerneloops
[ - ] keyboard-setup.sh
[ + ] kmod
[ - ] lvm2
[ + ] lvm2-lvmetad
[ + ] lvm2-lvmpolld
[ + ] mysql
[ + ] network-manager
[ + ] networking
[ - ] nfs-common
[ + ] nfs-kernel-server
[ - ] plymouth
[ - ] plymouth-log
[ - ] pppd-dns
[ + ] procps
[ + ] rpcbind
[ - ] rsync
[ + ] rsyslog
[ - ] saned
[ - ] screen-cleanup
[ + ] speech-dispatcher
[ - ] spice-vdagent
[ + ] udev
[ + ] ufw
[ + ] unattended-upgrades
[ - ] uuidd
[ + ] whoopsie
[ - ] x11-common
[ + ] xinetd
先将虚拟机网络设置为桥接模式,方法自己百度,
下面为开发板操作
$ifconfig eth0 upd
#IP根据自身情况设定
$ifconfig eth0 192.168.0.135
#下面命令2选一,避免网络不通
$oute add ‐net 255.255.255.255 netmask 255.255.255.255 dev eth0 metric 1
或
$route add ‐host 255.255.255.255 dev eth0
#开始挂载
$mount 192.168.0.128:/disk3/nfs /mnt ‐o nolock
查看是是否成功
$ls /mnt/
bin linuxrc proc sys var
dev mnt rootfs.tar.gz tmp
etc myPC2 sbin usr
运行文件,因为少库,导致tab不能自动补全及运行程序
^_^/mnt#./hello
-/bin/sh: ./hello: not found
将虚拟机的交叉编译器的库拷至nfs目录,再拷至开发板,注意32位库和64位库都要拷贝过去
#以下命令在虚拟机操作
$cd /root/Oriangepi/OrangePiH5/toolchain/gcc‐linaro‐aarch/aarch64‐linux‐gnu/libc
$cp lib ‐rf /disk3/nfs/
$cp lib64/ ‐rf /disk3/nfs/
以下为开发板操作
$cp /mnt/lib / ‐rf
$rm /lib/*.a ‐f //删除静态库
$cp /mnt/lib64 / ‐rf
$rm /lib64/*.a ‐f //删除静态库
#开始测试
^_^/mnt/myPC2#./hello
hello
开机自动启动网卡及配置IP暂无解决。现是手动输入命令。请注意当前网段IP
重新编译内核,打开DHCP选项
cd ~/Oriangepi/OrangePiH5/kernel
$make menuconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
[*] Networking support --->
Networking support
Networking options --->IP: kernel level autoconfiguration
[*] IP: DHCP support
[*] IP: BOOTP support
[*] IP: RARP support
重新编译内核
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image
返回上层目录(不返回需要修改下面的命令路径)
cd ..
mkimage -A arm -n "OrangePiH5" -O linux -T kernel -C none -a 0x40080000 -e 0x40080000 -d kernel/arch/arm64/boot/Image output/uImage
#因驱动都是直接编译进了内核,所有不需要make modules
将其拷贝到sd卡,当然如果挂载了nfs,可以先拷贝到nfs
#开发板挂载boot分区
$mkdir /boot
$mount /dev/mmcblk0p1 /boot
备份旧uImage
$cp /boot/orangepi/uImage /boot/orangepi/uImage.bak
#从nfs目录拷贝新的uImage进去/boot分区
此处可以先参考其它博文的,http://www.cnblogs.com/lidabo/p/5065187.html
上文链接有些旧了,好像保持上次我编译的busybox配置就可以了,只从busybox的examples/udhcp/下copy simple.script文件到开发板/usr/share/udhcpc/下,并重命名为default.script
并修改/etc/init.d/rcS文件在适当位置添加命令:
ifconfig eth0 up
/sbin/udhcpc &
如果改用ifup eth0 需要增加/etc/network/interfaces配置文件,具体未测试