Embedded Rust Hack Chat

Join us on Wednesday, May 12 at noon Pacific for the Embedded Rust Hack Chat with James Munns!

Programming languages, like fashion, are very much a matter of personal taste. Professional developers often don’t have much say in which language they’ll use for a given project, either for legacy or team reasons, but if they did have a choice, they’d probably choose the language that works best with the way they think. Some languages just “fit” different brains better than others, and when everything is in sync between language and developer, code just seems to flow effortlessly through the keyboard and onto the screen.

One language that consistently scores at the top of developers’ “most loved” lists is Rust. For a language that started as a personal project and has only existed for a little more than a decade, that’s really saying something. The emphasis Rust puts on safety and performance probably has a lot to do with that. And thanks to its safe concurrency, its memory safety, and its interoperability with C and other languages, Rust has made considerable in-roads with the embedded development community.

To learn more about Rust in embedded systems, James Munns will stop by the Hack Chat. James is an embedded systems engineer, with a history of working on software for a wide range of systems, including safety-critical avionics, and rapidly prototyped IoT systems. He’s a founding member of the Rust Embedded Working Group, as well as a founder of Ferrous Systems, a consultancy focused on systems development in Rust, with a specialty in embedded systems development. James also used to write for Hackaday, so he must be a pretty cool guy. So swing by the Hack Chat and find out where Rust might be able to help you out with your next embedded project.

join-hack-chatOur Hack Chats are live community events in the Hackaday.io Hack Chat group messaging. This week we’ll be sitting down on Wednesday, May 12 at 12:00 PM Pacific time. If time zones have you tied up, we have a handy time zone converter.

Click that speech bubble to the right, and you’ll be taken directly to the Hack Chat group on Hackaday.io. You don’t have to wait until Wednesday; join whenever you want and you can see what the community is talking about.
Continue reading “Embedded Rust Hack Chat”

Low-Level Academy Gets Into Details

We often say that you don’t have to know how an engine works to drive a car, but you can bet that every driver at the Indy 500 knows exactly how it works. You could say the same for computers. You don’t need to understand the details, but it really helps, especially if something goes wrong. [Low-Level Academy] has an online class where you can program in Rust inside your browser to learn about low-level TCP and UDP networking details.

Just how low it goes, we aren’t exactly sure, yet. There are three of eight modules ready to go. The first three cover number encoding, exchanging messages with UDP, and fragmentation. Reliability, routing, server programming, TCP, and HTTP are not out yet, but the ultimate project is a web server. In addition, new modules are released to sponsors first, so the fragmentation module for example won’t be available for a few more days. While that seems unorthodox, it is no different than having to wait for an HBO show to show up on basic cable in reruns.

Continue reading “Low-Level Academy Gets Into Details”

Linux Fu: Global Search And Replace With Ripgrep

If you are even a casual Linux user, you probably know how to use grep. Even if you aren’t a regular expression guru, it is easy to use grep to search for lines in a file that match anything from simple strings to complex patterns. Of course, grep is fine for looking, but what if you want to find things and change them. Maybe you want to change each instance of “HackADay” to “Hackaday,” for example. You might use sed, but it is somewhat hard to use. You could use awk, but as a general-purpose language, it seems a bit of overkill for such a simple and common task. That’s the idea behind ripgrep which actually has the command name rg. Using rg, you can do things that grep can do using more modern regular expressions and also do replacements.

A Note on Installing Ripgrep

Your best bet is to get ripgrep from your repositories. When I tried running KDE Neon, it helpfully told me that I could install a version using apt or take a Snap version that was newer. I usually hate installing a snap, but I did anyway. It informed me that I had to add –classic to the install line because ripgrep could affect files outside the Snap sandbox. Since the whole purpose of the program is to change files, I didn’t think that was too surprising, so I did the install.

Continue reading “Linux Fu: Global Search And Replace With Ripgrep”

3D-Printed Thermite Brings The Heat, And The Safety

Thermites are a double-edged sword. Packing a tremendous energy density, and eager to produce tremendous heat when ignited, thermite is great for welding train tracks. But sometimes you might be looking for a little more finesse. A new approach to 3D printing thermites might just be able to tame the beast.

Most of us do our soldering while sitting safely indoors in a comfortable climate. The biggest dangers we’re likely to face are burnt fingertips, forgetting the heat shrink, or accidentally releasing the smoke monster. But outside of our homes and workshops, there’s a lot of extreme joining of metals going on. No matter where it’s done, welding and brazing in the field requires a lot of equipment, some of which is unwieldy and even more difficult to move around in harsh conditions.

Welding railroad tracks with thermite. Image via YouTube

The utility of brazing is limited by all the complex scaffolding of hardware required to support it. This limiting factor and the discovery of thermite led to exothermic welding, which uses an energetic material to provide enough heat to melt a filler metal and join the pieces. Energetic materials can store a lot of chemical energy and forcefully release it in a short period of time.

