Hands-On With The Yocto Project: Mohammed Billoo

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

Hands-On With The

Yocto Project
Mohammed Billoo

w w w . e m b e d d e d o n l i n e c o n f e r e n c e . c o m
THE SPEAKER
Mohammed Billoo
Mohammed Billoo
(mab@mab-labs.com) • Founder of MAB Labs, LLC
• Expertise developing BSPs targeting custom
hardware
• Freescale/NXP-based SoMs
• Toradex
• Variscite
• Avnet
• TI-based SoMs
• Phytec
• Nvidia-based SoMs
• Jetson Nano
www.linkedin.com/in/mab-embedded • Expertise developing Linux drivers interfacing
with custom hardware, including FPGAs

© EmbeddedOnlineConference.com All rights reserved 2 EmbeddedOnlineConference.com


THE SPEAKER
0xB105F00D Newsletter
MAB Labs, LLC
• News

• Workshops

• Webinars

• Courses

• Tips and tricks


www.linkedin.com/company/mab-labs
www.mab-labs.com • Latest new developments in embedded Linux
and The Yocto Project
© EmbeddedOnlineConference.com All rights reserved 3 EmbeddedOnlineConference.com
AGENDA

1 Basics 4 Customizing the BSP

2 Jargon 5 What’s Next?

3 Toradex BSP Overview 6 Q&A and RAFFLE!

© EmbeddedOnlineConference.com All rights reserved 4 EmbeddedOnlineConference.com


BSP

What is a “BSP”?

A Board Support Package (BSP) can be ANY software that can be run on an
embedded system:

• That makes it easy for developers to implement their application

• Abstracts out underlying hardware from application developers


• Allows application developers to focus on their job/task

• DOES NOT HAVE TO BE LINUX!


• ARM CMSIS
• Popular RTOS implementations (e.g. FreeRTOS, Zephyr)

© EmbeddedOnlineConference.com All rights reserved 5 EmbeddedOnlineConference.com


BSP

Increased
abstraction

© EmbeddedOnlineConference.com All rights reserved 6 EmbeddedOnlineConference.com


Paradigm

Why?

• Troubleshoot build failures

• Determine the best way to customize a


vendor BSP
• Sustainable
• Extensible

© EmbeddedOnlineConference.com All rights reserved 7 EmbeddedOnlineConference.com


The Yocto Project

openembedded-core

poky + meta-openembedded

meta-freescale*

meta-toradex*

meta-mab

Linux Image

© EmbeddedOnlineConference.com All rights reserved 8 EmbeddedOnlineConference.com


Paradigm
BL Kernel DTS Apps
Any embedded Linux system has a
few core components

Embedded
Linux
Image

© EmbeddedOnlineConference.com All rights reserved 9 EmbeddedOnlineConference.com


Paradigm

Building an embedded Linux image


is like baking DTS Kernel

• Specify the ingredients for your final u-boot I2c-tools


image

• Provide instructions on how to


acquire/create these ingredients

© EmbeddedOnlineConference.com All rights reserved 10 EmbeddedOnlineConference.com


Paradigm

Just like baking, each ingredient


(and final image) has a specific set
of steps
• Fetch the source code

• Apply any patches

• Perform any configuration

• Compile the source code

• Install compiled source code to a staging area

• Package build artifact

• Combine packages into a final image

© EmbeddedOnlineConference.com All rights reserved 11 EmbeddedOnlineConference.com


Jargon

Why?

• To make it easier to get help


• Search the Internet for answers
• Search mailing lists for answers
• Ask questions on mailing lists

© EmbeddedOnlineConference.com All rights reserved 12 EmbeddedOnlineConference.com


Bitbake

Responsible for almost everything

• A tool that is used to:


• Build
• Customize

• Each of the steps outlined in slide #11 are referred to as “tasks”

• Functions corresponding to a particular task are prepended with a “do_”:


• Fetch à do_fetch
• Patch à do_patch
• ….

© EmbeddedOnlineConference.com All rights reserved 13 EmbeddedOnlineConference.com


Metadata

Build instructions for bitbake

Consists of:

• Recipes

• Configuration files

© EmbeddedOnlineConference.com All rights reserved 14 EmbeddedOnlineConference.com


Recipes

Instructions for Bitbake

A set of instructions for generating an output, including:

• Where to retrieve source code

• Which patches to apply

• How to configure the source code

• How to compile

• …..

© EmbeddedOnlineConference.com All rights reserved 15 EmbeddedOnlineConference.com


Recipes

• File with “.bb” extension


• “.bbappend” à append file that
customizes an existing recipe

• Can be very simple or very complex


• Simplest recipe involves copying a
file to the root filesystem

© EmbeddedOnlineConference.com All rights reserved 16 EmbeddedOnlineConference.com


Recipes

Fluid structure and format

© EmbeddedOnlineConference.com All rights reserved 17 EmbeddedOnlineConference.com


Package
Configuration
Bitbake output

Package
Recipe bitbake

© EmbeddedOnlineConference.com All rights reserved 18 EmbeddedOnlineConference.com


Layers

Organizing recipes

