10 ms·
Discover the world of microcontrollers through Rust
- shijie 9y agoThis is exactly, exactly what I've been looking for. As a software engineer whose professional career has focused entirely around the web, embedded systems is a strange, enticing landscape with what seems to be an "old guard," that eschews the frenetic pace of web technologies and frameworks, and relies on old, proven, get-shit-done tooling and technology. Which is amazing. But it also means that no one is writing blog posts on medium about this stuff, and beginner tutorials are sparse. For spoiled Elixir devs like me, this is perfect.
- drharby 9y agoOne could argue that blog posts wouldn't be needed since the books written on the material are generally accepted as mature coverage of the subject
- fit2rule 9y agoFrom the flipside, I've been a systems programmer since the 80's and have followed things along, pretty closely to the hardware, for a few decades now, and .. from this angle, its bananas to see how the web guys lose their minds over stupid shit nobody really needs every 6 months, yet everyone is a freakin' millionaire. ;)
- phkahler 9y agoSmall micro controllers don't have the resources you're used to. The smallest thing I ever wrote code for was in the PIC family and had 176 bytes of RAM and like 4 or 8K of flash (EEPROM?). Even on more common parts you may find only a few K of RAM and 10's or 100's of K flash. In that space we don't do any dynamic memory allocation, never mind garbage collection. If you did it's entirely possible you'd run out of heap space and the program would crash. It's a really different world than what web developers and app developers are used to. I highly recommend taking the dive even if it's just for fun and to see a different type of software development.
- Bromskloss 9y agoAnd you might want to avoid multiplication operations, because the compiler will likely have to implement those in software, which will be slow, and might make your program too large to fit in the memory… :-)
- DamonHD 9y agoThe AVRs, at least some of them, have reasonable Flash and RAM and EEPROM (v nice), and a single-instruction multiply. Much nicer than the 8-bit CPUs that I used to program back in days of yore...
- Bromskloss 9y agoPff, look at the fancy people over here!
- emilfihlman 9y ago>a single-instruction multiply But not single cycle ;) This is important!
- howard941 9y agoThe recommended 32Fs have FPUs so the hit isn't all that bad
- fulafel 9y agoThis is targeted at cortex m4, arm cores with hardware integer and division (and even integer simd).
- howard941 9y agoThis embedded dude longs to use Erlang on his MCUs. Closest I can get to it is one of the embedded *nixes. Raspberry PIs are great for prototyping but not all that easy a sell on the BOM
- petra 9y agoThere's a new mcu from microchip, that has 32mb dram, for ~$7. Might get you closer to your erlang dream. It uses new , cheap multi-die assembly techniques, which microchip also used in their ~$1 Bluetooth chip. So I think with time, and with an attractive software ecosystem,we'll see interesting new mcu's and price points.
- wott 9y ago> There's a new mcu from microchip, that has 32mb dram ...and a long list of errata, some of them quite serious: http://ww1.microchip.com/downloads/en/DeviceDoc/80000736A.pdf http://ww1.microchip.com/downloads/en/DeviceDoc/80000736A.pd... (note that if you look for it on Microchip website, the official link to the errata is also wrong at the moment!) Some people also reported a few heat issues, since it's got to dissipate heat from the memory and heat from the MCU, which starts being a bit large and a bit fast (for an MCU). Nothing extreme, but it has has to be considered in some setups. IMO, it's better to wait for other revisions of this chip, other versions in this family, or something else.
- MrBuddyCasino 9y agoThis is quite a list. There are so many "Module x is not functional. Workaround: None." its amazing. How did they manage screw up the VBAT pin?
- davidzweig 9y ago~$1 Bluetooth chip, is that the ATBTLC1000?
- pjc50 9y agoMicrocontrollers have got a lot more accessible since Arduino. There's lots of beginner material out there, although admittedly not on Medium. (Unsurprisingly, the people involved prefer a more bare metal approach and put it on blogs or forums instead) The tooling is nearly always C, so it's interesting to see Rust moving into this space. Memory management is not so much of an issue, but multitasking correctness is; perhaps there will be some new micro-RTOS framework with provably correct interrupt handling. (We have sel4, but that's not quite the same thing) As you get more low level, the tutorials get sparser. You move into FPGAs, where you have a choice of two languages with 1970s design principles, or third-party tools which work despite the manufacturer's total closedness. As you go deeper into actual IC design, nobody will attempt it without supervision from someone experienced to tell you all the little tricks. And then there's analog IC design, which is basically black magic.
- theWatcher37 9y agoCan confirm, in my emag applications class I had tools from "black magic something something" company printed on the top.
- Bromskloss 9y agoAlso in this stack, one step below using an Arduino, would be to use existing microcontrollers (or other ICs), but design your own circuit board. In contrast to IC design, this is something you can do on a hobbyist budget. Actually, if you don't etch the board yourself, but have it made and mailed, all you need is soldering equipment to populate the board with the components.
- kirrent 9y agoI've got the equipment to do hot air soldering, and I flatter myself that I've gotten pretty good at some fine SMD work, but these days I rarely bother. The premium on a service like macrofab.com usually is less than the money I waste on spare parts I accidentally destroy and postage from many different distributors.
- 9y ago
- k2enemy 9y agoI highly recommend nerdkits (http://www.nerdkits.com http://www.nerdkits.com) for someone in your shoes. You basically build an Arduino and it explains each part along the way. The included PDF is worth the price alone.
- AlexeyBrin 9y agoAll their kits and components are out of stock.
- audiometry 9y agoYeah, front page last-updated 2013, too.
- unkown-unknowns 9y agohttps://www.newbiehack.com/MicrocontrollerTutorial.aspx https://www.newbiehack.com/MicrocontrollerTutorial.aspx is an ok (not great but not bad either) way to learn about micro controllers. We used this site in a course I took. YMMV though. People in my class who lacked the experience I had with C and C++ from before had to struggle quite a lot.
- deleted 9y ago[deleted]
- anta40 9y agoIs there any significant work to add 8-bit microcontroller support to Rust?
- revelation 9y agoRust is by definition for new projects, so there are simply no more 8-bit microcontrollers around. Those things are moving into museums. And good riddance, M0s are soo much better.
- shakna 9y ago> so there are simply no more 8-bit microcontrollers around Atmel still produce a significant number of 8bit AVRs.
- fit2rule 9y agoYeah .. http://www.mouser.at/Semiconductors/Integrated-Circuits-ICs/Embedded-Processors-Controllers/Microcontrollers-MCU/8-bit-Microcontrollers-MCU/_/N-a86lo http://www.mouser.at/Semiconductors/Integrated-Circuits-ICs/... Apropros "M0's being so much better", this is not really an attitude that produces effective results in "the embedded" world. True fact: in embedded, many times you want the least powerful solution. 8-bit MCU's are freakin' everywhere, and they are not going anywhere.
- foldr 9y agoModern ARM Cortex M0 MCUs are cheaper than AVRs, use less power, and have much better peripherals. The only reason to use an AVR MCU these days is if you (i) need to run it off a 5V rail or (ii) you prototyped your product with an Arduino.
- kevin_thibedeau 9y agoCortex M has higher I/O latency.
- ChuckMcM 9y agoThis is well done, with lots of explanation around the bits that hang up a lot of people. Also Windows System for Linux (WSL) has become useful enough for embedded system development without running virtual machine. That helps minimize complexity a bit further for Windows users.
- bluejekyll 9y agoAt the recent RustConf I got to take a course working with TockOS. I highly recommend people check it out: https://www.tockos.org/documentation/getting-started/ https://www.tockos.org/documentation/getting-started/ It was a lot of fun to work with and looks to have a growing set of common drivers, etc. The OP guide looks to be lower level and wonderful for learning. Reading through it very quickly, it looks very thorough, well done!
- kfihihc 9y agoI like TockOS too. As a hardware product manager, I look forward to use it in next project.
- wlesieutre 9y agoAnyone know what would be required to get Rust running on the ESP32 boards? I picked up a couple for $6 each (Wemos LoLin32), and it's an impressive board for the price. Wifi and bluetooth built in. I assume it's non-trivial or someone would have done it already, but I'm curious if it might happen eventually. Been poking at C which is already a bit out of my wheelhouse, but it'd be a good excuse to check out Rust too if I could.
- tentaTherapist 9y agoThere isn't any LLVM support yet, and it doesn't look like anyone's working on it.
- mastax 9y agoI heard that Expressif was working on an LLVM port, but we'll see...
- MrBuddyCasino 9y agoThat has died. Every now and then I'm thinking this might be a fun project, but... well.
- Eridrus 9y agoYou could try and compile with the resurrected LLVM c backend, llvm-cbe, and then compile that C code with existing tools. Good luck debugging that mess if you ever need that, but Rust has compile time safety, right? ;)
- peller 9y agoI don't know about Rust, but MicroPython runs quite well on the ESP8266/ESP32 boards. Might be worth investigating if you're looking for something a bit more accessible than C. https://github.com/micropython/micropython-esp32 https://github.com/micropython/micropython-esp32
- PascLeRasc 9y ago>"But what's this ttyUSB0 thing? It's a file of course! Everything is a file in *nix." Isn't this not really true? I remember it was a long point of discussion in an embedded class I took years ago but can't remember exactly what was said.
- c3534l 9y agoI know that was originally the idea, but I doubt very much they've religiously kept up with that abstraction.
- microcolonel 9y agoIt's semi-true. Most things are still basically files, it's just that a lot of things get shoved through ioctls rather than reads, writes, and mmap. You still configure PCIe DMA through a file-based interface, but the ring buffers get mapped directly into your process. I think technically "everything" at least starts with an access to a file, but maybe not every interaction is done with a file.
- jononor 9y agoMany of the APIs for devices are through special ioctls, not through read/write of the file contents. Possibly what was referred to.
- dopeboy 9y agoStarted out with the 8052 in college. Graduated to the PIC. Upgraded to the AVRs. Last seen with Xilinx FPGAs before being kidnapped by fullstack web development. Man do I miss this stuff. Articles like these make me want to get back into it.
- MrBuddyCasino 9y agoWhy did you leave? I'm making the opposite journey right now, minus the job switch.
- tw1010 9y agoNot the parent. But I've done a bunch of both hardware and software and frankly I would go for software any day of the week. It's a lot harder to get into a flow with hardware. And it just feels a whole lot less free than software. You can go from pretty vauge idea to a working prototype very rapidly with software, but with hardware that both takes a lot longer and the types of things you can imagine is a lot more constrained. If you want a taste, go build some stuff in pure x86. You'll pretty quickly get tired of it and will want to build higher order abstractions, and then you're back in software-land.
- MrBuddyCasino 9y agoInteresting, I felt the opposite. Doing stuff with hardware expands your creative horizon to do things in the real world, freeing yourself from the confines of the virtual realm. 3D print what you need, make it come alive with MCUs. Also much of modern software development feels like just plugging lego bricks, but in embedded you actually have to know how stuff works, down to the register level. But then those were purely hobby projects, maybe it feels very different when doing it for a living.
- dopeboy 9y agoAt the time, I was in NYC and I wanted to stay. I couldn't find any hardware related jobs there so I switched over to software. Now I live in the bay area and am working on a startup. Iteration cycles are much more faster so I can learn quicker and ship quicker. Also, distribution is a lot easier.
- ravi2304 9y agoExcellent 5
- ravi2304 9y ago5
- Mister_Snuggles 9y agoI've dabbled with microcontrollers on and off. I started with the Basic STAMP, played around with things like the OOPic, tried my hand at PIC assembly on the 16F84 and 16F877, enjoyed the AVRs (ATmega328 and ATmega644) for a while, dabbled a bit with the ultra-low-power MSP430 (via the Launchpad), backed the MicroPython project and got a controller out of it, and have some ESP8266 boards that are just waiting to be played with. All of that was self-taught via online tutorials and forums. While some of this stuff is obscure, there's a ton of information out there for anyone to learn it. The biggest barrier to entry is money - developing for these platforms requires buying hardware, both the controllers themselves but also the programming tools (e.g., I use an AVRISP mkII to program ATmega chips). Many controller manufacturers make development boards that include a programmer, controller, and various peripherals to play with - this particular post focuses on the STM32FDISCOVERY board which seems to include the programming tool, a button, some LEDs, plus breaks out the controller's pins so that you can hook up whatever you need.
- jsolson 9y agoYou can get Arduino type boards for a few bucks on Amazon, which can be pretty easily turned into an ICSP programmer for arbitrary other microcontrollers. That helps a lot. Even just using it as an Arduino if you skip the "IDE" is a great way to start.
- Mister_Snuggles 9y agoYeah, the Arduino really opened up the world of microcontrollers to a lot of people. It's easy to get started and the price is reasonable. I've used an Arduino as a glorified breakout board thanks to the ICSP header (connected to an AVRISP mkII), and I've also used it with the Arduino IDE. It's a surprisingly versatile platform.
- ChristianGeek 9y agoYou can buy an Arduino for $10 and program it with a USB cable and any Windows/Mac/Linux computer.
- behohippy 9y ago
- deleted 9y ago[deleted]
- JustFinishedBSG 9y agoI got an STM32 Nucleo board some time ago that is sitting in a drawer. I want to learn Rust, would it apply?