[HN Gopher] Rust on Espressif chips
       ___________________________________________________________________
        
       Rust on Espressif chips
        
       Author : childintime
       Score  : 100 points
       Date   : 2023-07-01 15:39 UTC (7 hours ago)
        
 (HTM) web link (mabez.dev)
 (TXT) w3m dump (mabez.dev)
        
       | coder543 wrote:
       | This is a very timely article, since I've been trying to figure
       | out how to get Embassy to work on any of the various ESP32 boards
       | I have this weekend.
       | 
       | Is there any good guide for getting Rust working on ESP32? (the
       | old Xtensa dual core model, or the newer C3 or C6 models)
       | 
       | I've also been looking at maybe trying an RP2040 board I have,
       | but the Getting Started[0] guide seems very incomplete. It
       | doesn't even seem to mention that you need a nightly build of
       | Rust, but I'm pretty sure you do.
       | 
       | I also doubt that running "cargo run" is going to result in an
       | example being loaded onto any development board, so that seems
       | like a confusing thing to show in the guide.
       | 
       | [0]: https://embassy.dev/book/dev/getting_started.html
        
         | JoshMcguigan wrote:
         | "cargo run" does in fact flash the dev board. Cargo allows
         | configuring a custom runner, which is what the embassy examples
         | do [0].
         | 
         | [0]: https://github.com/embassy-
         | rs/embassy/blob/main/examples/stm...
        
           | coder543 wrote:
           | Ah, neat. That is a cool feature I didn't know cargo had!
        
         | captaincrisp wrote:
         | For ESP chips in general, the Rust on ESP Book [0] is pretty
         | solid. Little short. I've been playing with writing a Watchy
         | firmware in Rust (Watchy uses the dual-Xtensa ESP32-PICO-D4),
         | and this was a great starting point.
         | 
         | [0] https://esp-rs.github.io/book/installation/index.html
        
           | coder543 wrote:
           | I'll definitely take a look!
        
       | aloer wrote:
       | I have a bunch of various ESP32's lying around and I've been
       | getting by with copy pasted arduino code.
       | 
       | Works fine for most things but I've also told myself many times
       | now that I would like to dive deeper when I find the time.
       | 
       | My background is in web and Java. Never done C or C++.
       | 
       | Is rust on esp already good enough for a beginner?
        
         | bluejekyll wrote:
         | Rust makes use of some more advanced type features than Java
         | has. You'll want to focus on some of the differences between
         | traits and interfaces. Additionally, in Java you're probably
         | used to a lot of runtime dynamism, this is possible in Rust,
         | but not something you usually need to use. To understand this
         | better, look at dyn object safety.
         | 
         | The biggest thing in Rust that you need to become familiar with
         | from Java is the ownership system. First, Java is a default
         | copy-by-reference language, whereas Rust is move by default. So
         | learn the difference between, T, &T, and &mut T. Learning the
         | ownership system will make you disappointed in Java's thread-
         | safety story. Rust makes thread safety and multiple references
         | to values very obvious and you need to be explicit about how
         | things should be shared. This will probably be your biggest
         | hurtle, based on my experience.
         | 
         | Read the book, these concepts are all explained very nicely:
         | https://doc.rust-lang.org/book/
        
         | kelvie wrote:
         | Don't know the answer to your question, but depending on what
         | you want out of it, I find esphome with inlined C++ more than
         | enough for most cases (for anyone that knows how to code in
         | general).
         | 
         | It's mostly declarative, like writing a kubernetes helm chart
         | with some templating, which should be somewhat at home for web
         | folks.
        
       | heffer wrote:
       | For a second I thought this would be about an issue with damage
       | from iron oxide on Espressif chips.
       | 
       | Yes, it's a weekend and also a holiday today ;-)
        
       | jareklupinski wrote:
       | I've never worked with Rust, but I'm very familiar with
       | ESP32+VSCode/ESP-IDF, and eager to use something more high-level
       | but still stable enough for unattended network-connected
       | appliances
       | 
       | is this a good time to learn and start writing for the ESP32 in
       | Rust, or should I wait a little more?
        
         | jrockway wrote:
         | It's probably fine. I started using Go (tinygo) for
         | microcontroller projects a few years ago and haven't looked
         | back. If people can make Go work, I'm sure Rust is fine.
        
         | junon wrote:
         | This is a great time, in my opinion. Don't expect perfection,
         | but things are really far along.
        
       | smodo wrote:
       | I'm very excited about trying rust on these devices. Are there
       | any examples out there of projects using this in a more or less
       | mature shape?
        
         | sergiogasquez wrote:
         | Yes! The training developed with Ferrous Systems (https://esp-
         | rs.github.io/std-training/) contains several examples, and you
         | can find many community projects in https://github.com/esp-
         | rs/awesome-esp-rust#projects
        
         | f_devd wrote:
         | Afaik there while there are some OSS projects they aren't
         | necessarily mature.
         | 
         | The no_std hal is still a bit of a moving target so it's not as
         | beginner friendly, the most mature here seems to be the SlimeVR
         | firmware: https://github.com/SlimeVR/SlimeVR-
         | Rust/tree/main/firmware
         | 
         | For std hal there are a few more, OFMon being a good one:
         | https://github.com/arashsm79/OFMon
        
       | sacnoradhq wrote:
       | Oh shit, I have some ESP32s from my COVID isolation AliExpress
       | shopaholigasm.
       | 
       | "ESP32 ESP32-CAM WiFi"
       | 
       | "ESP8266 ESP32 ESP-32S"
       | 
       | "SX1276 ESP32 with LoRa 868MHz-915MHz"
       | 
       | Remember Chinese disposable brand sites tend to disappear without
       | warning, so you always have to archive everything they have on
       | their support sites, i.e., datasheets, code, examples, doc,
       | diagrams, etc.
        
       ___________________________________________________________________
       (page generated 2023-07-01 23:00 UTC)