25
Embedded platform choices Tavish Naruka BaseApp Systems

Embedded platform choices

Embed Size (px)

DESCRIPTION

Making a choice between and combining embedded platforms. From first delhi open hardware club meet.

Citation preview

Page 1: Embedded platform choices

Embedded platform choices

Tavish NarukaBaseApp Systems

Page 2: Embedded platform choices

Microcontroller or linux platform?Or both?

When prototyping

OR

Page 3: Embedded platform choices

System which uses only microcontrollers to function

System which has a linux cpu (may have microcontrollers too)

Page 4: Embedded platform choices

Working with microcontrollers

● First step is component selection○ Does the controller have all the interfaces required○ Voltage range, cost, memory sizes(flash and ram)○ Familiarity with the architecture, supported software,

documentation, even community○ debugger/programmer, toolchain○ Is some development kit available? If not, then can

you make a pcb for prototyping yourself? Maybe someone has published a design using this online

Page 5: Embedded platform choices

Some popular choices

● AVR is probably most popular due to arduino.

● PIC family of microcontrollers is also popular● ST microelectronics

● has a few not too expensive dev kits● TI MSP

Page 6: Embedded platform choices

Some dev kits

STM32F4 discovery Olimex PIC32-T79

MSP launchpad

Pinguino PIC32

Parallax propeller 8 core

Page 7: Embedded platform choices

Firmware

● Most code is in C, or assembly. sometimes C++

● compilers and chip makers often provides driver libraries and example code for things like USB, TCP/IP stack, and other peripherals

● The reference manual is usually a reference for a family of similar chips, and the datasheet is the ultimate reference

Page 8: Embedded platform choices

ARM Cortex M3 memory map

Page 9: Embedded platform choices

Peripherals and clocks on an STM ARM cortex m3 chip

Page 10: Embedded platform choices

● Input voltages● Memory layout● How does it boot● How do interrupts work in this chip● System clocks● Details about any peripherals you want to

use like USB, SPI, serial, DMA, timers etc.

Things to read in the manuals

Page 11: Embedded platform choices

Difference between bare metal and hosted programs

● Userspace programs running inside an operating system are hosted

● Code running on a microcontroller, (and linux kernel) are compiled for a freestanding environment. You (or mostly the compiler) provides C ‘runtime’

● C startup =○ Initialize stack, cannot use variables without it

(mostly), or call functions○ copy values to Initialized variables’ locations in RAM○ initialize globals to 0○ Copy read only data like strings to RAM

Page 12: Embedded platform choices

Why memory layout is important

● There is a well defined way how a chip boots, might start executing from a particular location

● Peripherals are memory mapped● Interrupt handlers, are locations reserved for function

pointers in some● If you want a bootloader, then the application code must

not have any portion located in flash occupied by bootloader

● This is done using linker scripts● The C startup code used locations exported by the

linker script to know where from/to copy or paste code

Page 13: Embedded platform choices

Why microcontrollers

● Small codebase, everything can be controlled● Instant on● Real-time behavior● Low power● Less supporting hardware● cheap● Low level things are easier to tweak than on linux

Page 14: Embedded platform choices

Why not microcontrollers

● limited choice of languages, toolchain● debugging can be difficult● File Systems, networking, graphics etc.

These things may be done on some microcontrollers, but with a lot more effort than if using linux

● application portability to a different system

Page 15: Embedded platform choices

Embedded linux platform

● Embedded, because its not general purpose, unlike a desktop

● Platform, because it can carry payload of your application, and become whatever specific purpose system you design it to be

Page 16: Embedded platform choices

Hardware

● Linux supports many architectures x86, x86_64, ARM, MIPS, powerpc, AVR32 etc.

● Not designed for small microcontrollers● RAM requirement depends on application,

but on a minimum is around 8MB

Page 17: Embedded platform choices

Where to get

● Evaluation board from chip manufacturer

AM335x starter kit from TI

Page 18: Embedded platform choices

cont..

● System on module

AM3352 SOM from olimex Carambola SOM placed on board

Page 19: Embedded platform choices

cont..

● Or designs/products by open hardware community● Could be from chip makers(like beaglebone from TI),

companies releasing usable boards(like A13 olinuxino from olimex)

● custom design

Allwinner A13 olinuxino iMX233 Locux BaseApp BeagleBone Black

Page 20: Embedded platform choices

cont..

● Consumer devices

A Router running linux

Belkin W

emo sw

itch

Smartphones

Smart tv

And lots of industrial Systems

Kindle

Page 21: Embedded platform choices

● Some ways to create a linux system(root filesystem) are ○ [Yocto project, openembedded, angstrom] ○ [Buildroot, Openwrt]○ debian debootstrap○ Can use full featured distros too, like debian(without

desktop environment)● Sometimes need to optimize for space/speed

○ provide common tools using busybox○ simpler init, only necessary programs run on boot○ only required drivers in kernel○ compressed fs like squashfs

Making a linux system for an embedded platform

Page 22: Embedded platform choices

Linux system boot process● (not x86)● first instructions execute a bootloader from

ROM which loads another bootloader, or sometimes linux kernel itself

● The bootloader loads the kernel, passes it kernel command line(can be hard coded in kernel image too)

● after loading, it jumps to the kernel’s entry point

● kernel command line option ‘rootfs’ is mounted

Page 23: Embedded platform choices

cont..

● After mounting rootfs, kernel looks for init program, which becomes the first process, and all other processes spawn from it.

● kernel loads modules as required● Usually init would be a standard program, like

○ systemV init○ systemd(debian uses this)○ upstart(ubuntu)○ busybox provided sysV init(common in embedded

systems to conserve space)● Init parses its init scripts to launch programs as required

Page 24: Embedded platform choices

● Suppose you need character LCD, keypad, CD ROM, SD card, network, USB hard disk

● Choose linux platform which is most suitable○ Needs USB, ethernet, fast enough

● Decide to use serial port to connect to a microcontroller, which connects to LCD and keypad

● If only one USB port, put usb hub● Linux has drivers for serial(for this particular

cpu), usb-storage(both hard disk and SD card), and usb CD ROM

Example application

Page 25: Embedded platform choices

cont..

● Program microcontroller so that it accepts commands for LCD on serial RX, sends keypad presses on serial TX

● Choose python to write application● Can mount/unmount hard disk/SD card(usb

mass storage) and cd-rom with mount/umount

● can use eject to open tray● can write to serial port with say pyserial● can access network easily