Compile your own – embedded linux – distro



Compile your own – embedded linux – distro

0 0


embedded_linux_distro

Build your own embedded linux distribution for fun and profit!

On Github davisRoman / embedded_linux_distro

Compile your own

embedded linux

distro

*For fun and profit*

Compile your own

(super simple)

embedded linux

distro

*For fun and profit*

Basically all we want is a shell

No seriously, all we want is a

(login) shell

A lot of moving parts are required

just to get to this point...

oh! And we'll be compiling for this...

using...

and then afterwards, we'll talk about...

Bartendro

A Raspberry pi powered Cocktail Dispensing Robot

Sorry, maybe next month...

Who am I?

Agenda

  • Introduction/Motivation ✔
  • What is embedded linux?
  • What is a distribution?
  • Toolchains and cross compilation
  • Raspberry pi
  • What is buildroot?
  • Profit!

What is embedded linux?

Embedded linux is the usage of the linux kernel and various open-source components in embedded systems. Typically requires a processor with a memory management unit ( MMU ) but not always.

What is an embedded system?

An embedded system is a computer system with a dedicated function within a larger mechanical or electrical system, often with realtime computing constraints

Agenda

  • Introduction/Motivation ✔
  • What is embedded linux? ✔
  • What is a distribution?
  • Toolchains and cross compilation
  • Raspberry pi
  • What is buildroot?
  • Profit!

So what is a linux distribution?

A Linux distribution may be described as a particular assortment of application and utility software, packaged together with the Linux kernel in such a way that its capabilities meet the needs of end users. --wikipedia
"...capabilities meet the needs of end users."

Distrowatch.com

Keeps track of top 100 actively used distros

Top 4 distros ( according to page hit ranking )

Each distro satisfies a particular set

of requirements

But since we'll be focusing on raspberry pi

the following are more appropriate:

raspbian, pidora,openelec, openbmc

What makes these distros better suited

than those available on distrowatch

  • Compiled for the correct processor architecture
    • Raspberry pi uses an ARM11 microarchitecture with ARMv6 instruction set
    • Doesn't mean you can't compile the other ones but then again how much time are you willing to burn
  • Requires less resources to run
    • Available ram: 512 MiB ( B+ )
    • Onboard CPU: 700 MHz ARM11 ARM1176JZF-S core
  • Bells and whistles are not included by default
    • Desktop environment probably won't be enabled by default (May not be installed at all)
  • Heavily rely on package management system to add as you go
    • apt-get install
    • opkg

Why choose a binary distribution when you can

compile one yourself?

  • Add whatever packages and configs you wish

  • Hack the kernel in whatever god awful way you see fit

  • Add extra kernel modules just because you feel like it

  • Bend init/util scripts to your will

  • Replace the init system with something better

  • Name your creation whatever you wish

  • Share it to the world. Sit back and revel in your brilliance

Software Components

  • Cross-compilation toolchain
    • Compiler that runs on the development machine, but generates code for the target
  • Bootloader
    • Started by the hardware, responsible for basic initialization, loading and executing the kernel
  • Linux Kernel
    • Contains the process and memory management, network stack, device drivers, and provides services to user space applications
  • C library
    • The interface between the kernel and user space applications
  • Libraries and applications
    • Third-party or in-house

Architecture

Agenda

  • Introduction/Motivation ✔
  • What is embedded linux? ✔
  • What is a distribution? ✔
  • Toolchains and cross compilation
  • Raspberry pi
  • What is buildroot?
  • Profit!

Compilation

Compilation #2

Toolchains

Agenda

  • Introduction/Motivation ✔
  • What is embedded linux? ✔
  • What is a distribution? ✔
  • Toolchains and cross compilation ✔
  • Raspberry pi
  • What is buildroot?
  • Profit!

Raspberry Pi

  • Low cost, credit card sized computer that plugs into a computer monitor or TV and uses a standard keyboard and mouse.
  • It enables people of all ages to explore computing and to learn how to program in languages such as Scratch and Python
  • Eben Upton
    • Technical Director and ASIC architect for Broadcom.
    • Founder of the Raspberry Pi Foundation

Agenda

  • Introduction/Motivation ✔
  • What is embedded linux? ✔
  • What is a distribution? ✔
  • Toolchains and cross compilation ✔
  • Raspberry pi ✔
  • What is buildroot?
  • Profit!

Buildroot

  • Set of makefiles and patches that make it easy to generate complete embedded linux systems
  • Able to generate:
    • cross-compilation toolchain
    • a root filesystem
    • a kernel image
    • a bootloader image
  • Useful for creating small systems using various CPU architectures (x86, ARM, MIPS, POWERPC, etc )
  • Automates the build process of your embedded systm

rpi-buildroot

building

 # git clone --depth 1 git://github.com/gamaral/rpi-buildroot.git
 # cd rpi-buildroot
 # make raspberrypi_defconfig  # Grabs default config for Raspberry Pi
 # make                        # Start the build process
                 
  • Use 'make menuconfig' to modify what is included in your distro
  • Build time is a function of cpu speed and # of cores
    • i7 8-core 5960X with 32GB of ram -> 11 minutes
    • i5 2-core with 4GB of ram -> 59 minutes
    • Your results may vary

buildroot output

Comes with convenient SD card generator tool

Boot your board & Profit!

Thank you !