交叉编译环境搭建
一、什么是交叉编译
开发机(x86)与目标板(ARM)架构不同,需要用交叉编译工具链在开发机上编译出 ARM 可执行文件。
二、安装工具链
sudo apt install gcc-arm-linux-gnueabihf
三、编译与传输
# hello.c 编译为 ARM 程序
arm-linux-gnueabihf-gcc hello.c -o hello
# 传到开发板(NFS / scp / U 盘均可)
scp hello root@192.168.1.100:/root/
四、板端运行
chmod +x /root/hello && /root/hello
Hello, Embedded Linux!
五、系统构建概览
完整嵌入式 Linux = Bootloader(U-Boot)+ 内核 + 根文件系统(Buildroot / Yocto)。先从“跑通最小系统”开始,再逐步深入。