构建海思arm交叉编译环境

构建海思arm交叉编译环境

    • 使用vmware安装CentOS-7-x86-64
    • 安装Hi3536 SDK
    • 安装tftp-server
    • 修改 嵌入式linux 共享内存大小

使用vmware安装CentOS-7-x86-64

安装完毕后需要删除预安装的open-vm-tools包

yum remove open-vm-tools

然后选“虚拟机”-“重新安装VMware Tools”。
之后把客户机里的光驱里的VMtools压缩包拷到随便一个目录下,解压,运行里面的.pl文件,第一步输入yes,之后全都按回车。最后重启客户机。这样手动以传统方式装VMtools后,复制文件的功能就正常了。

这一步是为了删除原有的vmware tools,重新使用vmware安装vmware tools

如果本身共享文件夹没问题的话可跳过此步骤

安装Hi3536 SDK

这里笔者使用Hi3536的芯片,所以需要安装海思的SDK

tar -zxf Hi3536_SDK_V2.0.7.0.tgz;
cd Hi3536_SDK_V2.0.7.0;
sudo chmod +x ./sdk.unpack;
sudo ./sdk.unpack;
cd ./osdrv/opensource/toolchain/arm-hisiv400-linux;
sudo chmod +x cross.v400.install;
sudo ./cross.v400.install;

安装tftp-server

因为使用的是hi-linux 嵌入式linux,此系统自带tftp客户端和telnet server,没有ssh server 和 ftp、sftp,所以远程登录使用telnet,文件传输使用tftp方式,因此需要在x86的linux或其他主机上安装tftp server

需要安装 xinetd、tftp- server 通过 yum 安装

sudo yum install xinetd
sudo yum install tftp sudo yum install tftp-server

配置etc/xinetd. d/tftp文件

Service tftp{
	t socket type dgram
	protocol
	wait =yes
	user =root
	server =/usr/sbin/in tftpd
	server args =-s /home/ -c // 设置tftp服务目录,-s指定chroot -c代表可以创建文件
	disable =no // 改为no代表启用tftp
	per source=1002
	flags =PV4
}
systemctl start xinetd.service

查看

netstat -a|grep tftp
udp        0      0 0.0.0.0:tftp            0.0.0.0:*    

说明服务已经启动

这时候需要编辑一个测试文件test.c
并使用海思编译器

export /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin
arm-hisiv400-linux-gcc test.c

可能会出现缺少某些库的情况
直接使用yum安装缺少的库名即可

如果编译器成功编译文件,那么就可以将编译生成的可执行文件发送至嵌入式linux中

telnet 嵌入式linux ip

依次输入账户、密码

tftp -g -r /home/nsk/bin/a.out tftp服务器ip

可能会出现的问题:
1、连接超时:
需要关闭tftp服务器主机的防火墙

sudo systemctl stop firewalld.service;
sudo systemctl disable firewalld.service;
sudo systemctl stop rsyslog.service;
sudo systemctl disable rsyslog.service;
sudo systemctl stop irqbalance.service;
sudo systemctl disable irqbalance.service;

2、找不到文件:
因为配置文件是把/home/作为服务目录,所以参数-r后面应该写基于/home/的相对地址,修改为

tftp -g -r /nsk/bin/a.out tftp服务器ip

3、没有权限
这个时候需要给tftp 服务的目录赋予权限

sudo chmod 777 /home -R

4、TFTP error: ‘Permission denied’ (0)

/etc/sysconfig/selinux 修改为:SELINUX=permissive
reboot

修改 嵌入式linux 共享内存大小

因为笔者需要使用到大于32M的共享内存空间,所以需要重新设置共享内存默认大小

sysctl -w kernel.shmmax=134217728
sysctl -w kernel.shmall=2097152

成功后即可将编译后的可执行程序在arm linux上运行

你可能感兴趣的:(笔记)