SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
Cross-compiling Linux Kernels on
x86_64: A tutorial on How to Get
Started

Shuah Khan
Senior Linux Kernel Developer – Open Source Group
Samsung Research America (Silicon Valley)
shuah.kh@samsung.com
Agenda
●

Cross-compile value proposition

●

Preparing the system for cross-compiler installation

●

Cross-compiler installation steps

●

Demo – install arm and arm64

●

Compiling on architectures

●

Demo – compile arm and arm64

●

Automating cross-compile testing

●

Upstream cross-compile testing activity

●

References and Package repositories

●

Q&A
Cross-compile value proposition
●

●

●

●

●

30+ architectures supported (several sub-archs)
Native compile testing requires wide range of test
systems – not practical
Ability to cross-compile non-natively on an widely
available architecture helps detect compile errors
Coupled with emulation environments (e.g: qemu) testing
on non-native architectures becomes easier
Setting up cross-compile environment is the first and
necessary step
arch/
alpha
frv
microblaze

arc
h8300
arm

s390

hexagon
arm64

unicore32

mn10300

avr32

sh
openrisc

m32r
blackfin

sparc

m68k

tile
powerpc

metag

xtensa
x86

parisc

c6x

x86_64

score

ia64

cris

um

mips
Cross-compiler packages
●

Ubuntu arm packages (12.10 or later)
–
–

●

gcc-arm-linux-gnueabi
gcc-arm-linux-gnueabihf

Ubuntu arm64 packages (13.04 or later) – use arm64
repo for older Ubuntu releases.
–

●

gcc-4.7-aarch64-linux-gnu

Ubuntu keeps adding support for compilers. Search
Ubuntu repository for packages.
Cross-compiler packages
●

Embedded Debian Project is a good resource for alpha,
mips, mipsel, powerpc, sh, and sparc cross-compilers.
–

gcc-4.7-alpha-linux-gnu

–

gcc-4.7-mips-linux-gnu

–

gcc-4.7-mipsel-linux-gnu

–

gcc-4.7-powerpc-linux-gnu

–

gcc-4.7-sh4-linux-gnu

–

gcc-4.7-sparc-linux-gnu
Cross-compiler packages
●

Fedora repo and Fedora Epel Repo are a good sources for several
cross-compilers and binutils rpms
–

blackfin

–

binutils-bfin-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm
● gcc-bfin-linux-gnu-4.7.1-0.1.20120606.fc17.x86_64.rpm
c6x
●

●
●

–

binutils-c6x-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm
gcc-c6x-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm

tile
●
●

binutils-tile-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm
gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm
Preparing the system for
cross-compiler installation
●

Choose an x86-64 system

●

Install Ubuntu 12.10 or later.
–

Ubuntu 13.04 Install
Install common packages
sudo apt-get install build-essential

sudo apt-get install binutils-multiarch

sudo apt-get install ncurses-dev

sudo apt-get install alien

Note: ncurses-dev is required to run menuconfig and alien to generate .deb from .rpm
Configure apt for arm64 repo
(Ubuntu 12.10)
wget -O - http://people.debian.org/~wookey/bootstrap/bootstrap-archive.key | sudo apt-key add

sudo apt-add-repository 'deb http://people.debian.org/~wookey/bootstrap/ubunturepo/ quantal-bootstrap main'

sudo apt-get update
Configure apt for emdebian repo

sudo apt-get install emdebian-archive-keyring

Create /etc/apt/sources.list.d/emdebian.list file with the following line:
deb http://www.emdebian.org/debian/ sid main
Download rpms from fedora repo
●

blackfin rpms:
–
–

●

binutils-bfin-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm
gcc-bfin-linux-gnu-4.7.1-0.1.20120606.fc17.x86_64.rpm

c6x rpms:
–
–

●

binutils-c6x-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm
gcc-c6x-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm

tile rpms
–

binutils-tile-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm

–

gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm

–

Note: gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm is
what you want. The older version is missing feedback.h, tilegx needs.
Convert rpms to .deb
sudo alien -d binutils-bfin-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm
sudo alien -d gcc-bfin-linux-gnu-4.7.1-0.1.20120606.fc17.x86_64.rpm

sudo alien -d binutils-c6x-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm
sudo alien -d gcc-c6x-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm
sudo alien -d binutils-tile-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm
sudo alien -d gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm

You will see warnings about missing keys e.g: below which you can safely ignore.
warning: gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm:
Header V3 RSA/SHA256 Signature, key ID 1aca3465: NOKEY
Resulting .debs
➔

binutils-bfin-linux-gnu_2.23.51.0.3-2_amd64.deb

➔

binutils-c6x-linux-gnu_2.23.51.0.3-2_amd64.deb

➔

binutils-tile-linux-gnu_2.23.51.0.3-2_amd64.deb

➔

gcc-bfin-linux-gnu_4.7.1-1.1_amd64.deb

➔

gcc-c6x-linux-gnu_4.7.2-3_amd64.deb

➔

gcc-tile-linux-gnu_4.7.2-3_amd64.deb
Install cross-compilers
alpha
sudo apt-get install --install-recommends gcc-4.7-alpha-linux-gnu
sudo ln -s /usr/bin/alpha-linux-gnu-gcc-4.7 /usr/bin/alpha-linux-gnu-gcc
arm
sudo apt-get install gcc-arm-linux-gnueabi
arm64
sudo apt-get install --install-recommends gcc-4.7-aarch64-linux-gnu
sudo ln -s /usr/bin/aarch64-linux-gnu-gcc-4.7 /usr/bin/aarch64-linux-gnu-gcc
mips
sudo apt-get install --install-recommends gcc-4.7-mips-linux-gnu
sudo ln -s /usr/bin/mips-linux-gnu-gcc-4.7 /usr/bin/mips-linux-gnu-gcc
mipsel
sudo apt-get install --install-recommends gcc-4.7-mipsel-linux-gnu
sudo ln -s /usr/bin/mipsel-linux-gnu-gcc-4.7 /usr/bin/mipsel-linux-gnu-gcc
Install cross-compilers
powerpc
sudo apt-get install --install-recommends gcc-4.7-powerpc-linux-gnu
sudo ln -s /usr/bin/powerpc-linux-gnu-gcc-4.7 /usr/bin/powerpc-linux-gnu-gcc
sh
sudo apt-get install --install-recommends gcc-4.7-sh4-linux-gnu
sudo ln -s /usr/bin/sh4-linux-gnu-gcc-4.7 /usr/bin/sh4-linux-gnu-gcc
arm64
sudo apt-get install --install-recommends gcc-4.7-aarch64-linux-gnu
sudo ln -s /usr/bin/aarch64-linux-gnu-gcc-4.7 /usr/bin/aarch64-linux-gnu-gcc
sparc
sudo apt-get install --install-recommends gcc-4.7-sparc-linux-gnu
sudo ln -s /usr/bin/sparc-linux-gnu-gcc-4.7 /usr/bin/sparc-linux-gnu-gcc
Note: Creating link to *arch*-linux-gnu-gcc is necessary as the
CROSS_COMPILE directive
to find the compilers.
Install cross-compilers from .debs
blackfin
sudo dpkg -i binutils-bfin-linux-gnu_2.23.51.0.3-2_amd64.deb
sudo dpkg -i gcc-bfin-linux-gnu_4.7.1-1.1_amd64.deb

c6x
sudo dpkg -i binutils-c6x-linux-gnu_2.23.51.0.3-2_amd64.deb
sudo dpkg -i gcc-c6x-linux-gnu_4.7.2-3_amd64.deb

tile
sudo dpkg -i binutils-tile-linux-gnu_2.23.51.0.3-2_amd64.deb
sudo dpkg -i gcc-tile-linux-gnu_4.7.2-3_amd64.deb
arch/compile
alpha
frv
microblaze

