12

I am new to kernel and embedded Linux. I have recently bought a Raspberry Pi and booted it using the Raspbian. I was fascinated by the Pi, to learn more on Embedded I have decided to make an home automation system. I wanted to use my own kernel, and stack. ie I don't want to use any of the OS.

For that I have download Kernel, target_fs, firmware, and tool-chain from the official github. I have compiled the kernel using the tool-chain.

Now I don't know how to put this to a new sdcard (formatted for a fresh start). What all things I have to take care before booting my stack? Since I have not put ssh or telnet server/Client, how can i know the boot was successful. Where can I get a ssh/telnet daemon for the pi? My aim is to boot only the kernel(or bare minimum) in the Raspberry Pi.

4
  • 2
    This is a herculean task and I don't think you have enough experience yet. Considered just adjusting an existing distribution and save 99% of the time? Jan 9, 2014 at 7:16
  • I had the same problem. I created a collection of shell scripts, for exactly that purpose. dettus.net/detLFS Aug 7, 2016 at 19:52
  • 1
    I realize this is a bit old, however I recently learned about MLL, which is another way to build a minimal Linux os. As a Linux neophite myself I found MLL instrumental in learning the process. I am currently researching the process by which to include the Raspberry Pi drivers in the build. MLL minimal.linux-bg.org/#home Best of luck!
    – Rob
    Feb 18, 2018 at 2:25
  • Here ten years after, a Pico would probably have been a much better starting point Apr 3 at 3:51

3 Answers 3

10

The kernel expects two things: a root filesystem, and an init daemon that resides on it. The init included with raspbian is a sysV style system. You are not tied to that -- other init systems commonly used with linux (remember: the kernel is linux) are systemd and upstart -- but you do need an init system of some sort.

You can also put init in an initramfs and have it built into the kernel, in which case you could get away without a root filesystem, but that seems pointless in this case.

init is the only userland application started by the kernel. Normally, it then starts processes which open ttys with a login, and then other services that may start a display manager, sshd, etc. You may not need the login, but you probably want the tty; you could also just start sshd directly instead.

Where can i get a ssh/telnet daemon for the pi?

Get it from the same place raspbian did, the upstream source. None of this stuff was written specifically for the pi. Or at least, very very little of it. It's been used on a huge variety of different systems.

If you want one pre-compiled for the pi...well, that's raspbian, etc.1

i don't know how to put this to a new sdcard

You'll have to use the pi-specific bootloader which is in the /boot partition of the raspbian image.


1. To be brutally honest, I think you are on a massively quixotic quest that, based on the knowledge implied by your question, you have virtually no hope of accomplishing this year unless you quit your job and devote yourself to learning full time, and even then your chance of failure is very high and it will take you months to reach a point where you have any chance of success. It is not simple. It is not easy. That said, even if you do fail, you will probably learn some useful things along the way. However, the time might be better spent learning to understand an existing distribution (such as raspbian) and how to use it to create your home automation system.

1
  • 1
    quixotic? You're one of the only people I know who routinely challenge my vocabulary. +1 for that alone.
    – Jacobm001
    Jan 14, 2016 at 4:48
7

For just getting started, I think you have the wrong concept of using embedded computers (especially at the Raspberry Pi level). If you really want to build a custom OS I suggest you start at Linux from Scratch, LFS, http://www.linuxfromscratch.org/ but if you want to understand embedded computing start by Googling "embedded systems", Wikipedia, or Embedded Linux Wiki http://elinux.org/Main_Page.

1
  • 1
    +1 for LFS. I'd want to do that in a cross-compile setting though!
    – goldilocks
    Jan 8, 2014 at 16:23
0

The LFS (Linux From Scratch) project is the best go-to resource for building a custom Linux distro from source code on an Intel style x86/x86-64 architecture. Pi LFS Has the up to date modifications and instructions for building on ARM.

When building a custom Linux image on any target architecture, you usually start with an existing image, make a new partition on your drive, and from the existing os, download and build the new image on to the new partition. Finally you cross your fingers and try booting into the new partition. If everything boots and runs as expected you can package up the new os image, delete the old os/partition, or generally use as desired.

This is true for the Raspberry pi. You start by booting in to Raspban on your Pi, make a new partition on the SD card, download/build the new OS, and try rebooting in to the new partition. This can all be done via GUI on the Pi, or via a headless SSH session, but the actual build is done entirely on the Pi. Depending on your internet connection, size of the new build, and RPi model this usually takes anywhere from 5-20 hours.

Building without any existing os (like when inventing a brand new chip architecture) is a real pain, and rather advanced stuff. It requires cross compiling and flashing to your chip using specialty hardware. If you want to learn more, start by learning basic bare-mettle AVR programing using an Arduino Uno and the AVRDude compiler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.