embedded linux primer
TRANSCRIPT
Embedded Linux primer
Drew Fustini@pdp7
NERP meetup May-26-2014Pumping Station: One (Chicago hackerspace)
Embedded Linux Conf (ELC)
● Annual event, 1 in N. America, 1 in Europe● I attended ELC in San Jose in April● http://events.linuxfoundation.org/events/embedded-linux-conference● Kernel subsystem maintainers, engineers from
manufacturers putting Linux on their devices, embedded development consultants, etc
ELC videos & slides!
● Awesome archives of videos and slides● 2014 Audio:
– http://events.linuxfoundation.org/events/embedded-linux-conference/program/slides
● 2014 Slides:– http://events.linuxfoundation.org/events/embedded-linux-conference/program/slides
● 2014 Videos: TBD– http://elinux.org/ELC_2014_Presentations
● Past events: http://elinux.org/Category:Events●
Linux Foundation YouTube
● Emedded Linux Conference Europe, 2013● https://www.youtube.com/playlist?list=PLbzoR-pLrL6oxnDyb7IvnNOOBur7z_8tE
● Much more!
General Linux Kernel learning
● Linux Kernel Development (3rd Edition) Paperback, by Robert Love
● http://www.amazon.com/Linux-Kernel-Development-3rd-Edition/dp/0672329468/ref=pd_sim_b_1?ie=UTF8&refRID=0RYJ0S0P477SF6XZ5K99
More general Linux kernel
● Linux Kernel Newbies– http://kernelnewbies.org/
– Kernelnewbies is a community of aspiring Linux kernel developers who work to improve their Kernels and more experienced developers willing to share their knowledge.
– Kernelnewbies can be found on the MailingList, IRC (irc.oftc.net #kernelnewbies), the web forum and this wiki.
● OPW: Linux Foundation Out Reach Program for Women– latest project QR code for kernel crash screen a.k.a. “oops”
● https://www.linux.com/news/featured-blogs/200-libby-clark/773488-opw-intern-develops-qr-code-for-linux-kernel-oops-messages
Staying up to date
● LWN.net: Linux Weekly News– General, Security, Kernel, Distros, Dev, Annoucements
● Covers happenings in the kernel dev mailing lists, etc, every week
● New issues are Subscribers-only for 1st week, after 1 week, free
● Totally worth $$$ (kernel mailing lists way over >1,000/week emails)
● https://lwn.net/ <--- go there! :)
Linux Architectures for Embedded
● Kernel requires MMU: memory management unit– (technically there is support for MMU-less but more
complicated)
● PowerPC: very popular historically● ARM: enormous variety; currently mostly Cortex-A series
for Linux systems; 64-bit now introduced● Intel 64-bit x86: Atom “Baytrail” is much more exciting
than past Atom SoCs● Intel Quark: 32-bit x86 “pentium-class”... will have to see
what Intel does with it
New architectures
● Not really embedded, but interesting chip from ELC 2014: Kalray 256-cores
● http://www.kalray.eu/● PDF “Porting Linux to new Architecture”:
– http://elinux.org/images/5/50/Rybczynska_Porting_Linux_to_a_new_architecture_ELC2014.pdf
Single Board Computers
● There's so many awesome boards!● Fav SBC news sites:
– http://linuxgizmos.com/
– http://www.cnx-software.com/
● Linux.com/Linux Gizmo survey list 30+ SBCs:– http://linuxgizmos.com/rate-your-favorite-open-single-board-computers/
*my rant about why it is unfortunate they created new loosely defined term “open spec” as the qualifier for their survey
Popular SoCs in SBCs
● Allwinner: ARM Cortex A based SoCs in large variety, cheap cus produced in HUGE volume in China for commodity tablets and phones– Olimex OlinuXino a great way to get into Allwinner:
● https://www.olimex.com/Products/OLinuXino/open-source-hardware● Dual-core A20 (ARM Cortex A7):
https://www.olimex.com/Products/OLinuXino/A20/● Maintained in mainline kernel by Free Electrons:
http://elinux.org/images/3/31/Ripard-mainlining-out-of-tree-socs.pdf [PDF]
More SoCs
● Freescale iMX.6: Cortex A9, up to quad-core, good mainline Linux support– WandBoard: http://www.wandboard.org/
– Udoo: http://www.udoo.org/
– My new laptop! Novena open source hardware laptop: quad iMX.6, 4GB RAM, FPGA, SDR & more; raised over $700,000; bare SBC is $500 https://www.crowdsupply.com/kosagi/novena-open-laptop
● TI OMAP (BeagleBoard), TI Sitara (BeagleBone), Broadcom BCM2835 (RPi), and many many more!
Device Tree
● All these ARM devices like phones, tablets, etc, with many variations of System-On-Chips (SoCs) adds clutter to Linux
● No common hardware layer like PC BIOS, ACPI, UEFI
● Linus says: stop adding new C source code (“board files”) for every new SoCs (there's tons and usually short-lived)
Device Tree
● The solution is to use Device Tree which is a data structure
● Describes the hardware resources of a given device
● Ideally OS agnostic● Ideally stable but lots of growing pains
currently
Many great talks on it!
● Device Tree for Dummies– Thomas Petazzoni, Free Electrons
– PDF: http://elinux.org/images/f/f9/Petazzoni-device-tree-dummies_0.pdf
– Video: https://www.youtube.com/watch?v=m_NyYEBxfn8&list=PLbzoR-pLrL6oxnDyb7IvnNOOBur7z_8tE&index=19
BeagleBone Black leading the way
● First SBC to take take on Device Tree● Jason Kridner: “paying the device tree tax
early”● Great article about how BeagleBone Black
handles itself, capes and Device Tree:http://elinux.org/BeagleBone_and_the_3.8_Kernel
● Adafruit has nice tutorial as well: http://www.adafruit.com/blog/2013/07/29/tutorial-introduction-to-the-beaglebone-black-device-tree/
●
Linux Kernel Development
● I believe the largest collaborative software project in history● Main website: https://www.kernel.org/● Mainline: current version under development
– This is Linus Torvalds tree (aka branch)
● Current Stable and long term support releases, used by distros, etc, to help keep things sane
● Kernel dev done in Git (which Linus created, kernel.org is its own Git server, though various folks have their own Linux trees aka branches on other services like GitHub)
● LWN.net is awesome! https://lwn.net/●
Real Time Linux
● Several different approaches to this● Real Time means predictable, not fast
– “No Suprises”
● Soft real-time: ok to miss some deadlines, such as video and audio
● Hard real-time: not ok to ever miss deadline, such as servo controller for airplane wing
● Linux can only ever do Soft Real-Time as it's just to darn complex
Real Time patch to the Kernel
● https://rt.wiki.kernel.org/index.php/Main_Page● "Controlling a laser with Linux is crazy, but
everyone in this room is crazy in his own way. So if you want to use Linux to control an industrial welding laser, I have no problem with your using PREEMPT_RT." -- Linus Torvalds
● Video: “Embedded Linux Conference 2013 - Inside the RT Patch”https://www.youtube.com/watch?v=n9ucTGWrON8
More Real Time Linux
● Uses for real-time:– MachineKit: LinuxCNC for BeagleBone Black
● http://blog.machinekit.io/p/machinekit_16.html
● Awesome Podcast:– https://linuxlink.timesys.com/3/podcast– Episode 16: Real-Time Embedded Linux Series — Part 3– Episode 15: Real-Time Embedded Linux Series — Part 2– Episode 14: Real-Time Embedded Linux Series — Part 1
Compile your own kernel
● General Kernel:– http://kernelnewbies.org/FAQ/KernelCompilation
● BeagleBone kernel for Debian by Robert C Nelson– https://github.com/RobertCNelson/stable-kernel
– https://github.com/RobertCNelson/linux-dev
– Build Kernel Image: ./build_kernel.sh
– Optional: Build Debian Package: ./build_deb.sh
– Install Kernel Image to SD card: (requires MMC set in system.sh): ./tools/install_kernel.sh
– Install Kernel Image to local system (kernel was built on ARM board): ./tools/local_install.sh
Beyond the Linux kernel
● We need a root filesystem to boot from● We need programs (aka packages)● We may need additional storage / filesystems● We may need to generate a filesystem image
for easy download and deployment
Building our system
● Buildroot: “Buildroot is a simple, efficient and easy-to-use tool to generate embedded Linux systems through cross-compilation.” http://buildroot.uclibc.org/
● OpenEmbedded: build framework for Linux http://www.openembedded.org/wiki/Main_Page– Uses BitBake (next slide)
– Evolved from OpenZaurus (for the Sharp PDA)
More build systems
● Yocto Project:– “Sponsored by the Linux Foundation, the Yocto Project is more than a
build system. It provides tools, processes, templates and methods so developers can rapidly create and deploy products for the embedded market”
– https://www.yoctoproject.org/
● Poky: “One of the core components of the Yocto Project is the Poky Build system”
● BitBake: “BitBake is a Gentoo-Portage-inspired build tool, used by both the Yocto Project and OpenEmbedded communities to utilize metadata to create Linux images from source.”
So many names, so confusing!
● Read this!– The Yocto Project by Elizabeth Flanagan
– http://aosabook.org/en/yocto.html
– From the free online book ● The Architecture of Open Source Applications● http://www.aosabook.org/en/index.html● Buy real copy and support author!
Awesome Podcast
● LinuxLink Radio - Podcasts for Embedded Linux Developers https://linuxlink.timesys.com/3/podcast
● LinuxLink Radio is a podcast geared towards developers of embedded Linux. Host Maciej Halasz discusses a wide range of embedded Linux topics. This podcast features commentary on common issues, guest interviews, featured LinuxLink projects, embedded Linux news and email from our listeners.