Thermites are made of metal oxide and metal powder, often iron oxide and aluminium. When ignited by a source of high heat, thermite compounds undergo an exothermic reduction-oxidation (redox) reaction as the aluminium reduces the number of electrons in the iron oxide atoms. More heat makes the reaction run faster, generating more heat, and so on. The result is molten iron and aluminium oxide slag.

Continue reading “3D-Printed Thermite Brings The Heat, And The Safety”

Exotic Device Gets Linux Support Via Wireshark And Rust

What can you do if you have a nice piece of hardware that kinda works out of the box, but doesn’t have support for your operating system to get the full functionality out of it? [Harry Gill] found himself in such a situation with a new all-in-one (AIO) water cooling system. It didn’t technically require any operating system interaction to perform its main task, but things like settings adjustments or reading back statistics were only possible with Windows. He thought it would be nice to have those features in Linux as well, and as the communication is done via USB, figured the obvious solution is to reverse engineer the protocol and simply replicate it.

His first step was to set up a dual boot system (his attempts at running the software in a VM didn’t go very well) which allowed him to capture the USB traffic with Wireshark and USBPcap. Then it would simply be a matter of analyzing the captures and writing some Linux software to make sense of the data. The go-to library for USB tasks would be libusb, which has bindings for plenty of languages, but as an avid Rust user, that choice was never really an issue anyway.

How to actually make use of the captured data was an entirely different story though, and without documentation or much help from the vendor, [Harry] resorted to good old trial and error to find out which byte does what. Eventually he succeeded and was able to get the additional features he wanted supported in Linux — check out the final code in the GitHub repository if you’re curious what this looks like in Rust.

Capturing the USB communication with Wireshark seems generally a great way to port unsupported features to Linux, as we’ve seen earlier with an RGB keyboard and the VGA frame grabber that inspired it. If you want to dig deeper into the subject, [Harry] listed a few resources regarding USB in general, but there’s plenty more to explore with reverse engineering USB.

Modified Bricks Can House Energy, Too

What if building an emergency battery were as easy as painting conductive plastic onto bricks, stacking them, and charging them up? Researchers at Washington University in St. Louis have done just that — they’ve created supercapacitors by modifying regular old red bricks from various big-box hardware stores.

The bricks are coated in poly(3,4-ethylenedioxythiophene) polystyrene sulfonate (PEDOT:PSS), a conductive polymer that soaks readily into the bricks’ porous surface. When the coated brick is connected to a power source such as a solar panel, the polymer soaks up ions like a sponge. PEDOT:PSS reacts with the iron oxide in the bricks, the rust that gives them their reddish-orange color. Check out the demonstration after the break — it’s a time lapse that shows three PEDOT-coated bricks powering a white LED for ten minutes.

We envision a future where a brick house could double as a battery backup when the power goes out. The researchers thought of that too, or at least had their eye on the outdoors. They waterproofed the PEDOT-coated bricks in epoxy and found they retain 90% of their capacitance and are still efficient after 10,000 charge-discharge cycles. Since this doesn’t take any special kind of brick, it seems to us that any sufficiently porous material would work as long as iron oxide is also present for the reaction. What do you think?

If you can get your hands on the stuff, PEDOT:PSS has all kinds of uses from paper-thin conductors to homebrew organic LEDs.

Continue reading “Modified Bricks Can House Energy, Too”

Will 2020 Be The Year Of Rust In The Linux Kernel?

One problem with modern programming languages is the reach their overly enthusiastic early adopters have nowadays thanks to the internet. As a result, everyone else’s first encounter with them are oftentimes some crude, fanboyish endeavors to rewrite every single established software project in that shiny new language — just because — which may leave an off-putting taste behind. However, Rust certainly seems to have outgrown this state by now, and with its rising popularity within the general developer population, it’s safe to say it will stick around. Will it fully replace C one day? Probably not, but there’s a big chance for coexistence, and [Nick Desaulniers] got the ball rolling for that within the Linux kernel.

Now, before you storm off pledging your allegiance to C by finding a new operating system: nothing is happening yet. [Nick] simply tested the waters for a possible future of Rust within the Linux kernel code base, which is something he’s planning to bring up for discussion in this year’s Linux Plumbers Conference — the annual kernel developer gathering. The interesting part is [Linus Torvalds]’s respone on the LKML thread, which leaves everyone hoping for a hearty signature Rust rant akin to his C++ one disappointed. Instead, his main concern is that a soft and optional introduction of the support in the build system would leave possible bugs hidden, and therefore should be automatically enabled if a Rust compiler is present — essentially implying that he seems otherwise on board.

We’ll see what comes of it, but with Rust language team lead [Josh Triplett] stating that enhancements benefiting and advancing a kernel integration are certainly imaginable for Rust itself, we might see interesting collaborations coming up in the near future. If you don’t want to wait for that and use Rust already today in a user-land driver, check out this 35c3 talk. And if that doesn’t go far enough for you, here’s a whole (non-Linux) kernel written in Rust.