1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com ELC 2009 System Size BOF Michael.

Slides:



Advertisements
Similar presentations
Algorithms and data structures
Advertisements

Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
Presented by: GREG UNGERER Lineo Inc 825 Stanley St Woolloongabba Qld 4102 Australia Ph: Building x86 Based.
Internet of Things with Intel Edison Presentation Paul Guermonprez Intel Software
ESE Einführung in Software Engineering N. XXX Prof. O. Nierstrasz Fall Semester 2009.
Metamodeling Seminar X. CHAPTER Prof. O. Nierstrasz Spring Semester 2008.
ESE Einführung in Software Engineering X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
CP — Concurrent Programming X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
12. eToys. © O. Nierstrasz PS — eToys 12.2 Denotational Semantics Overview:  … References:  …
Embedded Systems Programming Introduction to the course.
Introduction to The Linaro Toolchain Embedded Processors Training Multicore Software Applications Literature Number: SPRPXXX 1.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Chocolate Bar! luqili. Milestone 3 Speed 11% of final mark 7%: path quality and speed –Some cleverness required for full marks –Implement some A* techniques.
Computing Hardware Starter.
Enabling the ARM Learning in INDIA ARM DEVELOPMENT TOOL SETUP.
Seminar on Linux-based embedded systems
Internet of Things with Intel Edison Compiling and running Pierre Collet Intel Software.
Copyright 2001 Oxford Consulting, Ltd1 January Storage Classes, Scope and Linkage Overview Focus is on the structure of a C++ program with –Multiple.
Beagle Board Fast Boot Hui Chen Keji Ren Dec 10 th, 2009 EE382N-4 Project.
Exploring Suitability of Linux for Embedded Vision Applications Ankit Mathur Mayank Agarwal Mini Project.
CELF Project and Conference Information Tim Bird CELF Architecture Group Chair.
Unit - VI. Linux and Real Time: Real Time Tasks Hard and Soft Real Time Tasks Linux Scheduling Latency Kernel Preemption Challenges in Kernel Preemption.
Porting Linux Linux onto the Puppeteer SA1110. The Puppeteer board –SA1110 CPU –SMSC LAN91C96I ethernet –8 Mb Flash Intel 28F320C3 Boot block flash –32.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
CHAPTER 3-1, 3-2 MEMORY MANAGEMENT. MEMORY HIERARCHY Small amount of expensive, fast, volatile cache Larger amount of still fast, but slower, volatile.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
Implementation Method Linux-USB Gadget Framework –The Linux-USB Gadget Framework makes it easy for peripherals and other devices embedding GNU/Linux system.
The World Leader in High Performance Signal Processing Solutions Toolchain Basics.
Installing Linux: Partitioning and File System Considerations Kevin O'Brien Washtenaw Linux Users Group
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Free Electrons Introduction.
Linux on ARM7TDMI or Nothing is as easy as it looks Helicon technologies Ltd. How to run uClinux on NXP LPC22xx.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Embedded Linux system development.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com The GRUB bootloader Michael.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Embedded Linux system development.
1 ARM Linux specifics © Copyright , Free Electrons Creative Commons Attribution-ShareAlike 3.0 license 9/28/2016 ARM.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Free Electrons Linux kernel.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Scratchbox The Scratchbox.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Block filesystems Michael.
Michael Opdenacker Linux Tiny Linux-Tiny - The diet must go on Michael Opdenacker Free Electrons
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com SSH Thomas Petazzoni Free.
1 Kernel development with VirtualBox © Copyright 2009, Marco Stornelli Creative Commons Attribution-ShareAlike 3.0 license 9/30/2016 Linux development.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Participate! During the lectures...
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com TI OMAP 3530 power management.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Block filesystems Michael.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com The U-boot bootloader Michael.
The GRUB bootloader Michael Opdenacker Thomas Petazzoni Free Electrons
Lecture 3 Translation.
Ottawa Linux Symposium 2007
© 2002, Cisco Systems, Inc. All rights reserved.
CELF Embedded BOF - Ottawa - July 2008
Using USB gadget drivers
From Monoprogramming to multiprogramming with swapping
Porting U-boot Michael Opdenacker Free Electrons
Software Development with uMPS
The blob bootloader Thomas Petazzoni Free Electrons
Linux device driver development
Penguin Weight Watchers
Embedded Linux Conference - April 2009
Many-core Software Development Platforms
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Compiler Construction
Page Replacement.
Chapter 2: The Linux System Part 1
IS3440 Linux Security Unit 7 Securing the Linux Kernel
2.C Memory GCSE Computing Langley Park School for Boys.
Introduction to Computer Systems
Lecture 4: Instruction Set Design/Pipelining
SPL – PS1 Introduction to C++.
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Presentation transcript:

1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com ELC 2009 System Size BOF Michael Opdenacker Free Electrons

2 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Rights to copy Attribution – ShareAlike 3.0 You are free to copy, distribute, display, and perform the work to make derivative works to make commercial use of the work Under the following conditions Attribution. You must give the original author credit. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. License text: © Copyright , Free Electrons Document sources: Updates on size reduction techniques can be found on Corrections, suggestions, contributions and translations are welcome! Latest update: 10/2/2016

3 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com 24 slides... To avoid a tragic increase in the size of your system.

4 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Why system size matters Because Linux wouldn't fit otherwise To leave more space for user data (media players) To keep things easier to maintain Lighter code is faster to boot We should stop size growth because we don't want to force people to use old kernels and old software.

