• Nenhum resultado encontrado

71 aula

N/A
N/A
Protected

Academic year: 2021

Share "71 aula"

Copied!
32
0
0

Texto

(1)

Interface Hardware-Software

(2)

IHS - §7 Driver Intro 2

Tópicos

1) Device Driver Introduction 2) Linux embedded system 3) Cross compile

(3)

Tópicos

1) Device Driver Introduction

2) Linux embedded system 3) Cross compile

(4)

IHS - §7 Driver Intro 4

Input/Output Device Access

(5)

I/O Communication Infrastructure - Hardware

(6)

IHS - §7 Driver Intro 6

HW Controllers

I/O devices are managed by HW controllers Transfer data to/from device

Synchronize operations with software Have a working protocol

Usually have a standard communication interface Controllers have different registers:

Command Registers: Initiate some device operation

Status Registers: Indicate what the device is doing and the occurrence of errors

(7)
(8)

IHS - §7 Driver Intro 8

I/O Communication Infrastructure - Software

(9)

Device Drivers

SW specific to a device used by the higher layers Manage device usage

Provides an API for higher SW layers System calls usually call device drivers

Usually provides 6 basic features for using the device Device Initialization/Reset Open Close Read Write I/O control

(10)

IHS - §7 Driver Intro 10

Device Driver Development

Requires good understanding how the device's HW controller (working protocol) and bus work

Requires the writing of very complex code that

includes many specific details of the HW device often represents the largest SW part of a system Employs generally high-level languages

Specific small parts written in assembly

Many system libraries or routines available that allow low level access for high level languages

(11)

x86 Support for I/O Communication

The x86 processor instruction set supports two I/O communication mechanisms:

1) Memory mapped I/O

Memory reading and writing instructions (e.g. mov) 2) Specific Instructions for I/O ports

Read/write instructions for I/O ports (e.g. in and out) See later, Accessing the speaker

(12)

IHS - §7 Driver Intro 12

What Does Driver Development Involve?

In addition to the code required to perform the operations offered by a device, Operation Systems impose rules and procedures for

developing a driver: Register Driver

Inform the Driver type

Associate a driver with a unique identifier in the OS Associate a driver with one or more devices

Sign the operations that will be implemented within the interface established by OS

Associate Driver with an I/O port

(13)

OS Support for Driver Development

As mentioned, great part of the code is written in high level languages (C or C ++)

Operating systems offer libraries or software development kits (SDKs) for faster and more systematic driver development

Standard Interfaces for different device classes

Functions already implemented to register, enable and release drivers as well as add devices, among others

(14)

IHS - §7 Driver Intro 14

Linux Driver Development

Drivers are developed in layers

One less specific to the bus/device communication interface and another more specific

Provides driver development libraries for a variety of buses PCI, USB, Firewire, etc

Differences in features do not allow a single driver development standard for different communication interface types

(15)

Tópicos

1) Device Driver Introduction

2) Linux embedded system

(16)

IHS - §7 Driver Intro 16

NXP I.MX 7Dual SABRE Board

ARM Cortex-A7 (1GHz) Memory 1GB DDR3

Display/Camera Connectors Wireless

Ethernet, USB, PCI, SIM card slot

Accelerometer,

Magnetometer, Gyroscope, Barometer, Altimeter

(17)

Microchip SAMA5D2 Xplained Ultra board

ARM Cortex-A5 Memory 2GB DDR3 SD/MMC interface USB RGB LCD

ISC interface and

connector (Image sensor) Expansion connector

User push button Tri-color user LED

(18)

IHS - §7 Driver Intro 18

Broadcom BCM2837 board

Raspberry Pi 3 Model A+ ARM Cortex-A53 Memory 512MB SDRAM Wireless, Bluetooth HDMI

CSI camera port DSI display port

4-pole stereo output Composite video port Micro SD port

(19)
(20)

IHS - §7 Driver Intro 20

Linux embedded architecture

(21)

Linux embedded system

Bootloader:

Configures the memory system

Loads the kernel image and the device tree Kernel: Core of the OS

Lowest level of software

Manages the HW, runs user programs, maintains system security and integrity

System call interface

Allows user space applications to interact with the kernel Generally not invoked directly but rather through wrapper functions in the C runtime library, like glibc, newlib, …,

(22)

IHS - §7 Driver Intro 22

Linux embedded system (cont.)

System shared library

Linked with an user space application to provide it access to a specific system functionality

Abstracts the complexities of the kernel or direct driver access Examples (required by the Linux standard base): libc, libm,

libcrypt, …

Root filesystem

Stores all the files contained in the file hierarchy (including device nodes)

Includes, e.g., /bin, /sbin, /etc, /root, /tmp, /boot, /opt,

(23)

Build Embedded Linux Systems

Creating your own scripts

Using complete distributions, e.g., Ubuntu, Debian, Raspbian, … Preselected kernel version and a root filesystem with a

preselected set of libraries, utilities and applications Easy to get started, but harder to customize

Using Build frameworks, e.g., Buildroot, Yocto

Scripts and configuration meta-data that control the build process

Downloads, configures, compiles and installs all required components of the system taking version conflicts and dependencies into account

(24)

IHS - §7 Driver Intro 24

Build Framework Yocto

(25)

Typical Steps Using a Complete Distribution

Building the Linux kernel Cross-compile

Cross-compiler executables are prefixed by the name of the target system

Compress and write kernel image on SD card Use tools like Etcher

Copying Files

Transfer files from the host to the target using ssh

The IP address, the Netmask and Gateway need to be set Copy a simple “Hello World” app to the target system 


(26)

IHS - §7 Driver Intro 26

Tópicos

1) Device Driver Introduction 2) Linux embedded system

(27)

Cross Compile User Space Apps with Eclipse

1) New C Project

(28)

IHS - §7 Driver Intro 28

Cross Compile User Space Apps with Eclipse

(29)

Driver Development

A key concept in the design of the Linux embedded system is the separation of user applications from the underlying hardware

The hardware is exclusively accessed via kernel drivers Provides robustness

Provides portability

Device drivers can be kernel modules or statically built into the kernel image

Building a device driver as a module makes the development easier since it can be loaded, tested, and unloaded without rebooting the kernel

The kernel modules are usually located in /lib/modules/ <kernel_version>/ on the root filesystem

(30)

IHS - §7 Driver Intro 30

Cross Compile User Space Apps with Docker

InfoWorld article Containers 101: Linux container and Docker

explained: “[containers are] something that feels like a virtual

machine, but sheds all the weight and startup overhead of a guest operating system”

Advantage: Large number of already configured docker images available, e.g., docker pull mitchallen/pi-cross-compile

Build a “Hello, World” example with Docker: docker run -it -v ~/ raspberry/hello:/build mitchallen/pi-cross-compile

Uses a Makefile

(31)

Example: Cross Compile Linux Kernel

Docker image: docker pull simonvanderveldt/rpi3-kernel-builder

Checkout kernel sources: git clone --single-branch --branch rpi-4.14.y --depth 1 https://www.github.com/raspberrypi/linux

Build a kernel archive with the docker image using a volume mount:

docker run --rm -ti -v "${PWD}":/workdir rpi3-kernel-builder

To apply patches to the kernel sources make the patches available at PATCH_DIRS

The kernel can be configured using a defconfig:

make ARCH=arm bcm2709_defconfig make ARCH=arm menuconfig

(32)

Referências

Documentos relacionados

Neste trabalho estudamos as defini¸ c˜ oes, teoremas e exemplos sobre existˆ encia e unicidade de solu¸ c˜ oes, adimensionalisa¸ c˜ ao da equa¸ c˜ ao, princ´ıpio de

Mean value, F test and coefficient of variation (CV) for the leaf nitrogen content (LN), number of pods per plant (NPP), number of grains per pod (NGP), 100-grain weight (100GW)

Considerando então volume como sendo o resultado da quantidade de estímulos de treinamento em um determinado período, percebe-se diante dos resultados

Clique no link dentro do e-mail para confirmar seu e-mail e liberar sua conta.... Após confirmar seu e-mail irá surgir uma página com seus dados

Na forma de pagamento Pós-Paga ou na hi- pótese de haver a alteração automática da forma de pagamento para Pré-Paga durante o período de Permanência Mínima, no caso de

B) São entidades de atendimento aquelas que, de forma continuada, permanente e planejada, prestam serviços e executam programas e projetos voltados prioritariamente para

• O cérebro contém metade da quantidade total de fosfatidilserina do organismo; • Há decréscimo de fosfatidilserina com o envelhecimento (Cenacchi et al., 1993).. Níveis Teciduais

A associação com o complexo maior de histocompatibilidade (CMH) pertencente ao antígeno leucocitário humano (HLA) lócus DRB1 (HLA-DRB1) foi a primeira associação