Linux Porting

Anil Kumar Pugalia
Anil Kumar PugaliaLinux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Linux Porting 
& 
Linux Support Package 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 
All Rights Reserved.
What to Expect? 
Kernel Basics for Linux Porting 
W's of Linux Porting 
W's of Linux Support Package (LSP) 
Architecture of LSPs 
Browse & Understand the LSPs 
LSP & Board Bringup Connections 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 2 
All Rights Reserved.
Some Basics 
For 
Understanding Linux Porting 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 3 
All Rights Reserved.
Kernel Items to Consider 
Version 
Major 
Minor 
Sequence 
Extra version 
/proc/version 
Source Repositories & Mailing Lists 
Architecture Specific 
Architecture Merging Efforts 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 4 
All Rights Reserved.
Kernel Configuration (Detailed) 
Changing the .config by hand 
Preparing & Using a default config 
Example: arch/arm/configs/omap3evm 
Other Configs: rand, allmod, allyes, allno 
Adding an Entry 
Change in Kconfig 
Change in Makefile 
Let's have a demonstration 
The autoconf.h 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 5 
All Rights Reserved.
Kernel Image Components 
Observe the Makefile &/or vmlinux build with V=1 
Objects 
arch/<arch>/kernel/head.o 
Kernel Architecture specific startup code 
arch/<arch>/kernel/init-task.o 
Initial thread & task structs required by Kernel 
init/built-in.o 
Main kernel initialization code 
… 
Linker script 
arch/<arch>/kernel/vmlinux.lds 
Kernel Bootstrap Loader 
Initialize Processor's internal caches and C runtime environment (head*.o) 
Decompression & re-location (misc.o) 
Processor-specific initialization, e.g. endian related (*endian.o) 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 6 
All Rights Reserved.
Kernel Initialization (Detailed) 
Kernel Entry Point 
arch/<arch>/kernel/head*.o 
Kernel Startup 
init/main.c → start_kernel(); 
Browse the code 
Architecture Setup 
Command Line Processing & __setup macro(arg, f) 
Subsystem Initializations & Initcalls (for memory free up) 
Kernel init Thread → init process 
Idle Process 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 7 
All Rights Reserved.
Let's get down to the Source Code 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 8 
All Rights Reserved.
Let's Check 
Where are the following things done? 
MMU switching ON 
Starting of kernel 
Mounting of init ramdisk and root filesystem 
board_init invocation 
Where is the default command line setup? 
'Booting Kernel' message 
Machine Id verification 
Command Line parsing 
start_kernel location 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 9 
All Rights Reserved.
Linux Porting 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 10 
All Rights Reserved.
What is Porting? 
“To Port” is “To Carry” 
Adapting to the Environment 
That it was not Designed for 
And by “(Embedded) Linux Porting” we mean 
Adapting Linux to work on an Embedded Platform 
So, what does it take to port Linux 
At high level, the 5's of Embedded Systems 
And at kernel level, the 5 M's of OS 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 11 
All Rights Reserved.
5 M's of OS (Revisited) 
Architecture Porting 
Processor Management 
Memory Management 
Board Porting 
I/O Management 
Storage Management 
Network Management 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 12 
All Rights Reserved.
Linux Porting 
Architecture Porting is a subject in itself 
Would talk in a separate session 
Board Porting 
Board-specific Initialization Code 
And majorly Drivers Porting 
So, part of the Kernel Space 
Two categories of Drivers 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 13 
All Rights Reserved. 
Standard Device Drivers 
Part of the Kernel 
Or, Needs to be done as for writing the standard Linux Drivers 
At the standard directory locations 
Custom Device / Interface Drivers 
Board-specific Custom Code required 
Needs to be specifically brought-in with the Kernel
What is Linux Support Package? 
Collection of this board specific 
Initialization & Custom Code is referred as 
Board Support Package (BSP) – normal 
language 
Or, Linux Support Package (LSP) – Linux 
language 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 14 
All Rights Reserved.
Sources of LSPs 
Board Vendor 
For a reference board, Or 
For a board based on the reference design 
Develop your Own for a Custom Board 
developed In-House 
First, search the kernel source for existing code 
If found, use it 
Else, if found something close, modify & use it 
Otherwise, following material would provide 
further guidelines 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 15 
All Rights Reserved.
Architecture of Linux Support Packages 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 16 
All Rights Reserved.
Components of LSP 
As LSP is very specific to a board. It consists 
of code for things hard-wired on the board 
A Usual List 
Interrupt Request Numbers 
Audio Codecs 
Keypad Interfaces 
Switch Interfaces 
LED Interfaces 
... 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 17 
All Rights Reserved.
LSP Placement 
With these in mind, and a board being tied to an architecture, the 
natural place for an LSP becomes under the kernel's “arch” sub-tree 
To be more specific, under the specific <arch> of the arch/ 
Architecture Specific Code resides under 
arch/<arch> → Sources 
include/asm-<arch> → Headers 
So, Board Specific Code resides under 
arch/<arch>/mach-<board_name> → Sources 
include/asm/mach-<board_name> → Headers 
mach stands for Machine, lingo for Board in Linux community 
Many LSP vendors, violate these norms, and 
Place headers with sources 
Place the LSP at other inappropriate locations 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 18 
All Rights Reserved.
Design & Layout of LSPs 
Where does a keypad driver go? 
Under drivers, Or 
Linux Support Package 
What about code for Audio chip, when the controller doesn't have 
built-in audio support (say I2S)? 
Such gray areas create confusion 
People place the code as per their judgment 
Hence, we follow some thumb rules 
Design & Layout Rules of Thumb 
Look for something similar, already in kernel source 
Follow the norm 
If not there, start from the LSP 
Over time, if it becomes generic enough, move to drivers 
For all the above, appropriately update Kconfig & Makefile 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 19 
All Rights Reserved.
Initialization Code LSP 
Board specific Code 
UART Configuration – UART Pins, UART vs 
Device mapping, ... 
Ethernet Configuration – Interrupt Pin, ... 
… (the various device configurations) 
Let's browse the code 
mach-omap2/board-omap3evm.c 
plat-omap/... 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 20 
All Rights Reserved.
Custom Code LSP 
Interrupts 
Input / Output Management 
Audio 
Video 
Embedded Storage Management 
Flash Partitioning 
NB Separate sessions needed for each 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 21 
All Rights Reserved.
Let's Browse some LSPs 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 22 
All Rights Reserved.
LSP & Board Bringup Connections 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 23 
All Rights Reserved.
BSP in Bootloader 
Bootloader does some of the Board-specific 
tasks, which are done in kernel 
Device Initialization 
Some Device Access 
This could be taken advantage from 
Could serve as the reference for the LSP 
Many a times, it becomes other way round 
Code developed for LSP may help enhance 
Bootloader 
Improving a better Board Bringup Experience 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 24 
All Rights Reserved.
Board Id 
Unique Number designated to every 
Board Type 
Part of the LSP and exposed to Bootloader 
Populated by Bootloader 
Verified by LSP 
Let's browse to view it 
arch/arm/tools/mach-types 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 25 
All Rights Reserved.
Hacking the LSP 
Very often, we have initial boot, test & 
board bringup programs, written to run 
on the bare board 
They may be really useful to hack the LSP 
When it is not working as expected 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 26 
All Rights Reserved.
Steps in Porting 
Register the machine and get the machine id for board 
Create a board specific file 'board-<board_name>' at 
arch/arm/mach-<soc> 
Define the MACHINE_START for the board 
Update the Kconfig file at arch/arm/mach-<soc> 
Update the corresponding makefile 
Create the default configuration for the board and place the 
working .config file at arch/arm/configs/ 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 27 
All Rights Reserved.
What all have we learnt? 
Kernel Basics for Linux Porting 
W's of Linux Porting 
W's of Linux Support Package (LSP) 
Architecture of LSPs 
Browse & Understand the LSPs 
LSP & Board Bringup Connections 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 28 
All Rights Reserved.
Any Queries? 
© 2010-14 SysPlay Workshops <workshop@sysplay.in> 29 
All Rights Reserved.
1 of 29