5 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Linux Tiny achievements Merged features: [x86] use ELF section to list CPU vendor specific code [x86] configurable DMI scanning code [mm] directly use kmalloc() and kfree() in init/initramfs.c [x86] consolidate the definition of the force_mwait variable inflate: refactor inflate malloc code fs/buffer.c: uninline __remove_assoc_queue() [x86] make movsl_mask definition non-CPU specific [x86] move cmpxchg fallbacks to a generic place [x86] configuration options to compile out x86 CPU support code Configure out file locking features Configure out AIO support [PCI] allow quirks to be compiled out [x86] remove PC speaker code Work on multicast and ethtool configurability. Not merged yet. Implemented by Free Electrons, funded by CELF

6 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Linux Tiny status The diet must go on... Stopped maintaining the patches Merge them or let them bitrot! But the kernel continues to grow... Unavoidable progress of fate?

7 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Bloatwatch report Source code:

8 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com x86 kernel size example Still growing compiled with gcc 3.4! (beware of compiler artifacts!)

9 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com With and without CONFIG_EMBEDDED Same testcase. Also tested! Raw: -272 KB (-17%), Compressed: -136 KB (-20%)

10 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Linux Tiny ideas Reduced /proc Remove unused code when using a RAMFS: readahead, swapping, pdflush (compiled unconditionally) Just look at which files get compiled! You will find things you probably don't need. How to find kernel functions that are never executed? What about using ftrace to find them (good idea to explore). Move all debugging interfaces to debugfs Your ideas?

11 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Kernel size, really an issue? Still growing much slower than Moore's Law (which flash storage is supposed to follow). But perhaps still an issue for boot time: A smaller kernel takes less time to copy to RAM Keeping the kernel simpler also helps: less unused subsystems to initialize.

12 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Compressed filesystems (1) Great solutions to reduce system size, available in the latest kernels: UBIFS: compressed filesystem for flash (MTD) storage. Like JFFS2, but without the poor performance. Available since Linux SquashFS: lightning fast filesystem, perfect for all the parts of the root filesystem which can be kept read-only. Available since Linux See my presentation on flash filesystems tomorrow (11:00 am, Imperial A)

13 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Compressed filesystems (2) Hey, what about block storage (USB flash drives, SSD)?? Read-only: use Squashfs What solutions for read-write partitions? Does anyone use the FUSE based solutions? Any other suggestion?

14 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Compiler switches Standard -Os option. Supported for compiling Linux -funit-at-a-time Made gcc do a much better job of inlining and dead code removal. No longer does anything according to gcc's manual. -fwhole-program --combine Equivalent to grouping all source files and making all variables static. Not longer offered in BusyBox options. What happened? -mregparm=3 Seems to be x86 specific. Instructs the compiler to use registers for the first three function arguments. See for all available switches.

15 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Use a lighter C library glibc: approximately 2 MB in size uClibc good (usually < 500 KB). but often behind glibc in terms of features (floating point support, RT support...) eglibc

16 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com eglibc « Embedded glibc », under the LGPL Variant of the GNU C Library (GLIBC) designed to work well on embedded systems Strives to be source and binary compatible with GLIBC eglibc's goals include reduced footprint, configurable components, better support for cross-compilation and cross-testing. Can be built without support for NIS, locales, IPv6, and many other features. Supported by a consortium, with Freescale, MIPS, Montavista and Wind River as members.

17 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Need for stripping Compiled executables and libraries contain extra information which can be used to investigate problems in a debugger. This was useful for the tool developer, but not for the final user. To remove debugging information, use the strip command. This can save a very significant amount of space! gcc -o hello hello.c (output size: 4635 bytes) strip hello (output size: 2852 bytes, %) Don't forget to strip libraries too!

18 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Are my executables stripped? You can use the file command to get the answer gcc -o hello hello.c file hello hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped strip hello hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped You can use findstrip ( to find all executables and libraries that need stripping in your system.

19 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com How to strip Some lightweight tools, like busybox, are automatically stripped when you build them. Makefiles for many standard tools offer a special command: make install-strip Caution: stripping is architecture dependent. Use the strip command from your cross-compiling toolchain: arm-linux-strip potato

20 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com sstrip: “super strip” Goes beyond strip and can strip out a few more bits that are not used by Linux to start an executable. Can be used on libraries too. Minor limitation: processed libraries can no longer be used to compile new executables. Can also be found in toolchains made by Buildroot (optional) Best for tiny executables !

21 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Library Optimizer Contributed by MontaVista Examines the complete target file system, resolves all shared library symbol references, and rebuilds the shared libraries with only the object files required to satisfy the symbol references. Can also take care of stripping executables and libraries. However, requires to rebuild all the components from source. Would be nicer to achieve this only with ELF manipulations. Anyone using it?

22 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com ARM Thumb (1) Size gains on a small, non-representative example 28 bytes reduction, 22% code size reduction int bar(int c, int d) { return c + d; } int foo(int a, int b) { a += 3; b -= 2; return bar(b, a); } arm-linux-gcc -c arm-linux-gcc -c -mthumb test.arm.o test.thumb.o $ sizediff test.arm.o test.thumb.o text data bss dec hex filename c test.arm.o test.thumb.o C +/-

23 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com ARM Thumb (2) Interworking: possible to mix ARM and Thumb code: ARM for performance critical code Thumb for code which size matters. See for details about how to generate and use Thumb code. Anyone using this? Thumb2: allows to get almost the same performance as ARM code, with almost the same size as Thumb. No longer requires code switching. Anyone having tried Thumb2? Already supported by gcc since Support for userspace Thumb2 included in Linux

24 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Questions Since you're here, size should be a concern to you Why? What's biggest in your system? New techniques not listed here?

25 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Resources rm -r * ;-)