1、首先查看当前Rust开发环境支持的目标平台有哪些:rustup target list
2、这里选择的目标平台是锾哩菸谷全志V3s处理器,其内核为Cortex-A7,指令集属于armv7,对应Rust下的平台是ar罪焐芡拂mv7-unknown-linux-gnueabihf使用rustup工具安装该平台的支持:rustup target add armv7-unknown-linux-gnueabihf
3、另外本地还需要有交叉编译工具链(Rust需要使用里面的链接器),这里选择的是gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf在~/.cargo/config文件中指定该工具链的具体位置,具体需要添加如下配置[target.armv7-unknown-linux-gnueabihf]linker = "arm-linux-gnueabihf-gcc"
4、使用cargo创建hello_world项目:cargo new hello_world --bin在本地编译运行:cargo run
5、交叉编译该工程:cargo build --target=armv7-unknown-linux-gnueabihf查看交叉编译生成的可执行文件hello_world的信息:file hello_world可以看到是ARM版本的ELF二进制
6、把该程序直接拷贝到LicheePi Zero上,观察是否能够正常运行,可以看到最后成功输出了hello world字样