For projects using a small GNU/Linux system, it’s often important that certain code always be running when the computer is on. You can always log in and start a script running by hand once you turn on the power, but this isn’t very reliable – after all, the power might flicker, or the system might crash for unrelated reasons.
On an Arduino or similar device, the code you write usually just runs shortly after the power comes on, courtesy of a bit of software called a bootloader. Linux systems have these too, but what runs by default is the kernel, which in turn runs something known as an init system that’s in charge of starting all sorts of other software to provide important services.
First, we’ll check out SysV-style init on a Raspberry Pi 2. With roots dating back to early Unix systems, sysvinit was widely used on most Linux distributions until recently, and is still used by the version of Raspbian released in May of 2015, based on Debian Wheezy. It’s also similar to mechanisms still used by the BSD branch of the Unix family tree.
Next, we’ll look at systemd on a BeagleBone Black running Debian Wheezy with systemd. systemd is “a suite of basic building blocks for a Linux system”, recently adopted by most of the major distributions, including Debian Jessie (the current stable release of the project). Eventually, Raspbian will probably run systemd too.
This one just barely scratches the surface of a pretty convoluted topic, and might need extensive updates in future, but hopefully it’s enough to get you going for the simple case. Check it out and let us know what you think.
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.