7 ms·
RetroBSD: Unix for microcontrollers
- unwind 8y agoPretty cool. Made me wonder if it would make sense on these SoC targets to dynamically load a program from external storage and write into internal flash for execution, then start running it without a reboot. Since such flashes are typically only erasable in pretty big blocks ("sectors") it would require some interesting design choices, but it should be doable. :)
- berti 8y agoYou could exec from SRAM if you have enough to spare (larger Cortex M4/M7 uCs have 256k+, RetroBSD claims to only need 128k of that).
- monocasa 8y agoI'd be hesitant, as those flash banks aren't rated for more than 1000 or so writes over their lifetime. I've killed the internal flash in a few Arduinos and STM32s just from development/testing.
- exikyut 8y agoHm. Makes me think how many (few) bytes you could fit a "if a specific interrupt is received then copy bytes from wire to RAM and run that instead" preamble into the bootloader. Presuming "killed" means "won't accept new updates but will read" (?), you could then continue to use the chip.
- derefr 8y agoThis is, essentially, what the older generation of “flash carts” for game consoles do. Each new loaded game ROM gives you a progress bar as the cart performs an erase/program cycle to its flash. (The newer generation just copies the ROM to memory.)
- okl 8y agoThere are several runtimes for microcontrollers that feature an elf/hex loader for static binaries, or a bootloader that retrieves a program and executes it in RAM. Sometimes you can re-enter the bootloader from your application software. On some embedded systems (satellite OBSW comes to mind) you can actually hot-patch the code function-by-function while running. You compile/link the software with some extra space before and after your functions for future modifications. Then when you patch, you have to make sure that the modified code is locked out and that the variables used by the functions being patched are in an acceptable state as well as the cache. Whether all of that extra effort makes sense? - it depends. But in most embedded projects you can just flash a new firmware and avoid the overhead of executing from RAM. (Depending on your target, flash might have a separate memory bus and could be one or two clock cycles faster.) Edit: Hot-patching in flash is totally possible as well.
- ramzyo 8y agoSounds interesting - any runtimes in particular you could point out? Interested to read more about them.
- LeifCarrotson 8y agoI built such a system for a PIC32 in a previous job. When it was online, we'd connect to it over Ethernet and send it firmware updates that it would burn to an external SPI flash chip (we used it for testing communications protocols with a wide variety of products, and it needed frequent firmware updates). If one of these updates had a bug and bricked the controller, it was a hassle (not to mention downtime!) to remove it from the machines on the production floor and bring it back to engineering to plug in the dedicated programming device. So we set up the SPI flash to store two copies of the firmware. If it went down, you could reset it while holding down a "restore last-known-good firmware" button, and the boot routine would reflash the on-board flash memory with the previous copy of the firmware from the SPI flash. I wouldn't do this every time you needed to power cycle it - but on a per-revision level it was very useful!
- alxlaz 8y ago> Made me wonder if it would make sense on these SoC targets to dynamically load a program from external storage and write into internal flash for execution, then start running it without a reboot. There is less reason for this today because high-capacity, high write-count storage is cheap. But I have seen it done, e.g. in order to retrofit redundant firmware update schemes on devices that do not originally support it. A long time ago I looked into something like this for one of the devices I was working on at the time (the firmware was stored in the internal flash of the MCU, but was steadily growing, and we'd eventually run out of space to hold two copies; however, we also had a larger, cheaper, slower external flash that we could use). The write cycles cap of flash devices can make it a bad idea under some scenarios, but that's a decision you make on a case-by-case basis. ZOMG THIS IS FLASH DO NOT REWRITE IT is not exactly a clever design solution.
- kevin_thibedeau 8y agoIntegrated NOR flash still commonly tops out at 100K erases. Not something you'd want to be doing as an integral part of an OS execution model.
- ChuckMcM 8y agoSome of these SoC targets (like the STM32F4x9 series) have SDRAM controllers so you can put 4 - 16MB of RAM on them.
- erric 8y agoThe hardware looks pretty limited right now, but I have to wonder if this can be used as a base for replacing closed source Lights out Management such as iLO, DRAC, and LoM
- exikyut 8y agoInteresting idea; but this is 2.11BSD, not OpenBSD, so the attack surface/weak links are mostly unknown for this majorly obscure kernel configuration/port. IMO I'd generally want OOB management kit to be Very Very™ secure, and especially if it lets me near any secure boot keys. In any case this kind of thing will categorically have the ability to reboot the system, so if I can tinker with configuration I definitely want to have some degree of confidence in the auth process etc. Completely outside the scope of a microcontroller, what would a reasonable 10-year target for video capture be within a "server console/admin" context? 1080p? 2K? DisplayPort? HDMI? (Obviously VGA) I'm guessing HDMI and maybe 2K. Hm.
- pjc50 8y agoHDMI-over-IP is something you can just buy off Amazon for a few hundred dollars?
- lizknope 8y agoYes but you have to check what you buy carefully. There are HDMI over cat5/6 cable that are basically point to point and are basically just replacing the cable to transmit a longer distance. The more expensive products that claim to translate HDMI into IP and send over an ethernet network. I'm not sure if they are just turning into ethernet packets and only work on a LAN or if they turn into routable IP packets.
- namibj 8y agoWorst case you need to teach the router to create a Layer2 VPN. It's doable.
- ishikawa 8y agoThis can be pretty interesting for inexpensive IoT and IIoT devices.
- TickleSteve 8y agoNo, this is jut a toy, it would never be used for real IoT or IIoT devices. There is no need to dynamically load any code on these type of devices, you would generally just use eXecute-In-Place (XIP). The type of applications you develop for these devices simply do not require UNIX like features (multi-user, etc). Many more appropriate OS'es exist for this to be taken seriously.
- jacobush 8y agoI am not saying it's a good idea, but you have Minix (multi-user Unix, it can even compile itself) in (all?) Intel 64 bit chipsets.
- cat199 8y agoThis comment is misinformed. Unix has always been multi user, and has always (aside from earliest days before anyone heard of it) been able to compile itself. Minix does not stand for multi-user Unix. https://www.levenez.com/unix/ https://www.levenez.com/unix/ https://www.tuhs.org/Archive/Distributions/Research/Documentation/v6_setup.html https://www.tuhs.org/Archive/Distributions/Research/Document...
- tom_ 8y agoThe reference is presumably to Intel's use of Minix in its CPUs - see, e.g., https://www.zdnet.com/article/minix-intels-hidden-in-chip-operating-system/ https://www.zdnet.com/article/minix-intels-hidden-in-chip-op... - as an example of a place where a multi-user OS (that can compile itself...) might be used for what might seem like an embedded-type application.
- okl 8y ago> No, this is jut a toy, it would never be used for real IoT or IIoT devices. There's lots of outrageous stuff inside today's consumer products. What makes you so sure that this won't be used in a real (whatever that means) IoT or IIoT device by someone?
- iuguy 8y agoI have this running on a Fubarino. It's nice to fiddle with but not quite useful to be serious. I have an ethernet module that at some point I need to hook up to it. What I really want is a DIP version of the PIC32 with enough RAM and flash to run this or the 4.4-based LiteBSD[1] by the same people. [1] - https://github.com/sergev/LiteBSD https://github.com/sergev/LiteBSD
- grogenaut 8y agoWhy dip?
- jacobush 8y agoEasy to solder?
- Koshkin 8y agohttp://geoffg.net/SurfaceMount.html http://geoffg.net/SurfaceMount.html
- iuguy 8y agoExactly. I build projects in my spare time to teach people how to solder. SOIC or QFN is just about doable for beginners, but having a full Unix computer that anyone can build in an afternoon would be pretty cool.
- cat199 8y agoAgreed, If I could get 4M(16bit) or 16M/32M/64M and a tty going, and some tiny ssh implementation+ethernet that would be amazing.
- squarefoot 8y agoI wonder why there's no port for the ESP32 boards family. Plenty of RAM/Flash (compared to PIC32), lots of I/O ports and peripherals and built in WiFi/BT. It just seems to me the perfect target, or am I missing something? https://en.wikipedia.org/wiki/ESP32 https://en.wikipedia.org/wiki/ESP32
- javascriptPhD 8y agoI bet nobody has thought of making a POSIX-compliant system that runs on those spooky nerd doodads before
- deleted 8y ago[deleted]
- okl 8y agoThere are a number of real-time executives and operating systems that provide a POSIX API and are mostly compliant as far as sensible or feasible on such devices, for example RTEMS and RIOT-OS.
- dvfjsdhgfv 8y agoPIC32 is one of the the most underestimated MCU architectures; you get a small powerful computer for a fraction of the cost of one. I think it's doomed because of Cortex-M, but what you can do with it in that price range still amazes me. If only the Chinese picked it up... The boards by Olimex are nice to work with but could be a bit cheaper.
- ris 8y agoAs interesting as this is, I'm not really sure what this gets you over a regular RTOS that might be used with these sorts of microcontrollers apart from easy porting of existing unix software (though with 2.2BSD it would have to be very restricted in its use of syscalls - does it even have sockets?)
- btashton 8y agoIf you want to checkout a POSIX RTOS for microcontrollers, I would checkout Nuttx. I have built some commercial products with it. [0] nuttx.org