准备工作:
- 安装有 Ubuntu 18.04 的PC主机一台
- 烧录有最新版Debian 嵌入式镜像的 BBB 一台(可以参考官网下载并完成烧录)
- 调试用数据线一根
- 将PC和BBB通过数据线进行物理连接
- 确保PC通过该命令可以访问BBB:ssh -l debian 192.168.6.2 (密码为默认的temppwd,确认访问后需用exit断开连接)
- 准备工作完成
第一步:在 PC 安装交叉调试工具
- 添加外部结构:
sudo dpkg --add-architecture armhf - 验证结构:
sudo dpkg --print-architecture
sudo dpkg --print-foreign-architectures - 升级并更新:
sudo apt-get update
sudo apt-get upgrade - 安装交叉编译器:
sudo apt-get install crossbuild-essential-armhf
第二步:在 PC 尝试执行一个程序
- 在 PC 创建一个简单 c 程序,比如 helloworld.c
- 使用交叉编译器进行编译,得到可执行文件 helloworld
arm-linux-gnueabihf-gcc helloworld.c -o helloworld - 尝试在 PC 上执行该文件(应该会报错,提示无法执行二进制文件,执行格式错误!)
./helloworld
报错:bash: ./helloworld: cannot execute binary file: