1 / 74

Embedded Computer Linux OS porting

Embedded Computer Linux OS porting. TungPT. Training objectives. Aafter this lecture you’ll able to: Know more about linux bootloader Know more about linux kernel Know more about linux file system Basic Steps to build linux system. Learning approach.

hayes
Télécharger la présentation

Embedded Computer Linux OS porting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Embedded ComputerLinux OS porting TungPT

  2. Training objectives • Aafter this lecture you’ll able to: • Know more about linux bootloader • Know more about linux kernel • Know more about linux file system • Basic Steps to build linux system

  3. Learning approach • The following are strongly suggested for a better learning and understanding of this course: • Noting down the key concepts in the class • Analyze all the examples / code snippets provided • Study and understand the self study topics • Completion and submission of all the assignments, on time • Completion of the self review questions in the lab guide • Study and understand all the artifacts including the reference materials / e-learning / supplementary materials specified • Completion of the project (if application for this course) on time inclusive of individual and group activities • Taking part in the self assessment activities • Participation in the doubt clearing sessions

  4. Type of Host • Unix workstation • Linux workstation • Window workstation

  5. Development Setups - Linked Setup • the target and the host are permanently linked together using a physical cable • no physical hardware storage device is being transferred between the target and the host

  6. Removable Storage Setup • Using removable storage instead of physical cable • a storage device is written by the host, is then transferred into the target, and is used to boot the device.

  7. Standalone Setup • the target is a self-contained development system and includes all the required software to boot,operate, and develop additional software

  8. Tool chain(1) • The usual development tools available on a GNU/Linux workstation is a native toolchain • This toolchain runs on your workstation and generates code for your workstation, usually x86 • For embedded system development, it is usually impossible or not interesting to use a native toolchain • The target is too restricted in terms of storage and/or memory • The target is very slow compared to your workstation • You may not want to install all development tools on your target. • Therefore, cross-compiling toolchains are generally used. They run on your workstation but generate code for your target.

  9. Tool chain(1) x86 Source code Compilation machine Native toolchain (GCC, G++….) Cross-compiling Toolchain (ARM-linux-gcc….) x86 ARM X86 binary ARM binary Execution machine

  10. Tool chain's components Binutils Kernel headers C/C++ libraries GCC compiler GDB debugger (optional)

  11. Building a toolchain • Three machines must be distinguished when discussing toolchain creation • The build machine, where the toolchain is built. • The host machine, where the toolchain will be executed. • The target machine, where the binaries created by the toolchain will be executed. • Four build types are possible

  12. Building a toolchain (2) build host target build host target Cross build used to build a toolchain that runs on your workstation but generates binaries for the target Native build used to build the normal gcc of a workstation The most common solution in embedded build host target build host target Canadian build used to build on architecture A a toolchain that runs on architecture B and generates binaries for architecture C Cross-native build used to build a toolchain that runs on your target and generates binaries for the target

  13. Basic steps • Extract and install kernel headers • Extract, configure, compile and install binutils • Extract, configure and compile a first version gcc that generates binaries for the target. It will be used to cross-compile the C library. • Extract, configure and compile the C library using the previously generated compiler. • Re-configure and compile the final gcc cross-compiler.

  14. Get a precompiled toolchain • Solution that most people choose, because it is the simplest and most convenient solution • First, determine what toolchain you need: CPU, endianism, C library, component versions, ABI, soft float or hard float, etc. • Many pre-compiled toolchains are freely available: • CodeSourcery, http://www.codesourcery.com, is a reference in that area, but they only provide glibc toolchains.

  15. Installing and using a precompiled toolchain • Follow the installation procedure proposed by the vendor • Usually, it is simply a matter of extracting a tarball at the proper place • Toolchains used not to be relocatable!You must install them in the location they were built for. • This is no longer true with gcc 4.x, thanks to sysroot support, but it is still more convenient to install them at the proper place. • Then, add the path to toolchain binaries in your PATH:export PATH=/path/to/toolchain/bin/:$PATH

  16. The Bootloaders

  17. What is a Bootloader? • Simply, a loader (program), which boot (starts) up the system. • A Customized program started by • Controller’s internal code in embedded System • Or, External Pre-programmed Code (like BIOS) in Desktop machines

  18. Task of bootloader • Initialization Tasks • Memory Setup & Initialization • System Peripheral Initialization for the kernel • Actual Task • Load the RAM-based File System, like initrd, initramfs… • Load the kernel with proper arguments • Jump the the start of the kernel • Additional Task • Multi-kernel boots • Multi-way boots

  19. Design of bootloader • A Bootloader is started by a fixed code • It needs to be placed at the hard-coded location • Hard-code locations are not big enough for the complete code (/logic/task) of the bootloader • Hence, it is typically split into 2 portions • Stage1: small enough to load stage2 from our desired location • Stage2: The actual bootloader we want to have

  20. Design of bootloader

  21. Bootloader comparisons • On Desktops • Initialization tasks are done by BIOS • Bootloader is just to boot kernel • On Embedded Systems • All need to be done by bootloader • But in optimized way • Hence two bootloader are • Quite difference from each other • Later being more board dependent & constrained

  22. Stage 2 Bootloader Flavours • Prevalent Desktop Bootloaders • LILO • GRUB • WIN7 Loader • Chameleon • Popular Embedded System Bootloaders • U-boot • Bootloader Object(BLOB) • Redboot

  23. Linux kernel

  24. What is kernel? • Low-level software: • Manage hardware. • Interact with all applications(user space)

  25. Kernel configuration and build system The kernel configuration and build system is based on multiple Makefiles One only interacts with the main Makefile, present at the top directory of the kernel source tree Interaction takes place using the maketool, which parses the Makefile through various targets, defining which action should be done (configuration, compilation, installation, etc.). Run makehelpto see all available targets. Example cd linux-2.6.x/ make <target>

  26. Kernel configuration (1) The kernel contains thousands of device drivers, filesystem drivers, network protocols and other configurable items Thousands of options are available, that are used to selectively compile parts of the kernel source code The kernel configuration is the process of defining the set of options with which you want your kernel to be compiled The set of options depends On your hardware (for device drivers, etc.) On the capabilities you would like to give to your kernel (network capabilities, filesystems, real-time, etc.)

  27. Kernel configuration (2) The configuration is stored in the .configfile at the root of kernel sources Simple text file, key=value style As options have dependencies, typically never edited by hand, but through graphical or text interfaces : make xconfig, make gconfig(graphical) make menuconfig, make nconfig(text) You can switch from one to another, they all load/save the same .configfile, and show the same set of options To modify a kernel in a GNU/Linux distribution:the configuration files are usually released in /boot/, together with kernel images: /boot/config-2.6.17-11-generic

  28. Kernel or module ? The kernel image is a single file, resulting from the linking of all object files that correspond to features enabled in the configuration This is the file that gets loaded in memory by the bootloader All included features are therefore available as soon as the kernel starts, at a time where no filesystem exists Some features (device drivers, filesystems, etc.) can however be compiled as modules Those are plugins that can be loaded/unloaded dynamically to add/remove features to the kernel Each module is stored as a separate file in the filesystem, and therefore access to a filesystem is mandatory to use modules This is not possible in the early boot procedure of the kernel, because no filesystem is available

  29. Kernel option types There are different types of options bool options, they are either true (to include the feature in the kernel) or false (to exclude the feature from the kernel) tristate options, they are either true (to include the feature in the kernel image) or module (to include the feature as a kernel module) or false (to exclude the feature) int options, to specify integer values string options, to specify string values

  30. Kernel option dependencies There are dependencies between kernel options For example, enabling a network driver requires the network stack to be enabled Two types of dependencies depends on dependencies. In this case, option A that depends on option B is not visible until option B is enabled select dependencies. In this case, with option A depending on option B, when option A is enabled, option B is automatically enabled make xconfigallows to see all options, even those that cannot be selected because of missing dependencies. In this case, they are displayed in gray

  31. make xconfig make xconfig The most common graphical interfaceto configure the kernel. Make sure you readhelp -> introduction: useful options! File browser: easier to load configuration files New search interface to look for parameters Required Debian / Ubuntu packages: libqt4-dev

  32. make xconfig screenshot

  33. make xconfig search interface Looks for a keywordin the description string Allows to selector unselect found parameters.

  34. Kernel configuration options Compiled as a module (separate file)CONFIG_ISO9660_FS=m Driver optionsCONFIG_JOLIET=yCONFIG_ZISOFS=y Compiled statically into the kernelCONFIG_UDF_FS=y

  35. Corresponding .config file excerpt ## CD-ROM/DVD Filesystems#CONFIG_ISO9660_FS=mCONFIG_JOLIET=yCONFIG_ZISOFS=yCONFIG_UDF_FS=yCONFIG_UDF_NLS=y## DOS/FAT/NT Filesystems## CONFIG_MSDOS_FS is not set# CONFIG_VFAT_FS is not setCONFIG_NTFS_FS=m# CONFIG_NTFS_DEBUG is not setCONFIG_NTFS_RW=y Section name(helps to locate settings in the interface) All parameters are prefixedwith CONFIG_

  36. make gconfig make gconfig New GTK based graphical configuration interface. Functionality similar to that of make xconfig. Just lacking a searchfunctionality. Required Debian packages: libglade2-dev

  37. make menuconfig make menuconfig Useful when no graphics are available. Pretty convenient too! Same interface found in other tools: BusyBox,buildroot... Required Debian packages: libncurses-dev

  38. make nconfig make nconfig A newer, similar text interface More user friendly(for example, easier to access help information). Required Debian packages: libncurses-dev

  39. make oldconfig make oldconfig Needed very often! Useful to upgrade a .configfile from an earlier kernel release Issues warnings for configuration parametersthat no longer exist in the new kernel. Asks for values for new parameters If you edit a .configfile by hand, it's strongly recommended to run make oldconfigafterwards!

  40. make allnoconfig make allnoconfig Only sets strongly recommended settings to y. Sets all other settings to n. Very useful in embedded systems to select only the minimum required set of features and drivers. Much more convenient than unselecting hundreds of features one by one!

  41. Undoing configuration changes A frequent problem: After changing several kernel configuration settings,your kernel no longer works. If you don't remember all the changes you made,you can get back to your previous configuration:> cp .config.old .config All the configuration interfaces of the kernel(xconfig, menuconfig, allnoconfig...)keep this .config.oldbackup copy.

  42. Configuration per architecture The set of configuration options is architecture dependent Some configuration options are very architecture-specific Most of the configuration options (global kernel options, network subsystem, filesystems, most of the device drivers) are visible in all-architecture By default, the kernel build system assumes that the kernel is being built for the host architecture, i.e. native compilation The architecture is not defined inside the configuration, but at an higher level We will see later how to override this behavior, to allow the configuration of kernels for a different architecture

  43. Overview of kernel options (1) General setup Prompt for development/incomplete code allows to be able to enable drivers or features that are not considered as completely stable yet Local version - append to kernel release allows to concatenate an arbitrary string to the kernel version that an user can get using uname -r. Very useful for support! Support for swap, can usually be disabled on most embedded devices Configure standard kernel features (for small systems) allows to remove features from the kernel to reduce its size. Powerful, use with care!

  44. Overview of kernel options (2) Loadable module support Allows to enable or completely disable module support. If your system doesn't need kernel modules, best to disable since it saves a significant amount of space and memory Enable the block layer If CONFIG_EXPERT is enabled, the block layer can be completely removed. Embedded systems using only Flash storage can safely disable the block layer Processor type and features (x86) or System type (ARM) or CPU selection (MIPS) Allows to select the CPU or machine for which the kernel must be compiled On x86, only optimization-related, on other architectures very important since there's no compatibility

  45. Overview of kernel options (3) Kernel features Tickless system, which allows to disable the regular timer tick and use on-demand ticks instead. Improves power savings High resolution timer support. By default, the resolution of timer is the tick resolution. With high resolution timers, the resolution is as precise as the hardware can give Preemptible kernel enables the preemption inside the kernel code (the userspace code is always preemptible). See our real-time presentation for details Power management Global power management option needed for all power management related features Suspend to RAM, CPU frequency scaling, CPU idle control, suspend to disk

  46. Overview of kernel options (4) Networking support The network stack Networking options Unix sockets, needed for a form of inter-process communication TCP/IP protocol with options for multicast, routing, tunneling, Ipsec, Ipv6, congestion algorithms, etc. Other protocols such as DCCP, SCTP, TIPC, ATM Ethernet bridging, QoS, etc. Support for other types of network CAN bus, Infrared, Bluetooth, Wireless stack, WiMax stack, etc.

  47. Overview of kernel options (5) Device drivers MTD is the subsystem for Flash (NOR, NAND, OneNand, battery-backed memory, etc.) Parallel port support Block devices, a few misc block drivers such as loopback, NBD, etc. ATA/ATAPI, support for IDE disk, CD-ROM and tapes. A new stack exists SCSI The SCSI core, needed not only for SCSI devices but also for USB mass storage devices, SATA and PATA hard drives, etc. SCSI controller drivers

  48. Overview of kernel options (6) Device drivers (cont) SATA and PATA, the new stack for hard disks, relies on SCSI RAID and LVM, to aggregate hard drivers and do replication Network device support, with the network controller drivers. Ethernet, Wireless but also PPP Input device support, for all types of input devices: keyboards, mices, joysticks, touchscreens, tablets, etc. Character devices, contains various device drivers, amongst them serial port controller drivers PTY driver, needed for things like SSH or telnet I2C, SPI, 1-wire, support for the popular embedded buses Hardware monitoring support, infrastructure and drivers for thermal sensors

  49. Overview of kernel options (7) Device drivers (cont) Watchdog support Multifunction drivers are drivers that do not fit in any other category because the device offers multiple functionality at the same time Multimedia support, contains the V4L and DVB subsystems, for video capture, webcams, AM/FM cards, DVB adapters Graphics support, infrastructure and drivers for framebuffers Sound card support, the OSS and ALSA sound infrastructures and the corresponding drivers HID devices, support for the devices that conform to the HID specification (Human Input Devices)

  50. Overview of kernel options (8) Device drivers (cont) USB support Infrastructure Host controller drivers Device drivers, for devices connected to the embedded system Gadget controller drivers Gadget drivers, to let the embedded system act as a mass-storage device, a serial port or an Ethernet adapter MMC/SD/SDIO support LED support Real Time Clock drivers Voltage and current regulators Staging drivers, crappy drivers being cleaned up

More Related