• Directory structure that enables recipe organization in a sensible manner

• Recipes under a particular layer are organized into functional groups


• recipes-bsp
§ Bootloader customizations
• recipes-kernel
§ Kernel customizations

© EmbeddedOnlineConference.com All rights reserved 19 EmbeddedOnlineConference.com


Layer Organization

© EmbeddedOnlineConference.com All rights reserved 20 EmbeddedOnlineConference.com


Toradex Getting Started

Where do we start?
https://developer.toradex.com/knowledge-base/board-support-package/openembedded-core

© EmbeddedOnlineConference.com All rights reserved 21 EmbeddedOnlineConference.com


Repo?
openembedded-core

poky + meta-openembedded

What’s repo? meta-freescale*

meta-toradex*

• Tool to manage multiple repositories meta-mab

• Useful to pull in different layers

• https://source.android.com/setup/develop#installing-repo
Linux Image

© EmbeddedOnlineConference.com All rights reserved 22 EmbeddedOnlineConference.com


Repo Detour!

Manifest file

• Specifies how to download multiple


source repositories
• Which commit to use or “revision”
• Can specify a branch
§ Just a name for a commit

• Specifies where to download them

© EmbeddedOnlineConference.com All rights reserved 23 EmbeddedOnlineConference.com


Toradex’s Repo Manifest

© EmbeddedOnlineConference.com All rights reserved 24 EmbeddedOnlineConference.com


Repo

Helps manage multiple repositories

• Personal best practice

• Create two separate repositories


• One for my own layer
• Second for my manifest file

• Manifest file tracks repositories of vendor and our own layer


• Specify branch in revision field

• We can make customizations to our own branch without having to change the
manifest

© EmbeddedOnlineConference.com All rights reserved 25 EmbeddedOnlineConference.com


Toradex Board Overview

Wire up board to flash image to


eMMC
• Verdin iMX 8M Mini

• Dahlia Carrier Board

• Green USB-C
• Debug/UART console
• /dev/ttyUSB6

• Silver USB-C
• Mounting eMMC as a USB drive on host PC
• /dev/sdg

• Ethernet and display optional

© EmbeddedOnlineConference.com All rights reserved 26 EmbeddedOnlineConference.com


DEMO

Navigating, building, and flashing the Toradex BSP out-of-the-box

© EmbeddedOnlineConference.com All rights reserved 27 EmbeddedOnlineConference.com


Customizations

What sort of customizations can be made?

• Adding an application (as a package) to the image

• Modifying the Linux kernel


• Change a configuration option

• Modifying the device tree


• Add an i2c peripheral to the board

© EmbeddedOnlineConference.com All rights reserved 28 EmbeddedOnlineConference.com


Hardware Setup

© EmbeddedOnlineConference.com All rights reserved 29 EmbeddedOnlineConference.com


Adding An Application

Wish to add i2cdetect

• Common utility used during board bring up

• Used to confirm that an i2c peripheral is present

• Part of package that’s created when building “i2c-tools” recipe

© EmbeddedOnlineConference.com All rights reserved 30 EmbeddedOnlineConference.com


DEMO

Adding i2cdetect to the Toradex BSP to verify HW connections

© EmbeddedOnlineConference.com All rights reserved 31 EmbeddedOnlineConference.com


Modifying the Kernel

Add support for I2C sensor

• Wish to add support for the SHT3x

• Need to see which configuration option is necessary

• Check to see that it’s enabled

© EmbeddedOnlineConference.com All rights reserved 32 EmbeddedOnlineConference.com


DEMO

Enabling the sht3x driver in the kernel

© EmbeddedOnlineConference.com All rights reserved 33 EmbeddedOnlineConference.com


Modifying the Device Tree

Add SHT31 sensor to board

• Enabling the driver in the kernel is not enough

• Need to add it to the appropriate i2c bus in the device tree

• Once kernel “sees” the device in the device tree, it will load the driver for the device

© EmbeddedOnlineConference.com All rights reserved 34 EmbeddedOnlineConference.com


DEMO

Adding the sht31 sensor in the device tree

© EmbeddedOnlineConference.com All rights reserved 35 EmbeddedOnlineConference.com


Putting It All Together

Create your own layer with modifications

• conf/local.conf derived from Toradex layer


• Don’t have control!

• Changes made in devshell aren’t persistent

• Need to create custom recipes and append files that incorporate these changes

© EmbeddedOnlineConference.com All rights reserved 36 EmbeddedOnlineConference.com


DEMO

Putting it all together

© EmbeddedOnlineConference.com All rights reserved 37 EmbeddedOnlineConference.com


Advanced Topics

How can we learn further?


MAB Labs course on The Yocto Project

• Debugging failures

• Managing repository with custom layer

• Organizational decisions
www.mab-labs.com/#b105f00d
• Bitbake classes
www.linkedin.com/company/mab-labs
• Creating a custom image (w/ custom dts + defconfig)

• Speeding up a build

© EmbeddedOnlineConference.com All rights reserved 38 EmbeddedOnlineConference.com


THANK YOU

w w w . e m b e d d e d o n l i n e c o n f e r e n c e . c o m

You might also like