Recommended

SPI Drivers by
SPI DriversSPI Drivers
SPI DriversSysPlay eLearning Academy for You
13.2K views20 slides
USB Drivers by
USB DriversUSB Drivers
USB DriversAnil Kumar Pugalia
42.9K views31 slides
BeagleBone Black Bootloaders by
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black BootloadersSysPlay eLearning Academy for You
4.6K views24 slides
gcc and friends by
gcc and friendsgcc and friends
gcc and friendsAnil Kumar Pugalia
14.3K views11 slides
Board Bringup by
Board BringupBoard Bringup
Board BringupAnil Kumar Pugalia
28.7K views16 slides
Bootloaders by
BootloadersBootloaders
BootloadersAnil Kumar Pugalia
10K views19 slides

More Related Content

What's hot

Block Drivers by
Block DriversBlock Drivers
Block DriversAnil Kumar Pugalia
38.5K views21 slides
Linux Porting by
Linux PortingLinux Porting
Linux PortingChamp Yen
7.6K views28 slides
Bootloaders (U-Boot) by
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot) Omkar Rane
642 views18 slides
U-Boot presentation 2013 by
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013Wave Digitech
18.7K views28 slides
Basic Linux Internals by
Basic Linux InternalsBasic Linux Internals
Basic Linux Internalsmukul bhardwaj
41.3K views333 slides
Introduction to Linux by
Introduction to LinuxIntroduction to Linux
Introduction to LinuxAnil Kumar Pugalia
11.2K views32 slides

