armv7l linux 开发环境

随笔2个月前发布 豆豆爱妮宝
28 0 0

1:远程登录armv7l

armv7l 型号:MC813-GK
操作步骤:

本地PC 手动配置IP 10.10.80.10
网线连接PC与armv7l 的 ETH1口
PC terminal: telnet 10.10.80.15 (用户名:root, 没有密码)

#修改ETH0 口配置,分配内网静态IP。
root@GW-JD-JB-201:~# cat /etc/network/interfaces 
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
 
# The loopback interface
auto lo
iface lo inet loopback

# Wireless interfaces
iface wlan0 inet dhcp
        wireless_mode managed
        wireless_essid any
        wpa-driver wext
        wpa-conf /etc/wpa_supplicant.conf

iface tiwlan0 inet dhcp
        wireless_mode managed
        wireless_essid any

iface atml0 inet dhcp

# Wired or wireless interfaces
auto eth0                                
#iface eth0 inet dhcp                    
#        pre-up /bin/grep -v -e "ip=[0-9]+.[0-9]+.[0-9]+.[0-9]+" /proc/cm
iface eth0 inet static                                                          
address 192.168.66.201                                                            
gateway 192.168.66.1                                                             
netmask 255.255.255.0                                                           
                                                                                
auto eth1                                                                       
#iface eth1 inet dhcp                                                           
iface eth1 inet static                                                          
address 10.10.80.15                                                             
gateway 10.10.80.1                                                              
netmask 255.0.0.0   

# Ethernet/RNDIS gadget (g_ether)
# ... or on host side, usbnet and random hwaddr
iface usb0 inet dhcp

# Bluetooth networking
iface bnep0 inet dhcp

2:本地 ubuntu 开发环境(交叉编译)
main.cpp

#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.14)
project(untitled)
set(CMAKE_CXX_STANDARD 11)

add_executable(untitled main.cpp)

arm_linux_setup.cmake

set(CMAKE_SYSTEM_NAME Linux)    #目标系统名,这里是Linux
set(CMAKE_SYSTEM_PROCESSOR arm) #目标系统的处理器名,这里是arm

# wget https://ladd00.triumf.ca/~olchansk/MityARM/TI/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2
set(tools /home/eddy/CLionProjects/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux)   #指定编译器的
set(CMAKE_C_COMPILER ${tools}/bin/arm-linux-gnueabihf-gcc)                                      #C编译器的可执行文件名称
set(CMAKE_CXX_COMPILER ${tools}/bin/arm-linux-gnueabihf-g++)                                    #C++编译器的可执行文件名称

#当出现:error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
#sudo apt-get install lib32z1

build.sh

mkdir -p /home/eddy/CLionProjects/untitled/build              #创建 build 编译目录
cd /home/eddy/CLionProjects/untitled/build

cmake -DCMAKE_TOOLCHAIN_FILE=../arm_linux_setup.cmake ..      #CMAKE_TOOLCHAIN_FILE来指定工具链文件
make -j16                                                     #编译
#upx -5 -o untitled.upx untitled                              #压缩
cp untitled /home/eddy/workspace/tftp_space/                  #将新目标文件替换旧目标文件,通过tftp 方式传送到 arm中。
生成目标文件

3:arm 中运行
root@GW-JD-JB-201:~# cat run.sh

rm -fr untitled                        #删除旧目标文件
tftp -g -r untitled 192.168.66.2       #从192.168.66.2服务器下载
chmod +x untitled                      #赋予可报告权限

./untitled
Hello, World!

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...