Feature Request: Add Support for RISC-V (riscv64) Architecture
With the rise of alternative CPU architectures following Apple's M series chips, RISC-V has gained significant traction.
I am currently using a Milk-V Duo S, which is based on the RISC-V architecture:
When attempting to use curl on this device (which runs BusyBox), I noticed that riscv64 is not currently supported.
Would it be possible to add support for this architecture? If this is not something that can be added directly, I would be happy to contribute, but I would appreciate any guidance on where to make the necessary updates. I am not very familiar with Rust, so any pointers on where to start would be helpful.
Thank you!
Interesting, which OS is it running? And what would you say would be the number of people using these devices -- I'd imagine it is mostly embedded systems currently or is it also used for servers / desktops?
You may want to check out this list https://doc.rust-lang.org/beta/rustc/platform-support.html
For numbers of people there is no stats, but i can speculate, based on this video (https://youtu.be/rby8a_DsSYc) which has 64K views, let's say 5% of people bought it, which is 3200 devices sold minimum, then there are people like me who needs like 10 like those, so i could say it can vary from 3200 ~ 320 000 devices sold worldwide (also it mostly got sold out last time)
It uses a custom firmware :
[root@milkv-duo]~# uname -a
Linux milkv-duo 5.10.4-tag- #1 PREEMPT Thu Aug 1 14:12:58 CST 2024 riscv64 GNU/Linux
When cross-checking with milk-v docs, and rust docs you provide, it uses should be using riscv64gc-unknown-linux-musl
Milk V Duo S firmware releases page: https://github.com/milkv-duo/duo-buildroot-sdk-v2/releases/ (milk v duo s has dual architecture, arm and riscv).
Nice! unfortunately the cross-compiler / linker toolchain I use https://github.com/messense/homebrew-macos-cross-toolchains doesn't have riscv64gc targets so that's sad. But maybe there's a way to do it with cross.
Want to try building with cross from a different computer (not the riscv one) and let me know what works? This is what I have for my freebsd build for instance, along with some config in Cross.toml
cross build --release --target x86_64-unknown-freebsd
[target.x86_64-unknown-freebsd]
pre-build = [
"apt-get update",
# Protobuf version is too outdated on the cargo-cross image, which is ubuntu:20.04.
# "apt install -y protobuf-compiler",
"apt install -y wget libarchive-tools",
"mkdir /protoc",
"wget -qO- https://github.com/protocolbuffers/protobuf/releases/download/v29.2/protoc-29.2-linux-x86_64.zip | bsdtar -xvf- -C /protoc",
"mv -v /protoc/bin/protoc /usr/local/bin && chmod +x /usr/local/bin/protoc",
"mkdir -p /usr/local/include/google/protobuf/",
"mv -v /protoc/include/google/protobuf/* /usr/local/include/google/protobuf/",
"rm -rf /protoc",
]
I've asked Claude Opus 4 to make a go port of the client. I've compiled that for various platforms. Works fine on my mips64 router. If it helps, you can try the riscv64 binary from here: https://github.com/ovidiuvio/SSHXtend/releases/download/v0.4.1-sshxtend/sshxtend-go-linux-riscv64
It is a fork and has some changes, but it seems it still works fine with sshx.io
Hi, Thanks @ovidiuvio on my risc64 I get those
failed to create controller: failed to open session: rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: unexpected EOF"
and sometimes
failed to create controller: failed to open session: rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: read tcp 192.168.8.94:55500->66.51.127.182:443: read: connection reset by peer
Hi, Thanks @ovidiuvio on my risc64 I get those
failed to create controller: failed to open session: rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: unexpected EOF"and sometimes
failed to create controller: failed to open session: rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: read tcp 192.168.8.94:55500->66.51.127.182:443: read: connection reset by peer
Ok, seems there was a problem with tls connections in the go implementation: https://github.com/ovidiuvio/SSHXtend/commit/97abf3ab74909fedeade64e03494d0b89619a1a4 New build here: https://github.com/ovidiuvio/SSHXtend/releases/download/v0.4.1-o2-sshxtend/sshxtend-go-linux-riscv64
Did anyone try using cross as I suggested in https://github.com/ekzhang/sshx/issues/125#issuecomment-2737458507
No worries if not, I think that's probably the most promising approach also. Surprised that porting the whole thing to a new language with AI is easier than figuring out how to set cross-compilation flags in Rust (possibly also with AI?) 😓
@ekzhang I've tried to build it with cross for mips64 in january 2025 and spent a few good hours on that without much luck...
Opus 4 made the go port in 3 prompts ...🤷♂️
Did anyone try using cross as I suggested in #125 (comment)
No worries if not, I think that's probably the most promising approach also. Surprised that porting the whole thing to a new language with AI is easier than figuring out how to set cross-compilation flags in Rust (possibly also with AI?) 😓
Well you are right, no way to build on mac os :( I spent 3 hours fighting. If @ovidiuvio version works, i think you could merge it to your project ?
@ovidiuvio @ekzhang and @ovidiuvio implementation works!
- Current use case is for IoT, milkv-duo was 20KM away, had to swap tailscale ownership.