Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MT7620 RAMIPS 架构无法运行预编译版本 #26

Closed
LGA1150 opened this issue Mar 14, 2017 · 15 comments
Closed

MT7620 RAMIPS 架构无法运行预编译版本 #26

LGA1150 opened this issue Mar 14, 2017 · 15 comments
Labels

Comments

@LGA1150
Copy link

LGA1150 commented Mar 14, 2017

OpenWrt 15.05
运行 overture-linux-mips 时报错:
./overture-linux-mips: line 1: syntax error: unexpected "("
运行 overture-linux-mipsle 时报错:
Illegal instruction

@shawn1m
Copy link
Owner

shawn1m commented Mar 14, 2017

这个不清楚,这是 Go 1.8 的新特性,可能会有一些问题。我没办法调试,你可以自己交叉编译试试看。

@LGA1150
Copy link
Author

LGA1150 commented Mar 14, 2017

我有交叉编译环境,要怎么配置Go的交叉编译呢?

@shawn1m
Copy link
Owner

shawn1m commented Mar 15, 2017

搜了一下有:http://studygolang.com/articles/7326 ,这是匹配以前版本的。
当前版本可以

GOOS=linux GOARCH=mips CGO_ENABLED=0 go build -o overture-linux-mips main/main.go

GOOS GOARCH 参数可选项参见:https://golang.org/doc/install/source

@LGA1150
Copy link
Author

LGA1150 commented Mar 15, 2017

据悉如果是 RAMIPS ,应该把 GOARCH 设为 mips32le

@LGA1150
Copy link
Author

LGA1150 commented Mar 15, 2017

官方的编译器似乎不能设置为 mips32le ,编译会报错,设为 mipsle 后运行时仍然有 Illegal instruction.

之后我找到了 https://github.com/gomini/go-mips32 ,成功编译了可以运行的版本 overture-linux-mips32le

以下是执行 file 命令的输出:

root@OpenWrt:/tmp/overture# file overture-linux-mipsle
overture-linux-mipsle: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), statically linked, not stripped
root@OpenWrt:/tmp/overture# file overture-linux-mips32le
overture-linux-mips32le: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), statically linked, not stripped

可以运行的多了个 rel2

@shawn1m
Copy link
Owner

shawn1m commented Mar 16, 2017

golang/go#18880
你可以试一下是不是 FPU 的问题。

@LGA1150
Copy link
Author

LGA1150 commented Mar 16, 2017

fatedier/frp#245
看来是的,然而得重新编译固件加入 FPU 模拟才能用
在 Golang 解决这个问题之前,暂时用 gomini/go-mips32 编译 MIPS 用的版本吧

@LGA1150
Copy link
Author

LGA1150 commented Mar 16, 2017

编译时加上参数 -ldflags "-s -w" 可以稍微减少编译的可执行文件大小
我编译好的文件大小达到 6.7MB ,快赶上路由器固件大小了,加上参数后减小到了 4.7MB

@LGA1150
Copy link
Author

LGA1150 commented Mar 16, 2017

又用 UPX 压缩了一下,大小只有约 900K 了,需要的可以下载
overture-linux-ramips.zip

@shawn1m
Copy link
Owner

shawn1m commented Mar 17, 2017

非常感谢。

@LGA1150
Copy link
Author

LGA1150 commented Mar 21, 2017

为什么不把 ramips 加进 release 呢

@shawn1m
Copy link
Owner

shawn1m commented Mar 21, 2017

Release 是直接用 build.py 自动生成的,我这里没有 ramips 的编译和测试环境,所以就没有放进来。我刚才试了一下,如果要编译 go 的话需要处理很多依赖关系,我这里没法做。Release 的内容是由自动化脚本决定的。

@shawn1m
Copy link
Owner

shawn1m commented Mar 21, 2017

或者新版本如果你编译好了上传我放进去。

@ghost
Copy link

ghost commented Mar 30, 2017

@LGA1150 重新编译固件会导致内核改变 无法安装官方仓库的 kmod 包

@63780223
Copy link

lede AR71XX mips 版不工作Illegal instruction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants