embedded linux primer

26
Embedded Linux primer Drew Fustini @pdp7 NERP meetup May-26-2014 Pumping Station: One (Chicago hackerspace)

Upload: drew-fustini

Post on 19-Jan-2017

573 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Embedded Linux primer

Embedded Linux primer

Drew Fustini@pdp7

NERP meetup May-26-2014Pumping Station: One (Chicago hackerspace)

Page 2: Embedded Linux primer

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

Page 3: Embedded Linux primer

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●

Page 4: Embedded Linux primer

Linux Foundation YouTube

● Emedded Linux Conference Europe, 2013● https://www.youtube.com/playlist?list=PLbzoR-pLrL6oxnDyb7IvnNOOBur7z_8tE

● Much more!

Page 5: Embedded Linux primer

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

Page 6: Embedded Linux primer

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

Page 7: Embedded Linux primer

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! :)

Page 8: Embedded Linux primer

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

Page 9: Embedded Linux primer

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

Page 10: Embedded Linux primer

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

Page 11: Embedded Linux primer

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]

Page 12: Embedded Linux primer

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!

Page 13: Embedded Linux primer

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)

Page 14: Embedded Linux primer

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

Page 15: Embedded Linux primer

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

Page 16: Embedded Linux primer

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/

Page 17: Embedded Linux primer

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/●

Page 18: Embedded Linux primer

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

Page 19: Embedded Linux primer

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

Page 20: Embedded Linux primer

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

Page 21: Embedded Linux primer

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

Page 22: Embedded Linux primer

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

Page 23: Embedded Linux primer

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)

Page 24: Embedded Linux primer

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.”

Page 25: Embedded Linux primer

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!

Page 26: Embedded Linux primer

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.