What's hot(20)

Linux Porting by Champ Yen
Linux PortingLinux Porting
Linux Porting
Champ Yen7.6K views
Bootloaders (U-Boot) by Omkar Rane
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
Omkar Rane642 views
U-Boot presentation 2013 by Wave Digitech
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
Wave Digitech18.7K views
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03) by William Liang
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
William Liang7.1K views
Arm device tree and linux device drivers by Houcheng Lin
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
Houcheng Lin17.5K views
Linux Kernel Booting Process (1) - For NLKB by shimosawa
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
shimosawa12.5K views
Uboot startup sequence by Houcheng Lin
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
Houcheng Lin33.7K views
Device Tree for Dummies (ELC 2014) by Thomas Petazzoni
Device Tree for Dummies (ELC 2014)Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)
Thomas Petazzoni1.7K views

Viewers also liked

BeagleBoard-xM Bootloaders by
BeagleBoard-xM BootloadersBeagleBoard-xM Bootloaders
BeagleBoard-xM BootloadersSysPlay eLearning Academy for You
7.3K views17 slides
Platform Drivers by
Platform DriversPlatform Drivers
Platform DriversSysPlay eLearning Academy for You
17.6K views12 slides
File Systems by
File SystemsFile Systems
File SystemsAnil Kumar Pugalia
18K views22 slides
References by
ReferencesReferences
ReferencesAnil Kumar Pugalia
21.8K views8 slides
Embedded C by
Embedded CEmbedded C
Embedded CAnil Kumar Pugalia
25.7K views20 slides
Serial Drivers by
Serial DriversSerial Drivers
Serial DriversSysPlay eLearning Academy for You
17.1K views13 slides

Similar to Linux Porting

Linux Kernel Overview by
Linux Kernel OverviewLinux Kernel Overview
Linux Kernel OverviewAnil Kumar Pugalia
26.7K views20 slides
Introduction to Linux by
Introduction to LinuxIntroduction to Linux
Introduction to LinuxAnil Kumar Pugalia
4K views33 slides
Cisco Ios advanced by
Cisco Ios advancedCisco Ios advanced
Cisco Ios advancedNallaparaju Varma
220 views5 slides
Introduction to Embedded Systems by
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded SystemsAnil Kumar Pugalia
18.5K views37 slides
Visão geral do hardware do servidor System z e Linux on z - Concurso Mainframe by
Visão geral do hardware do servidor System z e Linux on z - Concurso MainframeVisão geral do hardware do servidor System z e Linux on z - Concurso Mainframe
Visão geral do hardware do servidor System z e Linux on z - Concurso MainframeAnderson Bassani
1.1K views37 slides
Slimline Open Firmware by
Slimline Open FirmwareSlimline Open Firmware
Slimline Open FirmwareHeiko Joerg Schick
2.1K views37 slides

Similar to Linux Porting(20)

