how to hack edison

48
Agenda What is Edison? Play with Edison Yocto 101 Connect Hardware

Upload: shotaro-uchida

Post on 05-Jul-2015

3.519 views

Category:

Technology


0 download

DESCRIPTION

Bay Area Kernel/VM Hackers, Nov 3, 2014

TRANSCRIPT

Page 1: How to Hack Edison

Agenda

● What is Edison?● Play with Edison● Yocto 101● Connect Hardware

Page 2: How to Hack Edison

What is Edison?

Page 3: How to Hack Edison

Overview

● Tiny computer to make IoT/Wearable device● Dual x86 core SoC (Atom Z34XX + Quark)● WiFi/BT combo (BCM43340)

– W/ chip antenna

● No graphics at all– GPU has been disabled

● Linux kernel is available– Forked from 3.10 yocto kernel

Page 4: How to Hack Edison

What you can do

● Run Linux kernel– W/ WiFi+BT functions

● Run Arduino sketch (top on Linux)

Page 5: How to Hack Edison

What you cannot do (So far...)

● No BSP other than Linux● Play with Quark● Unleash GPU power● Hardware video enc/dec acceleration

Page 6: How to Hack Edison

Edison Alternatives?

Application Processorbased

Microcontroller based

Page 7: How to Hack Edison

Edison Alternatives?

Linux Video/Graphics Low-power Making your own device(Custom PCB)

Arduino No No Yes Very Easy(AT Mega)

mbed No No Yes Easy(Cortex-M devices)

Raspberry Pi Yes Yes No(C)

Almost Impossible(BCM2835)

Beagle Bone Yes Yes No Difcult(AM335x)

Edison Yes No Reasonable Easy

Page 8: How to Hack Edison

Edison is something diferent

● Yes it's x86.● No Video/Graphics, but full featured Linux.● Not low-power as uCs, but still reasonable

power consumption.– Approx. 200mA without connectivity

– You can sleep device easily

● Tiny integrated module, not a “dev board”

Page 9: How to Hack Edison

Current Buying Options

++ +

For wimpsDecent choice

For rich people

Fortrue enthusiasts

Page 10: How to Hack Edison

Current Buying OptionsSparkFun Amazon Mouser Fry's Sunnyvale

Edison 49.95 49.99 53.40@10 49.99

Edison + Minibreakout

74.95 67.84 69.00 59.99

Edison +Arduino board

99.95 N/A 99.00 84.99

Edison +Sparkfun boards

(Pre-Order)

79.90 – 200 ormore

N/A N/A N/A

GO FRY'S NOW

Page 11: How to Hack Edison

Why you should not buy“Arduino board”

● You want “Arduino-compatible-pin-header”?Really?

● Price is expensive– Too much components to make it “compatible”

with Arduino shields*

● Though Intel recommend beginners to buy thisboard, documents are crap.

*Edison logic level is 1.8Vc

Page 12: How to Hack Edison

Play with Edison

Page 13: How to Hack Edison

Powering up

Page 14: How to Hack Edison

Booting

******************************PSH KERNEL VERSION: b0182727 WR: 20104000******************************

SCU IPC: 0x800000d0 0xfffce92c

PSH miaHOB version: TNG.B0.VVBD.0000000c

microkernel built 23:15:13 Apr 24 2014

******* PSH loader *******PCM page cache size = 192 KB Cache Constraint = 0 PagesArming IPC driver ..Adding page store pool ..PagestoreAddr(IMR Start Address) = 0x04899000pageStoreSize(IMR Size) = 0x00080000

*** Ready to receive application ***

U-Boot 2014.04 (Nov 01 2014 - 02:50:55)

Watchdog enabledDRAM: 980.6 MiBMMC: tangier_sdhci: 0In: serialOut: serialErr: serialHit any key to stop autoboot: 0

Page 15: How to Hack Edison

Powering up(Mini Breakout)

USB Micro B(For Console)

USB Micro AB(For OTG)

Ext. Power 7-17V

Li-PoBattery

● 3 Methods– 5V via OTG

– External DC-in

– Li-Po Battery

● OTG host will onlyworks with DC-in

● Li-Po will charged at190mA

– i.e. Connect 190mAhor higher

Recommend external DC-InBE CAREFUL WITH POLARITY

Edison

Page 16: How to Hack Edison

Powering up(Bare Module)

EdisonVSYS

Where VSYS is: 3.15-4.5V i.e. VBAT voltageDo NOT connect 5V

Page 17: How to Hack Edison

Booting

******************************PSH KERNEL VERSION: b0182727 WR: 20104000******************************

SCU IPC: 0x800000d0 0xfffce92c

PSH miaHOB version: TNG.B0.VVBD.0000000c

microkernel built 23:15:13 Apr 24 2014

******* PSH loader *******PCM page cache size = 192 KB Cache Constraint = 0 PagesArming IPC driver ..Adding page store pool ..PagestoreAddr(IMR Start Address) = 0x04899000pageStoreSize(IMR Size) = 0x00080000

*** Ready to receive application ***

U-Boot 2014.04 (Nov 01 2014 - 02:50:55)

Watchdog enabledDRAM: 980.6 MiBMMC: tangier_sdhci: 0In: serialOut: serialErr: serialHit any key to stop autoboot: 0

Page 18: How to Hack Edison

Boot process

Trusted Boot ROM U-Boot Kernel

Page 19: How to Hack Edison

Working with WiFi

● Intel ofers “quick setup” script called“confgure_edison”

– Many people use this script.

● Intel also ofers connection manager daemoncalled “ConnMan”

– Many people think it is more difficult to handle,which is not.

– Easy to use, and scalable.

Page 20: How to Hack Edison

Quick Start ConnMan

~# systemctl start connman~# systemctl start wpa_supplicant~# connmanctlconnmanctl> enable wificonnmanctl> scan wificonnmanctl> agent onconnmanctl> connect wifi_xxxxxxxxxxxx_xxx_xxx

Page 21: How to Hack Edison

Quick Start ConnMan

● Make sure connman and wpa_supplicant isworking

● connmanctl is a tiny CLI to full accessconnman API

Page 22: How to Hack Edison

ConnMan Overview

● Connection manager developed by Intel● It was a part of Moblin/MeeGo project● Fully modular system● Lightweight● Designed to be running on embedded device,

tablet, phone.

Page 23: How to Hack Edison

ConnMan API

● All APIs are D-Bus interface● Manager API● Technology API● Service API● Session API● Agent API● VPN

Page 24: How to Hack Edison

Technology API

● Enable● Disable

– rfkill

● Settings● Scan

– AP Scan

● Tethering– Edison supports

tethering!

Page 25: How to Hack Edison

Service API

● Connect● Disconnect● Get details

– SSID

– Strength

Page 26: How to Hack Edison

Session API

WiFiService

WiFiService

LTEService

LTEService

EtherService

Keep one Session whileusing many Services

Page 27: How to Hack Edison

Agent API

● API layer for UI● ConnMan requests

passphrase input viaAgent API

Example:Requesting a passphrase for WPA2 network

RequestInput("/service1",{ "Passphrase" : { "Type" : "psk",

"Requirement" : "mandatory"}

}==> { "Passphrase" : "secret123" }

Page 28: How to Hack Edison

Quick Start SSH

[Unit]Conflicts=sshd.service

[Socket]ExecStartPre=/bin/mkdir -p /var/run/sshdListenStream=22# restrict access to wired access for security reasons# comment this line to remove restrictionBindToDevice=usb0 <-- Comment hereAccept=yes

[Install]WantedBy=sockets.target

vi /lib/systemd/system/sshd.socket

Page 29: How to Hack Edison

Yocto 101

It's not an embedded Linux distribution– it creates a custom one for you

Page 30: How to Hack Edison

Overview

● Build tool to create your own distribution– Build your Toolchain

– Build your Bootloader/Kernel

– Build your RootFS

● Merged with OpenEmbedded– OE-Core/Yocto

● Using BitBake– Embedded-target version of Portage(Gentoo)

Page 31: How to Hack Edison

Architecture

Page 32: How to Hack Edison

Workfow - Recipes

Recipe

● Source codes?● Config files?● Patches?● Compile options?● Target(s)?

Build Package

Page 33: How to Hack Edison

Workfow - Packages

Meta Layer

PackagesYour RepositoryMeta Layer

Meta Layer

Page 34: How to Hack Edison

Workfow - Deploy

Packages

Kernel

zImage

U-Boot

u-boot.bin

CrossToolchain

RootFS(chroot-ed)

Deployrootfstar.gz

Here also use a recipecalled “image recipe”

Deploy

Deploy

Page 35: How to Hack Edison

Workfow - Cross build

Packages(for Host)

Recipes(for Host)

CrossToolchain

Packages(for Target)

Recipes(for Target)

TargetImages

Page 36: How to Hack Edison

What is Poky?

● Poky is the “reference distribution” of Yocto– You may fork poky to create your own

● Basic recipes– Yocto reference kernel

– OE-Core

– Basic image recipes

● Reference setup– Determine preferred version for each recipes

– Determine preferred init● sysvinit

Page 37: How to Hack Edison

Quick Start Yocto - Prerequisite

● Host Linux build machine– I use Ubuntu 14.04 LTS

– Actually “Intel-flavored-poky” supports otherbuild machine. (i.e. Windows and Mac) But Iwould not recommend.

● “Edison Linux source fles” from ofcial site● $ sudo apt-get install build-essential git diffstat gawk chrpath

texinfo libtool gcc-multilib

Page 38: How to Hack Edison

Quick Start Yocto

$ cd edison-src$ ./device-software/setup.sh$ source poky/oe-init-build-env$ bitbake edison-image

Extract Edison Linux source fles then,

Page 39: How to Hack Edison

Quick Start Yocto

edison-src$ ls build/tmp/deploy/images/edison/bzImage modules-edison.tgzbzImage--3.10.17+git0+6ad20f049a_c03195ed6e-r0-edison-20141101085834.bin README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txtbzImage-edison.bin u-boot.binedison-image-edison-20141101085834.hddimg u-boot-edison-2014.04-1-r0.binedison-image-edison-20141101085834.rootfs.ext4 u-boot-edison-2014.04-1-r0.imgedison-image-edison-20141101085834.rootfs.manifest u-boot-edison.binedison-image-edison.ext4 u-boot-edison.imgedison-image-edison.hddimg u-boot-envsedison-image-edison.manifest u-boot.imgmodules--3.10.17+git0+6ad20f049a_c03195ed6e-r0-edison-20141101085834.tgz

3-4 hours later....

Hooray!

Page 40: How to Hack Edison

Quick Start Yocto

$ device-software/utils/flash/postBuild.sh$ build/toFlash/flashall.sh

To fash image to EdisonConnect Edison (via OTG) then,

Page 41: How to Hack Edison

Poky-Edison?

● Intel-forked version of poky● Using systemd (Yes seriously) instead of

sysvinit

Page 42: How to Hack Edison

Connect Hardware

Page 43: How to Hack Edison

Basic Interfaces

● GPIO– Digital I/O, PWM

● I2C– Edison has 2 I2C port.

● SPI● UART

– Edison has 2 UART port, but 1 for debuggingnormally.

REMEMBER: Edison logic level is 1.8V!!

Page 44: How to Hack Edison

Additional Interfaces

● I2S– For ADC/DAC (audio codecs)

● SD– You need level shifter :(

● USB

REMEMBER: Edison logic level is 1.8V!!

Page 45: How to Hack Edison

How to use them?

● Linux standard methods– User space

– Kernel module

● MRAA(+UPM) (for basic interfaces)– A part of Intel iot-devkit project (Galileo)

● Arduino Library (for basic interfaces)– Need to hack around to use other than Arduino

board.

● Quark bare metal– Not available so far

Page 46: How to Hack Edison

Using GPIO

● sysfs– Standard method

– Used by MRAA and Arduino lib

● PCI device– Fast path to read/write

– Example included in Intel-Arduino source

● Kernel– True interrupt

Page 47: How to Hack Edison

Quick Start MRAA (C)

#include "mraa.h"

void main() {mraa_gpio_context gpio;

mraa_init();gpio = mraa_gpio_init(8);mraa_gpio_dir(gpio, MRAA_GPIO_OUT);mraa_gpio_write(gpio, 1);mraa_gpio_close(gpio);

}

Page 48: How to Hack Edison

Quick Start MRAA (JS)

var m = require('mraa');var myLed = new m.Gpio(13);myLed.dir(m.DIR_OUT);myLed.write(1);