Arguably the biggest advantage of the Arduino ecosystem is how easy it is to get your code running. Type a few lines into the IDE, hit the button, and in a few seconds you’re seeing an LED blink or some text get echoed back over the serial port. But what if that same ease of use didn’t have to be limited to microcontrollers? What if you could use the Arduino IDE to create computer software?
That’s exactly what boot2duino, a project developed by [Jean THOMAS] hopes to accomplish. As you might have guessed from the name, the code you write in the Arduino is turned into a bootable floppy disk image that you can stick into an old PC. After a few seconds of beeping and grinding your “Hello World” should pop up on the monitor, and you’ve got yourself the world’s biggest Arduino.
Now to be clear, this isn’t some kind of minimal Linux environment that boots up and runs a compiled C program. [Jean] has created an Arduino core that provides basic functionality on x86 hardware. Your code has full control over the computer, and there’s no operating system overhead to contend with. As demonstrated in a series of videos, programs written with boot2duino can display text, read from the keyboard, and play tones over the PC’s speaker.
The documentation for boot2duino says the project serves no practical purpose, but we’re not so sure. While the feature set is minimal, the low overhead means you could theoretically press truly ancient PCs into service. There’s certainly an appeal to being able to write your code on a modern OS and effortlessly deploy it on a retrocomputer, from somewhat modernized versions of early computer games to more practical applications. If any readers end up exploring this concept a bit further, be sure to let us know how it goes.
Budget SSFD? (solid state floppy disk) Could be useful for faster booting into DOS?
If you want to boot into DOS, put DOS onto your fast storage. Why would you want to initialize a C++ runtime to chainload DOS? That is an extra step you don’t need.
Ide to cf flash. Did it with one of those linus cpu laptops. Was decent. Not great.
How about IDE to SATA and a SATA SSD?
Exactly; every BIOS (and UEFI with CSM enabled) is capable of booting DOS regardless of the media it is on, the only requirement being the media being visible to the BIOS.
How about boot from usb….. Could see an application or two for that….
Not if you’re trying to boot ancient x86 machines. Those were pre-PCI era and I don’t think anyone made ISA USB card.
There are ISA cards that allow to use USB, CompactFlash, PATA drives, then there are FDD USB replacements like GOTEK.
IIRC they didn’t usually allow booting from USB.
Even by the Pentiun era, USB boot was something you enabled in the bios.
Actually, it allows you to boot a disk image from a USB stick, through an emulated floppy disk drive.
And ISA or PCI card can enable you to boot via USB due to the fact that they can have little BIOSes of their own on the card. Hacking some PCI card’s firmware to add their own code was actually the what enabled the NSA to add a BIOS backdoor to some high-security systems and evade detection. :)
In the syslinux package there is memdisk that is made to boot floppy disk images from other media, for example USB.
Like this!
Next step it a fully automomous ardino IDE booting from floppy without any OS!
Arduino *is* your OS here. Just like it is the OS when run on an atmega.
Arduino is a collection of libraries and an ecosystem of boards aimed at education and hobbyists. It’s not anything close to an OS that runs on atmegas.
It all hinges on your definition of “Operating System”. All you would need to add is a set of FAT16 routines and you’d have something roughly equivalent to MSDOS, TRSDOS, Apple ][ DOS 3.3, or MacOS prior to OSX (minus the GUI, and yes, that’s flamebait… go for it. I’ve owned all four).
I would say all of those are “monitors” more than “operating system”, but to each their own I suppose.
You forgot Apple II ProDOS and, of course, CP/M. Certainly CP/Ms before PC-DOS were “monitors”. I think you can blame the ambiguity to MS calling the Windows 3.11 Graphical shell, an “Operating System”. From then on marketers call anything they want an OS
Of course somebody would try to make this argument, but it’s clear what people mean in this context when they mean “no OS”.
For sure you can write a kind-of OS *with* Arduino :-)
But multi user / multi process is so has been :-)
There are thin environments like Ultibo (a Pascal environment for Raspberry Pi that has its own boot, runtime and kernel). These are probably operating systems by some definition. At least embedded environments.
Depending on how for define life, the Arduino is alive!
Johnny 5 … is alive!
Years ago, I was looking at a Ruby tutorial, and it occurred to me that not only was Ruby’s package manager similar to Python’s pip package manager, but both are similar to Debian’s apt and Fedora’s RPM, among other things.
I concluded that every language, to some extent or another, “wants” to be an operating system — and a little more reflection caused me to conclude that every operating system is a language.
Of course, if you have a good Forth implementation, you can have an interactive interpreter, compiler, editor, and so forth — in short, an operating system — that can easily fit in the RAM of a 2K Arduino.
So I am more than willing to consider Ultibo to be an OS (even if I can’t help but say “Pascal? Why did it have to be Pascal?”).
Agreed on your points that language and operating system are coupled. It’s more apparent in something like Forth or SmallTalk. But honestly environments that are conductive to programming end up look like BASIC on a home computer, Python REPL, or Erlang.
There are things from Pascal that I miss when I’m using C. but there are more things in C that I miss whenever I go back to Pascal.
I’d move onward to something “modern” like C++ or Rust, except they have too many things to know before it’s possible to understand a typical program.
Wait you want to boot the IDE without an os? The point here is being able to use an old PC as a dev board, not to avoid operating systems entirely. You would basically have to build or reuse an operating system to run the Arduino ide: not just have but also native compilers and linkers, firmware tools, etc.
The “no os” part just means you’re programming for the bare metal PC hardware, rather than being inside of and under an operating system. If you want code to run, you’ve got to either write it or link it in.
There is FreeRTOS port for DOS, which might be a nice addition. It might probably work even without DOS, but there is little to no overhead, since DOS does not have any kernel tasks or similar runtime components.
FreeRTOS is fully ported to x86 so there is no need to bother with DOS. There is also no need to bother with this if you merely install it in UEFI memory.
Next up, configuring the parallel port to act as gpio.
It can’t be hard to add an in/out 378/379/37a nn.
If it already beeps the speaker, most of the code is already there, not quite a case of replacing the 7 and updating the total size but not far off.
This would be pretty awesome. Although old PCs are becoming pretty hard to get your hands on these days. Saying that, depends on your definition of old.
Would this not work on a more modern pc? Aren’t modern pc fully X86-compatible anymore (at boot time?)
has nothing to do with X86 compatibility, rather than the printer port isnt directly connected to the CPU bus and hasn’t been for decades
Truly my greatest gripe with modern hardware. Let me at the guts!
It is most likely connected over (virtual) pci-e, but nonetheless hardware parallel ports still listen to the 37x IO port address
Compatible enough that inb / outb to 0x378 still works just fine.
https://github.com/LinuxCNC/linuxcnc/blob/master/src/hal/drivers/hal_parport.c#L377
(outb is wrapped in a thin layer here for conditonal compilation reasons)
In fact, how _else_ would you write to the parport?
In DOS? You write to the parallel port with BIOS Int 17H, of course :-/
Linux CNC parport compatible machines where hard to find 5 years ago. Don’t think that has improved.
Just to clarify a common misunderstanding. LinuxCNC does not require a parallel port. It still supports the parallel port as an option, as there has been no good reason to un-support it, but it isn’t a preferred option. Better results can be had my PCI, PCIe, and Ethernet-connected interfaces. (And, also, if you must, ISA and EPP-data)
And PCI/PCIe parallel ports do expose ECP/EPP grade I/O ports to the host.
Actually, it would work!… if it’s not the Intel chip made post-2020: https://superuser.com/questions/1519671/can-a-64-bit-computer-x86-run-a-16-bit-os-natively-without-emulation
64 bit port needed :-) !
I keep an old laptop with a parallel port for JTAG purposes, to access the 0x378 address.
Jean Thomas is actually a friend from the DirtyJTAG project, an stm32 firmware to build a JTAG USB cable.
Fun project, let’s see what people can do with it!
Don’t forget I2C. If you still have a VGA port I think there’s an I2C bus on that. Lots of expansion cards also use I2C internally that I suppose you could bodge a wire onto.
There is an I2C bus on the VGA, I bought this 328P PCB, never soldered it:
https://blog.atx.name/twilight-vga-i2c-breakout-board/
I really like this fun project, but:
> and there’s no operating system overhead to contend with
… aside from Arduino, which is way operating system overhead. Also, unlike, say, a FreeDOS program, you’re basically limited to writing code in the `loop` function; in a “proper” OS you don’t have to do that; servicing the hardware happens without you having to jump through these
lhoops.That’s actually a significant overhead, when you think about it, both in the developer mindspace as well as in the ability to reliably predict timing of your system.
That’s not to bash Arduino – it’s great for exactly the reasons stated in the article – but calling Arduino “low-overhead” is honestly not accurate.
> Your code has full control over the computer
aside from the parts that the `gcc -m16 -ffreestanding -fno-PIE -nostartfiles -nostdlib` compiled code has no access to (like, most of your RAM, PCIe devices, thus USB, basically everything the good ol’ BIOS emulation of your mainboard has no basic workflow for).
Yeah…if you’re worried about access to PCIe devices of all things, you really don’t get what the intent here is at all.
> > Your code has full control over the computer
>
> aside from the parts that the `gcc -m16 -ffreestanding -fno-PIE -nostartfiles -nostdlib`
> compiled code has no access to (like, most of your RAM, PCIe devices, thus USB,
> basically everything the good ol’ BIOS emulation of your mainboard has no basic
> workflow for).
If you use a USB keyboard, there’s a good chance your BIOS emulates plain old AT keyboard interface in SMM, running a USB stack in the background. And there’s a good chance ACPI/APM also steal CPU cycles from time to time.
So yeah, fuil control…
If your interest is in the “modern” toolchain, there are plenty of modern C implementations for DOS.
If your interest is Arduino on x86, there are already x86 boards with fuller Arduino support for their hardware (GPIO etc).
But I’m sure they solved some challenges, well done.
There might be some interest in adding IOs on a PC, either via the parallel port (which are gone from PCs), or via USB-GPIO dongles, via PCI cards, or vi
…or via serial ports (also gone from PCs).
Many PCs still have parallel ports. If not on the back panel then as a header on the motherboard.
Of 34 motherboards listed at http://www.mini-itx.com three have a back-panel parport and 3 have a motherboard header.
(The board-finder allows you to filter for them, presumably as there is still some limited demand)
Virtualized via the Super-IO chip on the LPC bus l, correct, and advertised to the operating system via BIOS plug and play?
Some parallel ports PCI cards could be accessed directly at 0x378, but it really depends on chip on there, I heard MOSCHIP was supporting that feature (needed for some JTAG software like OpenWRT’s HairyDairyMaid):
https://www.aliexpress.com/item/32818138665.html
That would be handy to have a list of those PCI cards that can be used for direct IO, including on Linux.
I have (for my sins) experimented with a number of PCI add-on cards and motherboard parallel ports.
So far every MB parallel port I have tried to access has responded to inb() and outb() on the advertised port. (I _think_ that they have all been at 0x378). PCI cards are more variable, some report an address to the system (visible in Linux with cat /proc/ioports or with lspci)
The exceptions seem to be the cards with a small chip towards the rear bottom. These seem to have a general-purpose IO chip that only becomes a patallel (or serial) port when a driver is downloaded into it at (Windows) boot time. I have had no luck achieving port-level access with those.
Do you have a CH351 based one in your stock?
You can find those PCI (which version of PCI I don’t know) for 6EUR on Ali.
Some people are discussing if they can be used for LinuxCNC, which might have the same requirements:
https://www.forum.linuxcnc.org/18-computer/27520-parallel-port-card-ch352-chip
https://forum.linuxcnc.org/forum/18-computer/18917-faq-pci-parallel-port-cards
The question is whether those PCI parallel cards with some WCH CH352 could be used for IO purposes:
https://www.forum.linuxcnc.org/18-computer/27520-parallel-port-card-ch352-chip
https://forum.linuxcnc.org/forum/18-computer/18917-faq-pci-parallel-port-cards
There is also a tester app here:
http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Parallel_Port_Tester
The first sentence of this article is só true.
I am not a good programmer and always have proboems setting up hardware, yet I had my first arduino (a digispark) set up and blinking a LED (including installing the IDE) within six minutes (which I remember as I was reheating some food in the microwave) – mentally I had prepared an evening to get up to this level, so that was a great win.
This is pretty cool. Whether or not you consider it easier or harder to develop x86 without DOS hardware servicing, it’s a great hack. I’d love to see someone do similar for 32bit protected mode using scanlime’s “metalkit” toolkit (which I think has a bootloader and basic setup routines).
It seems a really nice way to hack on ancient systems which have no more hard disk or exploitable media except a floppy and access bios configuration or low level hardware
I have an old 386 laptop which has a failed Conner CP2064 hard disk and will not accept something else, for which the bios setup was once done with system floppy that is now unobtainable… it would be pretty easy to peek at low level memory mapping and send a dump of the ROM to the serial port for being able to find the hard disk parameters and put a plan to boot DOS on another hard disk
Would definitely try this out if I was able to find some time :p
This is a really interesting project, especially because I still have at least five old PCs here with which I can test it.
This is bare metal Forth
This is all great except for the Arduino aspect of things. Just say “no” to Arduino.
You may want to try out PlatformIO with $3 nanos from china… hard to beat the price/performance/ease ratio…
Thanks but $2 32 bit ARM STM32 from China, along with gcc and Makefiles hits the sweet spot for me.
30 cents CH552 with USB are hard to beat, but you need a devboard around it:
http://zoobab.com/ch552g-blink
I made this for you ;-)
Absolutely AWESOME!
Now, make this for Raspberry PI ARM SOCs!
Wise idea, at least we could play with the GPIOs on there!
Is the generated code 16-, 32- or 64-bit? How much RAM can you access?
I can’t find the answers in the Readme file.
The generated code is 16-bits. The stack is hardcoded to 4096 bytes. You can tweak that in the linker script, but honestly if you need more RAM than that, it’s time to switch to something more serious ;-)
has anybody installed this on windows? I installed arduino and the only /hardware folder is C:\Program Files (x86)\Arduino\hardware. I put the Bootduino folder in there but it doesn’t seem to be available e.g. the examples don’t show up in file/examples.
I never got around to try it on Windows. One user did add instructions for it, but I’m not sure they tried it themselves.
This is brilliant. I’m gonna poke at it later and see if I can talk to the PATA port in PIO mode at 0x1f0. If I can bitbang those pins in addition to the parallel port at 0x3f8, that’s a ton of I/O bits already.