arc
h8300
arm

s390

hexagon
arm64

unicore32

mn10300

avr32

sh
openrisc

m32r
blackfin

sparc

m68k

tile
powerpc

metag

xtensa
x86

parisc

c6x

x86_64

score

ia64

cris

um

mips
Building from sources
●

Mauro Chehab's build_cross script
–

downloads compiler sources for a specified arch from
gnu repo, builds and installs.

–

Usage: build_cross arm

–

Runs on fedora
Demo arm and arm64 install
Compilation Tips
●

●

●

If make ARCH=arch defconfig fails on an arch, pick a
config to test from arch/*/configs
Some architectures don't support defconfig in
cross-compile mode. e.g: powerpc.
In some cases, you might see errors in LD phase, and
please keep in mind these are just compile tests.
Cross-compiling
alpha
make distclean
make ARCH=alpha defconfig
ARCH=alpha CROSS_COMPILE=alpha-linux-gnu- make all
arm
make distclean
make ARCH=arm defconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make all
arm64 (3.7 and later)
make distclean
make ARCH=arm64 defconfig
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make all
blackfin
make distclean
make ARCH=blackfin defconfig
ARCH=blackfin CROSS_COMPILE=bfin-linux-gnu- make all
Cross-compiling
c6x (3.4 and later)
make distclean
make ARCH=c6x defconfig
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make all
mips
make distclean
make ARCH=mips defconfig
ARCH=mips CROSS_COMPILE=mips-linux-gnu- make all
mipsel
make distclean
make ARCH=mips defconfig
ARCH=mips CROSS_COMPILE=mipsel-linux-gnu- make all
powerpc
make distclean
cp arch/powerpc/configs/wii_defconfig .config
ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- make all
Cross-compiling
sh
make distclean
make ARCH=sh defconfig
ARCH=sh CROSS_COMPILE=sh4-linux-gnu- make all

sparc
make distclean
make ARCH=sparc defconfig
ARCH=sparc CROSS_COMPILE=sparc-linux-gnu- make all

tile
make distclean
make ARCH=tile defconfig
ARCH=tile CROSS_COMPILE=tile-linux-gnu- make all
Demo arm and arm64 compilation
Automating cross-compile testing
●

●

●

Script – cross_compile.sh automates builds for the
compilers mentioned in this talk
ktest – crosstests.conf
Buildbot – tool for automating software builds. It can be
configured to checkout Linux kernel sources from git
repos and build.
Upstream Cross-compile testing
activity
●

Linux Kernel stable queue builds project
–

Guenter Rock keeps adding new compilers each
week.

–

Configs: allmodconfig, defconfig, configs with mmu
and without (nommu) where applicable.

–

qemu test results on selected architectures.
References and Package
repositories
●

ARMv8 Debian and Ubuntu bootstrap repositories

●

Embedded Debian Project

●

Fedora Repo

●

Fedora Epel Repo

●

Kernel.org - crosstool

●

Ubuntu 13.04 Install

●

Buildbot

●

Linux Kernel stable queue builds project

●

Ktest
Q&A
Thank you.

Shuah Khan
Senior Open Source Developer – Open Source Group
Samsung Research America (Silicon Valley)
shuah.kh@samsung.com
Summary
●

Cross-compiling Linux Kernels on x86_64: A tutorial on How to Get
Started

●

Agenda

●

Cross-compile value proposition

●

arch/

●

Cross-compiler packages

●

Cross-compiler packages

●

Cross-compiler packages

●

Preparing the system for cross-compiler installation

●

Install common packages

●

Configure apt for arm64 repo (Ubuntu 12.10)

●

Configure apt for emdebian repo

●

Download rpms from fedora repo

●

Convert rpms to .deb

●

Resulting .debs

●

Install cross-compilers

●

Install cross-compilers

●

Install cross-compilers from .debs

●

arch/compile

●

Building from sources

●

Compilation Tips

●

Cross-compiling

●

Cross-compiling

●

Cross-compiling

●

Automating cross-compile testing

●

Upstream Cross-compile testing activity

●

References and Package repositories

●

Thank you.

Contenu connexe

Tendances

Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
Kernel TLV
 

Tendances (20)

Introduction to Modern U-Boot
Introduction to Modern U-BootIntroduction to Modern U-Boot
Introduction to Modern U-Boot
 
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
 
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
 
Understand and optimize Linux I/O
Understand and optimize Linux I/OUnderstand and optimize Linux I/O
Understand and optimize Linux I/O
 
Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)
 
UM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of SoftwareUM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of Software
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
 
Ipc in linux
Ipc in linuxIpc in linux
Ipc in linux
 
UEFI presentation
UEFI presentationUEFI presentation
UEFI presentation
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Yocto Project introduction
Yocto Project introductionYocto Project introduction
Yocto Project introduction
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet Filters
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
Introduction to armv8 aarch64
Introduction to armv8 aarch64Introduction to armv8 aarch64
Introduction to armv8 aarch64
 
LCA13: Power State Coordination Interface
LCA13: Power State Coordination InterfaceLCA13: Power State Coordination Interface
LCA13: Power State Coordination Interface
 
Surfing on an Interactive Kiosk
Surfing on an Interactive KioskSurfing on an Interactive Kiosk
Surfing on an Interactive Kiosk
 
The Linux Kernel Scheduler (For Beginners) - SFO17-421
The Linux Kernel Scheduler (For Beginners) - SFO17-421The Linux Kernel Scheduler (For Beginners) - SFO17-421
The Linux Kernel Scheduler (For Beginners) - SFO17-421
 
Introduction to eBPF
Introduction to eBPFIntroduction to eBPF
Introduction to eBPF
 

Similaire à Tutorial: Cross-compiling Linux Kernels on x86_64

U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
Macpaul Lin
 

Similaire à Tutorial: Cross-compiling Linux Kernels on x86_64 (20)

Embedded Linux/ Debian with ARM64 Platform
Embedded Linux/ Debian with ARM64 PlatformEmbedded Linux/ Debian with ARM64 Platform
Embedded Linux/ Debian with ARM64 Platform
 
3. configuring a compute node for nfv
3. configuring a compute node for nfv3. configuring a compute node for nfv
3. configuring a compute node for nfv
 
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
 
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
 
LCU14 209- LLVM Linux
LCU14 209- LLVM LinuxLCU14 209- LLVM Linux
LCU14 209- LLVM Linux
 
Realtime autonomous car for studying and ROS2 cross compiling
Realtime autonomous car for studying and ROS2 cross compilingRealtime autonomous car for studying and ROS2 cross compiling
Realtime autonomous car for studying and ROS2 cross compiling
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
Developing MIPS Exploits to Hack Routers
Developing MIPS Exploits to Hack RoutersDeveloping MIPS Exploits to Hack Routers
Developing MIPS Exploits to Hack Routers
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
 
Cross-compilation native sous android
Cross-compilation native sous androidCross-compilation native sous android
Cross-compilation native sous android
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
Linux Kernel - Let's Contribute!
Linux Kernel - Let's Contribute!Linux Kernel - Let's Contribute!
Linux Kernel - Let's Contribute!
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
 
Linux Tracing Superpowers by Eugene Pirogov
Linux Tracing Superpowers by Eugene PirogovLinux Tracing Superpowers by Eugene Pirogov
Linux Tracing Superpowers by Eugene Pirogov
 
Summit 16: OPNFV on ARM - Hardware Freedom of Choice Has Arrived!
Summit 16: OPNFV on ARM - Hardware Freedom of Choice Has Arrived!Summit 16: OPNFV on ARM - Hardware Freedom of Choice Has Arrived!
Summit 16: OPNFV on ARM - Hardware Freedom of Choice Has Arrived!
 
Basic Linux kernel
Basic Linux kernelBasic Linux kernel
Basic Linux kernel
 
Scylla Summit 2022: ScyllaDB Rust Driver: One Driver to Rule Them All
Scylla Summit 2022: ScyllaDB Rust Driver: One Driver to Rule Them AllScylla Summit 2022: ScyllaDB Rust Driver: One Driver to Rule Them All
Scylla Summit 2022: ScyllaDB Rust Driver: One Driver to Rule Them All
 
Rhce ppt
Rhce pptRhce ppt
Rhce ppt
 
BPF - in-kernel virtual machine
BPF - in-kernel virtual machineBPF - in-kernel virtual machine
BPF - in-kernel virtual machine
 
JavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame GraphsJavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame Graphs
 

Plus de Samsung Open Source Group

Plus de Samsung Open Source Group (20)

The Complex IoT Equation (and FLOSS solutions)
The Complex IoT Equation (and FLOSS solutions)The Complex IoT Equation (and FLOSS solutions)
The Complex IoT Equation (and FLOSS solutions)
 
Easy IoT with JavaScript
Easy IoT with JavaScriptEasy IoT with JavaScript
Easy IoT with JavaScript
 
Spawny: A New Approach to Logins
Spawny: A New Approach to LoginsSpawny: A New Approach to Logins
Spawny: A New Approach to Logins
 
Rapid SPi Device Driver Development over USB
Rapid SPi Device Driver Development over USBRapid SPi Device Driver Development over USB
Rapid SPi Device Driver Development over USB
 
Tizen RT: A Lightweight RTOS Platform for Low-End IoT Devices
Tizen RT: A Lightweight RTOS Platform for Low-End IoT DevicesTizen RT: A Lightweight RTOS Platform for Low-End IoT Devices
Tizen RT: A Lightweight RTOS Platform for Low-End IoT Devices
 
IoTivity: Smart Home to Automotive and Beyond
IoTivity: Smart Home to Automotive and BeyondIoTivity: Smart Home to Automotive and Beyond
IoTivity: Smart Home to Automotive and Beyond
 
IoTivity for Automotive: meta-ocf-automotive tutorial
IoTivity for Automotive: meta-ocf-automotive tutorialIoTivity for Automotive: meta-ocf-automotive tutorial
IoTivity for Automotive: meta-ocf-automotive tutorial
 
GENIVI + OCF Cooperation
GENIVI + OCF CooperationGENIVI + OCF Cooperation
GENIVI + OCF Cooperation
 
Framework for IoT Interoperability
Framework for IoT InteroperabilityFramework for IoT Interoperability
Framework for IoT Interoperability
 
Open Source Metrics to Inform Corporate Strategy
Open Source Metrics to Inform Corporate StrategyOpen Source Metrics to Inform Corporate Strategy
Open Source Metrics to Inform Corporate Strategy
 
IoTivity for Automotive IoT Interoperability
IoTivity for Automotive IoT InteroperabilityIoTivity for Automotive IoT Interoperability
IoTivity for Automotive IoT Interoperability
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
 
Adding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux Device
Adding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux DeviceAdding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux Device
Adding IEEE 802.15.4 and 6LoWPAN to an Embedded Linux Device
 
IoTivity: From Devices to the Cloud
IoTivity: From Devices to the CloudIoTivity: From Devices to the Cloud
IoTivity: From Devices to the Cloud
 
SOSCON 2016 JerryScript
SOSCON 2016 JerryScriptSOSCON 2016 JerryScript
SOSCON 2016 JerryScript
 
IoT: From Arduino Microcontrollers to Tizen Products using IoTivity
IoT: From Arduino Microcontrollers to Tizen Products using IoTivityIoT: From Arduino Microcontrollers to Tizen Products using IoTivity
IoT: From Arduino Microcontrollers to Tizen Products using IoTivity
 
Run Your Own 6LoWPAN Based IoT Network
Run Your Own 6LoWPAN Based IoT NetworkRun Your Own 6LoWPAN Based IoT Network
Run Your Own 6LoWPAN Based IoT Network
 
Practical Guide to Run an IEEE 802.15.4 Network with 6LoWPAN Under Linux
Practical Guide to Run an IEEE 802.15.4 Network with 6LoWPAN Under LinuxPractical Guide to Run an IEEE 802.15.4 Network with 6LoWPAN Under Linux
Practical Guide to Run an IEEE 802.15.4 Network with 6LoWPAN Under Linux
 
IoTivity Tutorial: Prototyping IoT Devices on GNU/Linux
IoTivity Tutorial: Prototyping IoT Devices on GNU/LinuxIoTivity Tutorial: Prototyping IoT Devices on GNU/Linux
IoTivity Tutorial: Prototyping IoT Devices on GNU/Linux
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of ThingsJerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Tutorial: Cross-compiling Linux Kernels on x86_64

  • 1. Cross-compiling Linux Kernels on x86_64: A tutorial on How to Get Started Shuah Khan Senior Linux Kernel Developer – Open Source Group Samsung Research America (Silicon Valley) shuah.kh@samsung.com
  • 2. Agenda ● Cross-compile value proposition ● Preparing the system for cross-compiler installation ● Cross-compiler installation steps ● Demo – install arm and arm64 ● Compiling on architectures ● Demo – compile arm and arm64 ● Automating cross-compile testing ● Upstream cross-compile testing activity ● References and Package repositories ● Q&A
  • 3. Cross-compile value proposition ● ● ● ● ● 30+ architectures supported (several sub-archs) Native compile testing requires wide range of test systems – not practical Ability to cross-compile non-natively on an widely available architecture helps detect compile errors Coupled with emulation environments (e.g: qemu) testing on non-native architectures becomes easier Setting up cross-compile environment is the first and necessary step
  • 5. Cross-compiler packages ● Ubuntu arm packages (12.10 or later) – – ● gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf Ubuntu arm64 packages (13.04 or later) – use arm64 repo for older Ubuntu releases. – ● gcc-4.7-aarch64-linux-gnu Ubuntu keeps adding support for compilers. Search Ubuntu repository for packages.
  • 6. Cross-compiler packages ● Embedded Debian Project is a good resource for alpha, mips, mipsel, powerpc, sh, and sparc cross-compilers. – gcc-4.7-alpha-linux-gnu – gcc-4.7-mips-linux-gnu – gcc-4.7-mipsel-linux-gnu – gcc-4.7-powerpc-linux-gnu – gcc-4.7-sh4-linux-gnu – gcc-4.7-sparc-linux-gnu
  • 7. Cross-compiler packages ● Fedora repo and Fedora Epel Repo are a good sources for several cross-compilers and binutils rpms – blackfin – binutils-bfin-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm ● gcc-bfin-linux-gnu-4.7.1-0.1.20120606.fc17.x86_64.rpm c6x ● ● ● – binutils-c6x-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm gcc-c6x-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm tile ● ● binutils-tile-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm
  • 8. Preparing the system for cross-compiler installation ● Choose an x86-64 system ● Install Ubuntu 12.10 or later. – Ubuntu 13.04 Install
  • 9. Install common packages sudo apt-get install build-essential sudo apt-get install binutils-multiarch sudo apt-get install ncurses-dev sudo apt-get install alien Note: ncurses-dev is required to run menuconfig and alien to generate .deb from .rpm
  • 10. Configure apt for arm64 repo (Ubuntu 12.10) wget -O - http://people.debian.org/~wookey/bootstrap/bootstrap-archive.key | sudo apt-key add sudo apt-add-repository 'deb http://people.debian.org/~wookey/bootstrap/ubunturepo/ quantal-bootstrap main' sudo apt-get update
  • 11. Configure apt for emdebian repo sudo apt-get install emdebian-archive-keyring Create /etc/apt/sources.list.d/emdebian.list file with the following line: deb http://www.emdebian.org/debian/ sid main
  • 12. Download rpms from fedora repo ● blackfin rpms: – – ● binutils-bfin-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm gcc-bfin-linux-gnu-4.7.1-0.1.20120606.fc17.x86_64.rpm c6x rpms: – – ● binutils-c6x-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm gcc-c6x-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm tile rpms – binutils-tile-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm – gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm – Note: gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm is what you want. The older version is missing feedback.h, tilegx needs.
  • 13. Convert rpms to .deb sudo alien -d binutils-bfin-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm sudo alien -d gcc-bfin-linux-gnu-4.7.1-0.1.20120606.fc17.x86_64.rpm sudo alien -d binutils-c6x-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm sudo alien -d gcc-c6x-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm sudo alien -d binutils-tile-linux-gnu-2.23.51.0.3-1.fc17.x86_64.rpm sudo alien -d gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm You will see warnings about missing keys e.g: below which you can safely ignore. warning: gcc-tile-linux-gnu-4.7.2-2.aa.20121114svn.fc17.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 1aca3465: NOKEY
  • 15. Install cross-compilers alpha sudo apt-get install --install-recommends gcc-4.7-alpha-linux-gnu sudo ln -s /usr/bin/alpha-linux-gnu-gcc-4.7 /usr/bin/alpha-linux-gnu-gcc arm sudo apt-get install gcc-arm-linux-gnueabi arm64 sudo apt-get install --install-recommends gcc-4.7-aarch64-linux-gnu sudo ln -s /usr/bin/aarch64-linux-gnu-gcc-4.7 /usr/bin/aarch64-linux-gnu-gcc mips sudo apt-get install --install-recommends gcc-4.7-mips-linux-gnu sudo ln -s /usr/bin/mips-linux-gnu-gcc-4.7 /usr/bin/mips-linux-gnu-gcc mipsel sudo apt-get install --install-recommends gcc-4.7-mipsel-linux-gnu sudo ln -s /usr/bin/mipsel-linux-gnu-gcc-4.7 /usr/bin/mipsel-linux-gnu-gcc
  • 16. Install cross-compilers powerpc sudo apt-get install --install-recommends gcc-4.7-powerpc-linux-gnu sudo ln -s /usr/bin/powerpc-linux-gnu-gcc-4.7 /usr/bin/powerpc-linux-gnu-gcc sh sudo apt-get install --install-recommends gcc-4.7-sh4-linux-gnu sudo ln -s /usr/bin/sh4-linux-gnu-gcc-4.7 /usr/bin/sh4-linux-gnu-gcc arm64 sudo apt-get install --install-recommends gcc-4.7-aarch64-linux-gnu sudo ln -s /usr/bin/aarch64-linux-gnu-gcc-4.7 /usr/bin/aarch64-linux-gnu-gcc sparc sudo apt-get install --install-recommends gcc-4.7-sparc-linux-gnu sudo ln -s /usr/bin/sparc-linux-gnu-gcc-4.7 /usr/bin/sparc-linux-gnu-gcc Note: Creating link to *arch*-linux-gnu-gcc is necessary as the CROSS_COMPILE directive to find the compilers.
  • 17. Install cross-compilers from .debs blackfin sudo dpkg -i binutils-bfin-linux-gnu_2.23.51.0.3-2_amd64.deb sudo dpkg -i gcc-bfin-linux-gnu_4.7.1-1.1_amd64.deb c6x sudo dpkg -i binutils-c6x-linux-gnu_2.23.51.0.3-2_amd64.deb sudo dpkg -i gcc-c6x-linux-gnu_4.7.2-3_amd64.deb tile sudo dpkg -i binutils-tile-linux-gnu_2.23.51.0.3-2_amd64.deb sudo dpkg -i gcc-tile-linux-gnu_4.7.2-3_amd64.deb
  • 19. Building from sources ● Mauro Chehab's build_cross script – downloads compiler sources for a specified arch from gnu repo, builds and installs. – Usage: build_cross arm – Runs on fedora
  • 20. Demo arm and arm64 install
  • 21. Compilation Tips ● ● ● If make ARCH=arch defconfig fails on an arch, pick a config to test from arch/*/configs Some architectures don't support defconfig in cross-compile mode. e.g: powerpc. In some cases, you might see errors in LD phase, and please keep in mind these are just compile tests.
  • 22. Cross-compiling alpha make distclean make ARCH=alpha defconfig ARCH=alpha CROSS_COMPILE=alpha-linux-gnu- make all arm make distclean make ARCH=arm defconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make all arm64 (3.7 and later) make distclean make ARCH=arm64 defconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make all blackfin make distclean make ARCH=blackfin defconfig ARCH=blackfin CROSS_COMPILE=bfin-linux-gnu- make all
  • 23. Cross-compiling c6x (3.4 and later) make distclean make ARCH=c6x defconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make all mips make distclean make ARCH=mips defconfig ARCH=mips CROSS_COMPILE=mips-linux-gnu- make all mipsel make distclean make ARCH=mips defconfig ARCH=mips CROSS_COMPILE=mipsel-linux-gnu- make all powerpc make distclean cp arch/powerpc/configs/wii_defconfig .config ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- make all
  • 24. Cross-compiling sh make distclean make ARCH=sh defconfig ARCH=sh CROSS_COMPILE=sh4-linux-gnu- make all sparc make distclean make ARCH=sparc defconfig ARCH=sparc CROSS_COMPILE=sparc-linux-gnu- make all tile make distclean make ARCH=tile defconfig ARCH=tile CROSS_COMPILE=tile-linux-gnu- make all
  • 25. Demo arm and arm64 compilation
  • 26. Automating cross-compile testing ● ● ● Script – cross_compile.sh automates builds for the compilers mentioned in this talk ktest – crosstests.conf Buildbot – tool for automating software builds. It can be configured to checkout Linux kernel sources from git repos and build.
  • 27. Upstream Cross-compile testing activity ● Linux Kernel stable queue builds project – Guenter Rock keeps adding new compilers each week. – Configs: allmodconfig, defconfig, configs with mmu and without (nommu) where applicable. – qemu test results on selected architectures.
  • 28.
  • 29.
  • 30.
  • 31. References and Package repositories ● ARMv8 Debian and Ubuntu bootstrap repositories ● Embedded Debian Project ● Fedora Repo ● Fedora Epel Repo ● Kernel.org - crosstool ● Ubuntu 13.04 Install ● Buildbot ● Linux Kernel stable queue builds project ● Ktest
  • 32. Q&A
  • 33. Thank you. Shuah Khan Senior Open Source Developer – Open Source Group Samsung Research America (Silicon Valley) shuah.kh@samsung.com
  • 34. Summary ● Cross-compiling Linux Kernels on x86_64: A tutorial on How to Get Started ● Agenda ● Cross-compile value proposition ● arch/ ● Cross-compiler packages ● Cross-compiler packages ● Cross-compiler packages ● Preparing the system for cross-compiler installation ● Install common packages ● Configure apt for arm64 repo (Ubuntu 12.10) ● Configure apt for emdebian repo ● Download rpms from fedora repo ● Convert rpms to .deb ● Resulting .debs ● Install cross-compilers ● Install cross-compilers ● Install cross-compilers from .debs ● arch/compile ● Building from sources ● Compilation Tips ● Cross-compiling ● Cross-compiling ● Cross-compiling ● Automating cross-compile testing ● Upstream Cross-compile testing activity ● References and Package repositories ● Thank you.