小米R3G openwrt交叉编译
整体流程:
1.去openwrt官网下载对应的交叉编译sdk,用c语言测试ok
2.设置rust 为nightly版本,并用xargo代替cargo构建项目(因为rust正式版的target不支持mipsel-unknown-linux-uclibc)
host: ubuntu18.04
target: openwrt 15.05.1
https://openwrt.org/toh/hwdata/xiaomi/xiaomi_miwifi_3g_v2 //小米r3g硬件信息
http://downloads.openwrt.org/
https://archive.openwrt.org/chaos_calmer/15.05.1/ramips/mt7621/ //交叉编译sdk下载页面
ssh登陆到小米R3G
uname -a //查看架构信息
cat /etc/openwrt_release //小米自带的openwrt信息是假的
ubuntu上的操作
1.下载交叉编译sdk,并配置环境变量
cd ~/tmp
wget https://archive.openwrt.org/chaos_calmer/15.05.1/ramips/mt7621/OpenWrt-SDK-15.05.1-ramips-mt7621_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2
解压下载的文件
tar xjvf OpenWrt-SDK-15.05.1-ramips-mt7621_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2
设置环境变量
vi ~/.zshrc
export PATH=$PATH:~/tmp/openwrt/staging_dir/toolchain-mipsel_1004kc+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
export STAGING_DIR=~/tmp/openwrt/staging_dir/
自建hello.c 测试c语言交叉编译
#include<stdio.h>
main() {
printf("Hello, World!\n");
}
mipsel-openwrt-linux-gcc hello.c -o hello
2.设置rust 为nightly版本,并用xargo代替cargo
rustup install nightly
rustup default nightly
rustup component add rust-src
rustc -Vv
cargo install xargo
新建 rust测试项目hello
cargo new hello --bin
vi Cargo.toml //添加
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
vi Xargo.toml //添加
[target.mipsel-unknown-linux-uclibc.dependencies.std]
features = []
vi ~/.cargo/config //添加
[target.mipsel-unknown-linux-uclibc]
linker = "mipsel-openwrt-linux-gcc"
构建项目
xargo build --release --target mipsel-unknown-linux-uclibc --verbose
参考链接
https://github.com/japaric/rust-cross //rust 交叉编译文档
https://github.com/japaric/xargo
https://users.rust-lang.org/t/openwrt-mips-cross-compile-error/7285
https://nitschinger.at/Rust-on-the-Wifi-Pineapple-and-OpenWRT/ //详细介绍配置过程 仔细阅读
https://www.dazhuanlan.com/2019/12/26/5e043c553fc1a/?__cf_chl_jschl_tk__=3a32e05b873db5c4cefed9207b4a2dc879c8aa28-1584347106-0-AVEJlXYnaY88_QUj0n132ZRBYcYJafmB_rP-I4jpPhszwmZ-GV-0wbJdTfo8LcWfLoma_1KSAMf1vv-eo4CCJgXmNCweBYJjhXzav2Lyj5m8NLUp_CYdpweEfkJ95fG014W6dlB4hyWbXSvowCddowdu2hlzOaIwRfMg5fz9oK3yF-jujDU-LqrDwGzHBg0KIsUEAAlhvZoZHZ5I8Hzt0z5VxpQKu-gx73O-8EnZbokDAF0AkKzf7XJp8tMz3MYnx9oErXL2QeNyzX3VD0FZONMjZW_uByGlTlDRgllrcTdkwg8FN9SFmZIQ6fpGkUxNJg
openssl
https://*.com/questions/37375712/cross-compile-rust-openssl-for-raspberry-pi-2
https://www.reddit.com/r/rust/comments/axaq9b/opensslsys_error_when_crosscompiling_for/