Visão geral do hardware do servidor System z e Linux on z - Concurso Mainframe by Anderson Bassani
Visão geral do hardware do servidor System z e Linux on z - Concurso MainframeVisão geral do hardware do servidor System z e Linux on z - Concurso Mainframe
Visão geral do hardware do servidor System z e Linux on z - Concurso Mainframe
Anderson Bassani1.1K views
Ubuntu and Linux Terminal Server Project by Sameer Verma
Ubuntu and Linux Terminal Server ProjectUbuntu and Linux Terminal Server Project
Ubuntu and Linux Terminal Server Project
Sameer Verma4.7K views
© 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 1.docx by LynellBull52
© 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 1.docx© 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 1.docx
© 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 1.docx
LynellBull524 views
FreeBSD - LinuxExpo by webuploader
FreeBSD - LinuxExpoFreeBSD - LinuxExpo
FreeBSD - LinuxExpo
webuploader1.2K views
17294_HiperSockets.pdf by Eeszt
17294_HiperSockets.pdf17294_HiperSockets.pdf
17294_HiperSockets.pdf
Eeszt4 views
Problem Reporting and Analysis Linux on System z -How to survive a Linux Crit... by IBM India Smarter Computing
Problem Reporting and Analysis Linux on System z -How to survive a Linux Crit...Problem Reporting and Analysis Linux on System z -How to survive a Linux Crit...
Problem Reporting and Analysis Linux on System z -How to survive a Linux Crit...
Kernel Recipes 2013 - Easy rootfs using Buildroot by Anne Nicolas
Kernel Recipes 2013 - Easy rootfs using BuildrootKernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using Buildroot
Anne Nicolas7.2K views
Unix nim-presentation by Rajeev Ghosh
Unix nim-presentationUnix nim-presentation
Unix nim-presentation
Rajeev Ghosh770 views
Leveraging Open Source to Manage SAN Performance by brettallison
Leveraging Open Source to Manage SAN PerformanceLeveraging Open Source to Manage SAN Performance
Leveraging Open Source to Manage SAN Performance
brettallison2K views

More from Anil Kumar Pugalia

File System Modules by
File System ModulesFile System Modules
File System ModulesAnil Kumar Pugalia
21K views37 slides
Kernel Debugging & Profiling by
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & ProfilingAnil Kumar Pugalia
6K views14 slides
Processes by
ProcessesProcesses
ProcessesAnil Kumar Pugalia
7K views33 slides
System Calls by
System CallsSystem Calls
System CallsAnil Kumar Pugalia
4.2K views17 slides
Embedded Software Design by
Embedded Software DesignEmbedded Software Design
Embedded Software DesignAnil Kumar Pugalia
7K views29 slides
Playing with R L C Circuits by
Playing with R L C CircuitsPlaying with R L C Circuits
Playing with R L C CircuitsAnil Kumar Pugalia
2.8K views17 slides

More from Anil Kumar Pugalia(20)

Recently uploaded

Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...ShapeBlue
198 views20 slides
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...ShapeBlue
173 views15 slides
The Role of Patterns in the Era of Large Language Models by
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language ModelsYunyao Li
85 views65 slides
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool by
Extending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPoolExtending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPool
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPoolShapeBlue
123 views10 slides
The Power of Heat Decarbonisation Plans in the Built Environment by
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built EnvironmentIES VE
79 views20 slides
State of the Union - Rohit Yadav - Apache CloudStack by
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStackShapeBlue
297 views53 slides

Recently uploaded(20)

Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue198 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue173 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li85 views
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool by ShapeBlue
Extending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPoolExtending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPool
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool
ShapeBlue123 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE79 views
State of the Union - Rohit Yadav - Apache CloudStack by ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue297 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue132 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue180 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10123 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue166 views
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue by ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue135 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue221 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue194 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue186 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue203 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash158 views
Initiating and Advancing Your Strategic GIS Governance Strategy by Safe Software
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
Safe Software176 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue138 views

