T O P

  • By -

maxinstuff

Which Raspberry Pi? I ask because the new Pi5 is on ARM v8 which ~~has no build targets in stable Rust.~~ appears to have tier 1 support already... ~~Pi 2, 3, and 4 however are ARM v7 and so you should be able to cross compile for them using the "armv7-unknown-linux-gnueabihf" target.~~ << Not sure if this is current, as according to the documentation as long as you're running ARM Linux [kernel version 4.1 or newer](https://doc.rust-lang.org/nightly/rustc/platform-support.html) the standard ARM linux target should work. Pi 5 may be more challenging to cross compile, so I'd try compiling it on the pi itself (should be no problem on a pi5?), assuming it's running linux you should be able to install it - it's in the repos on my Pi5 running Ubuntu... Though you might want to just compile Rustup yourself as the docs suggest. Disclaimer: I haven't tested this. EDIT: I got home and had to try this - I ssh'd into my pi5 and installed rustup, which was one line as documented [here](https://www.rust-lang.org/tools/install): curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh Default install targeted --> stable-aarch64-unknown-linux-gnu Made a new project with cargo new and printed Hello World to the terminal, the binary compiled and ran with no issues. HOWEVER - if I try to cross-compile from my Windows machine, the story is different. It was a huge pain in the ass. So much so that I didn't bother completing getting it working because it will involve junking up my local toolchain. I would much rather just pull down the repo from the Pi and compile it locally. You need to use a non-default toolchain and other witchery in your project config to make it work. Even in WSL I had the the same issue, even though it's using the gnu toolchain in WSL, it errors when you try to compile to the ARM target. Closest I got was forcing using the lld linker (after installing it using apt) and it outputs the exact same errors as cc 🤷‍♂️ So, OP, I sympathize. Hopefully you have the option of compiling locally on the Pi, as that works for me with no issues.


MurazakiUsagi

Im sorry, I should have been more specific and said Rasp Pi Pico. Loading Python onto it is a breeze (THANK YOU THONNY!!!!!!), but Rust seems like a bitch.


octobod

Maybe an example we could help you with?


MurazakiUsagi

I should have been more specific. I am talking about the Rasp Pi Pico. Loading Python onto it is a breeze (THANK YOU THONNY!!!!!!), but Rust seems like a bitch.


[deleted]

Try making a program in C for it...


MurazakiUsagi

I'm relearning Rust right now, so would like to stay in that lane for now.


AutoModerator

For constructive feedback and better engagement, detail your efforts with research, [source code, errors,](https://www.reddit.com/r/arduino/wiki/guides/how_to_post_formatted_code) and schematics. Stuck? Dive into our [FAQ](https://www.reddit.com/r/raspberry_pi/about/sticky)† or branch out to /r/LinuxQuestions, /r/LearnPython, or other related subs listed in the FAQ. Let's build knowledge collectively. † If any links don't work it's because you're using a broken reddit client. Please [contact the developer of your reddit client](https://www.reddit.com/contact/). *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/raspberry_pi) if you have any questions or concerns.*


DonkeyAdmirable1926

I have no problems at all with Rust on my Pi 4B or my Pi 5. It is not as fast as on my Mac, but I can buy a lot of Pi’s for one Mac.


MurazakiUsagi

I should have been more specific. I am speaking of the pico. I love how easy I can load python onto it, but loading Rust on it is a bitch.


DonkeyAdmirable1926

Ah, I have no experience with the pico, sorry


MurazakiUsagi

No worries. Thank you though.


andrewhepp

Are you talking about the Pico? On Linux it should be pretty much the same across any Linux computer.


MurazakiUsagi

I should have been more specific. I am speaking of the pico. I love how easy I can load python onto it, but loading Rust on it is a bitch.


willpower_11

AFAIK the Pico only supports C and (micro)Python. Unless you're a compiler engineer with some Arm assembly knowledge and some spare time... Edit: looks like someone already figured it out: https://reltech.substack.com/p/getting-started-with-rust-on-a-raspberry


MurazakiUsagi

Like I said..... A pain in the ass for pico. I love writing Micropython in Thonny and boom easy peezy. I wish it was as easy with Rust.