Linux Porting

  • 1. Linux Porting & Linux Support Package © 2010-14 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved.
  • 2. What to Expect? Kernel Basics for Linux Porting W's of Linux Porting W's of Linux Support Package (LSP) Architecture of LSPs Browse & Understand the LSPs LSP & Board Bringup Connections © 2010-14 SysPlay Workshops <workshop@sysplay.in> 2 All Rights Reserved.
  • 3. Some Basics For Understanding Linux Porting © 2010-14 SysPlay Workshops <workshop@sysplay.in> 3 All Rights Reserved.
  • 4. Kernel Items to Consider Version Major Minor Sequence Extra version /proc/version Source Repositories & Mailing Lists Architecture Specific Architecture Merging Efforts © 2010-14 SysPlay Workshops <workshop@sysplay.in> 4 All Rights Reserved.
  • 5. Kernel Configuration (Detailed) Changing the .config by hand Preparing & Using a default config Example: arch/arm/configs/omap3evm Other Configs: rand, allmod, allyes, allno Adding an Entry Change in Kconfig Change in Makefile Let's have a demonstration The autoconf.h © 2010-14 SysPlay Workshops <workshop@sysplay.in> 5 All Rights Reserved.
  • 6. Kernel Image Components Observe the Makefile &/or vmlinux build with V=1 Objects arch/<arch>/kernel/head.o Kernel Architecture specific startup code arch/<arch>/kernel/init-task.o Initial thread & task structs required by Kernel init/built-in.o Main kernel initialization code … Linker script arch/<arch>/kernel/vmlinux.lds Kernel Bootstrap Loader Initialize Processor's internal caches and C runtime environment (head*.o) Decompression & re-location (misc.o) Processor-specific initialization, e.g. endian related (*endian.o) © 2010-14 SysPlay Workshops <workshop@sysplay.in> 6 All Rights Reserved.
  • 7. Kernel Initialization (Detailed) Kernel Entry Point arch/<arch>/kernel/head*.o Kernel Startup init/main.c → start_kernel(); Browse the code Architecture Setup Command Line Processing & __setup macro(arg, f) Subsystem Initializations & Initcalls (for memory free up) Kernel init Thread → init process Idle Process © 2010-14 SysPlay Workshops <workshop@sysplay.in> 7 All Rights Reserved.
  • 8. Let's get down to the Source Code © 2010-14 SysPlay Workshops <workshop@sysplay.in> 8 All Rights Reserved.
  • 9. Let's Check Where are the following things done? MMU switching ON Starting of kernel Mounting of init ramdisk and root filesystem board_init invocation Where is the default command line setup? 'Booting Kernel' message Machine Id verification Command Line parsing start_kernel location © 2010-14 SysPlay Workshops <workshop@sysplay.in> 9 All Rights Reserved.
  • 10. Linux Porting © 2010-14 SysPlay Workshops <workshop@sysplay.in> 10 All Rights Reserved.
  • 11. What is Porting? “To Port” is “To Carry” Adapting to the Environment That it was not Designed for And by “(Embedded) Linux Porting” we mean Adapting Linux to work on an Embedded Platform So, what does it take to port Linux At high level, the 5's of Embedded Systems And at kernel level, the 5 M's of OS © 2010-14 SysPlay Workshops <workshop@sysplay.in> 11 All Rights Reserved.
  • 12. 5 M's of OS (Revisited) Architecture Porting Processor Management Memory Management Board Porting I/O Management Storage Management Network Management © 2010-14 SysPlay Workshops <workshop@sysplay.in> 12 All Rights Reserved.
  • 13. Linux Porting Architecture Porting is a subject in itself Would talk in a separate session Board Porting Board-specific Initialization Code And majorly Drivers Porting So, part of the Kernel Space Two categories of Drivers © 2010-14 SysPlay Workshops <workshop@sysplay.in> 13 All Rights Reserved. Standard Device Drivers Part of the Kernel Or, Needs to be done as for writing the standard Linux Drivers At the standard directory locations Custom Device / Interface Drivers Board-specific Custom Code required Needs to be specifically brought-in with the Kernel
  • 14. What is Linux Support Package? Collection of this board specific Initialization & Custom Code is referred as Board Support Package (BSP) – normal language Or, Linux Support Package (LSP) – Linux language © 2010-14 SysPlay Workshops <workshop@sysplay.in> 14 All Rights Reserved.
  • 15. Sources of LSPs Board Vendor For a reference board, Or For a board based on the reference design Develop your Own for a Custom Board developed In-House First, search the kernel source for existing code If found, use it Else, if found something close, modify & use it Otherwise, following material would provide further guidelines © 2010-14 SysPlay Workshops <workshop@sysplay.in> 15 All Rights Reserved.
  • 16. Architecture of Linux Support Packages © 2010-14 SysPlay Workshops <workshop@sysplay.in> 16 All Rights Reserved.
  • 17. Components of LSP As LSP is very specific to a board. It consists of code for things hard-wired on the board A Usual List Interrupt Request Numbers Audio Codecs Keypad Interfaces Switch Interfaces LED Interfaces ... © 2010-14 SysPlay Workshops <workshop@sysplay.in> 17 All Rights Reserved.
  • 18. LSP Placement With these in mind, and a board being tied to an architecture, the natural place for an LSP becomes under the kernel's “arch” sub-tree To be more specific, under the specific <arch> of the arch/ Architecture Specific Code resides under arch/<arch> → Sources include/asm-<arch> → Headers So, Board Specific Code resides under arch/<arch>/mach-<board_name> → Sources include/asm/mach-<board_name> → Headers mach stands for Machine, lingo for Board in Linux community Many LSP vendors, violate these norms, and Place headers with sources Place the LSP at other inappropriate locations © 2010-14 SysPlay Workshops <workshop@sysplay.in> 18 All Rights Reserved.
  • 19. Design & Layout of LSPs Where does a keypad driver go? Under drivers, Or Linux Support Package What about code for Audio chip, when the controller doesn't have built-in audio support (say I2S)? Such gray areas create confusion People place the code as per their judgment Hence, we follow some thumb rules Design & Layout Rules of Thumb Look for something similar, already in kernel source Follow the norm If not there, start from the LSP Over time, if it becomes generic enough, move to drivers For all the above, appropriately update Kconfig & Makefile © 2010-14 SysPlay Workshops <workshop@sysplay.in> 19 All Rights Reserved.
  • 20. Initialization Code LSP Board specific Code UART Configuration – UART Pins, UART vs Device mapping, ... Ethernet Configuration – Interrupt Pin, ... … (the various device configurations) Let's browse the code mach-omap2/board-omap3evm.c plat-omap/... © 2010-14 SysPlay Workshops <workshop@sysplay.in> 20 All Rights Reserved.
  • 21. Custom Code LSP Interrupts Input / Output Management Audio Video Embedded Storage Management Flash Partitioning NB Separate sessions needed for each © 2010-14 SysPlay Workshops <workshop@sysplay.in> 21 All Rights Reserved.
  • 22. Let's Browse some LSPs © 2010-14 SysPlay Workshops <workshop@sysplay.in> 22 All Rights Reserved.
  • 23. LSP & Board Bringup Connections © 2010-14 SysPlay Workshops <workshop@sysplay.in> 23 All Rights Reserved.
  • 24. BSP in Bootloader Bootloader does some of the Board-specific tasks, which are done in kernel Device Initialization Some Device Access This could be taken advantage from Could serve as the reference for the LSP Many a times, it becomes other way round Code developed for LSP may help enhance Bootloader Improving a better Board Bringup Experience © 2010-14 SysPlay Workshops <workshop@sysplay.in> 24 All Rights Reserved.
  • 25. Board Id Unique Number designated to every Board Type Part of the LSP and exposed to Bootloader Populated by Bootloader Verified by LSP Let's browse to view it arch/arm/tools/mach-types © 2010-14 SysPlay Workshops <workshop@sysplay.in> 25 All Rights Reserved.
  • 26. Hacking the LSP Very often, we have initial boot, test & board bringup programs, written to run on the bare board They may be really useful to hack the LSP When it is not working as expected © 2010-14 SysPlay Workshops <workshop@sysplay.in> 26 All Rights Reserved.
  • 27. Steps in Porting Register the machine and get the machine id for board Create a board specific file 'board-<board_name>' at arch/arm/mach-<soc> Define the MACHINE_START for the board Update the Kconfig file at arch/arm/mach-<soc> Update the corresponding makefile Create the default configuration for the board and place the working .config file at arch/arm/configs/ © 2010-14 SysPlay Workshops <workshop@sysplay.in> 27 All Rights Reserved.
  • 28. What all have we learnt? Kernel Basics for Linux Porting W's of Linux Porting W's of Linux Support Package (LSP) Architecture of LSPs Browse & Understand the LSPs LSP & Board Bringup Connections © 2010-14 SysPlay Workshops <workshop@sysplay.in> 28 All Rights Reserved.
  • 29. Any Queries? © 2010-14 SysPlay Workshops <workshop@sysplay.in> 29 All Rights Reserved.