Intel Edison + Yocto - Como construir sua própria distribuição Linux Embarcado

intel edison yocto

A Intel está apostando algumas fichas nas aplicações de Internet das Coisas (IoT) através do lançamento de kits de desenvolvimento. Uma dessas apostas é a Intel Edison, que foi oficialmente lançada em CES 2014.

 

Juntamente com a placa, a Intel disponibiliza em seu site o Board Support Package (BSP) da Intel Edison compatível com o Yocto Project para desenvolvimento de distribuições Linux Embarcado, bem como aplicativos, bibliotecas e componentes para aplicações IoT.

 

Componentes do Intel IoT Developer Kit

 

intel iot developer kit components
Figura 1 - Intel IoT Developer Kit Components

 

Diversas IDEs, linguagens de programação e ferramentas estão disponíveis para desenvolvimento: 

  • Eclipse IDE - C/C++:
    • Eclipse IDE para Windows, Mac ou Linux;
    • Todas as ferramentas essenciais para desenvolvimento (cross-compiling tool chain, debugging e profiling tools);
    • Bibliotecas para conexão com a Galileo e Edison mais bibliotecas de sensores;
    • Templates e exemplos de como iniciar a construção de aplicações em IoT.
  • Intel® XDK IoT Edition - JavaScript:
    • Você pode construir uma solução completa em IoT usando aplicações Node.js e HTML5 embarcadas na placa.
  • Arduino IDE - Wiring e Sketches de Arduino;
  • Wyliodrin - Programação Visual:
  • Cloud Analytics:
    • Intel IoT Analytics inclui capacidades para coleta de dados, armazenamento e análise de sensores. Além disso ele pode gerar alertas e realizar análises avançadas. Este serviço é gratuito para aplicações não comerciais.
  • Intel System Studio for IoT:
    • Uma IDE que provém acesso avançado a nível de software e hardware para aumentar a velocidade de desenvolvimento, testes e otimizações. Suporta a Galileo e Edison com uso de debuggers (JTAG com openOCD) e compilador C++ com ferramentas e bibliotecas de performance da Intel. Ele está disponível através de licença trial para uso não comercial.

 

 

Intel Edison Yocto

 

Recentemente foi lançada a versão 2.1 da imagem Linux da Edison.

 

Você pode baixar e instalar a imagem Linux da Edison pré-compilada direto do site da Intel. O procedimento de gravação pode ser feito em máquinas Windows, Mac e Linux.

 

Nesse artigo mostraremos como gerar do zero uma imagem Linux Embarcado para a Intel Edison com o Yocto Project. Utilizaremos como Host uma máquina com Ubuntu 14.04.

 

 

Setup do Host

 

Primeiramente devemos instalar alguns pacotes para o correto funcionamento do Yocto e a gravação da imagem na Edison. Abra o terminal (Ctrl+Alt+T) e digite:

 

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat libsdl1.2-dev xterm gdebi libncurses5:i386 \
libstdc++6:i386 dfu-util

 

Agora vamos baixar os fontes do BSP:

 

mkdir -p ~/yocto/dl
mkdir -p ~/yocto/edison-bsp-2.1/
cd ~/yocto/edison-bsp-2.1/
wget http://downloadmirror.intel.com/24910/eng/edison-src-ww18-15.tgz
tar -xzf edison-src-ww18-15.tgz
cd edison-src
export BB_DL_DIR=~/yocto/dl

 

 

Construindo a imagem

 

Na pasta "~/yocto/edison-bsp-2.1/edison-src" e existe um Makefile que concentra todas as configurações e operações necessárias para construirmos a nossa imagem. Vamos executar dois comandos para baixar todos os fontes necessários (make setup) e para construir a imagem (make image):

 

make setup
make image

 

Agora relaxe, vá tomar um café e aproveite para estudar mais sobre o Yocto, pois o processo de construção é demorado quando feito pela primeira vez.

 

No final do processo você receberá essa mensagem no terminal:

 

Build Configuration:
BB_VERSION = "1.22.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "Ubuntu-14.04"
TARGET_SYS = "i586-poky-linux"
MACHINE = "edison"
DISTRO = "poky-edison"
DISTRO_VERSION = "1.6.1"
TUNE_FEATURES = "m32 core2"
TARGET_FPU = ""
meta 
meta-yocto 
meta-yocto-bsp = "(detachedfromyocto-1.6.1):c4f1f0f491f988901bfd6965f7d10f60cb94a76f"
meta-intel-edison-bsp 
meta-intel-edison-distro = "<unknown>:<unknown>"
meta-intel-iot-middleware = "(detachedfrom52ca21c):52ca21c1587ff7870599eee3a08179090af27848"
meta-intel-arduino = "<unknown>:<unknown>"

NOTE: Preparing runqueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 3609 tasks of which 3602 didn't need to be rerun and all succeeded.
./meta-intel-edison/utils/flash/postBuild.sh /home/dsueiro/yocto/edison-bsp-2.1/edison-src/out/current/build
EDISON_ROOTFS_MB = 1536, IMAGE_SIZE_MB = 512
1+0 records in
1+0 records out
4194304 bytes (4,2 MB) copied, 0,00608839 s, 689 MB/s
1+0 records in
1+0 records out
4194304 bytes (4,2 MB) copied, 0,0110309 s, 380 MB/s
1+0 records in
1+0 records out
4194304 bytes (4,2 MB) copied, 0,0064562 s, 650 MB/s
1+0 records in
1+0 records out
4194304 bytes (4,2 MB) copied, 0,00415899 s, 1,0 GB/s
1+0 records in
1+0 records out
4194304 bytes (4,2 MB) copied, 0,00923674 s, 454 MB/s
1+0 records in
1+0 records out
4194304 bytes (4,2 MB) copied, 0,0101175 s, 415 MB/s
1+0 records in
1+0 records out
4194304 bytes (4,2 MB) copied, 0,00879689 s, 477 MB/s
Image Name: Edison Updater script
Created: Sat May 30 06:48:22 2015
Image Type: PowerPC Linux Script (uncompressed)
Data Size: 14683 Bytes = 14.34 kB = 0.01 MB
Load Address: 00010000
Entry Point: 00010000
Contents:
 Image 0: 14675 Bytes = 14.33 kB = 0.01 MB
**** Done ***
Files ready to flash in /home/dsueiro/yocto/edison-bsp-2.1/edison-src/out/current/build/toFlash/
Run the flashall script there to start flashing.
*************

 

 

Gravando a imagem

 

Rode o comando a abaixo no terminal:

 

sudo make flash

 

E você verá a seguinte mensagem:

 

./out/current/build/toFlash/flashall.sh
Using U-Boot target: edison-blankcdc
Now waiting for dfu device 8087:0a99
Please plug and reboot the board

 

Posicione a chave SW1 próxima ao conector micro USB de acordo com a figura abaixo:

 

intel edison sw1 setup
Figura 2 - Posicionamento da chave SW1 para gravação do firmware

 

e conecte a Edison ao seu computador através do cabo micro USB:

 

intel edison usb setup
Figura 3 - Conexão USB para gravação do firmware

 

A placa será energizada e o processo de gravação será iniciado. No final teremos as seguintes mensagens no terminal:

 

Flashing IFWI
##################################################] finished!
##################################################] finished!
Flashing U-Boot
##################################################] finished!
Flashing U-Boot Environment
##################################################] finished!
Flashing U-Boot Environment Backup
##################################################] finished!
Rebooting to apply partition changes
Now waiting for dfu device 8087:0a99
Flashing boot partition (kernel)
##################################################] finished!
Flashing rootfs, (it can take up to 5 minutes... Please be patient)
##################################################] finished!
Rebooting
U-boot & Kernel System Flash Success...
Your board needs to reboot to complete the flashing procedure, please do not unplug it for 2 minutes.

 

Pronto, agora a sua Edison está rodando a versão 2.1 do Linux da Intel.

 

Se desejar você pode ter acesso a console serial da placa através do conector micro USB conectado ao computador conforme a figura abaixo:

 

intel edison console setup
Figura 4 - Conexão para console serial

 

Instale o aplicativo screen e abra a conexão com a placa:

 

sudo apt-get install screen
sudo screen /dev/ttyUSB0 115200

 

O usuário padrão da placa é "root" e não possui senha.

 

Abaixo você pode conferir o log de mensagens de boot:

 

******************************
PSH KERNEL VERSION: b0182b2b
                WR: 20104000
******************************

SCU IPC: 0x800000d0  0xfffce92c

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

microkernel built 11:24:08 Feb  5 2015

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

*** Ready to receive application *** 


U-Boot 2014.04 (May 25 2015 - 08:41:56)

       Watchdog enabled
DRAM:  980.6 MiB
MMC:   tangier_sdhci: 0
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0 
Target:blank
Partitioning already done...
Flashing already done...
GADGET DRIVER: usb_dnl_dfu
reading vmlinuz
5338432 bytes read in 132 ms (38.6 MiB/s)
Valid Boot Flag
Setup Size = 0x00003c00
Magic signature found
Using boot protocol version 2.0c
Linux kernel version 3.10.17-yocto-standard ([email protected]) #1 SMP PREEMPT Mon May 25 08:19:18 BRT 2015
Building boot_params at 0x00090000
Loading bzImage at address 00100000 (5323072 bytes)
Magic signature found
Kernel command line: "rootwait root=PARTUUID=012b3303-34ac-284d-99b4-34e03a2335f4 rootfstype=ext4 console=ttyMFD2 earlyprintk=ttyMFD2,keep logle"

Starting kernel ...

[    1.623850] snd_soc_sst_platform: Enter:sst_soc_probe
[    2.027763] pmic_ccsm pmic_ccsm: Error reading battery profile from battid frmwrk
[    2.045958] pmic_ccsm pmic_ccsm: Battery Over heat exception
[    2.046031] pmic_ccsm pmic_ccsm: Battery0 temperature inside boundary

Welcome to Linux!

         Expecting device dev-ttyMFD2.device...
[  OK  ] Reached target Remote File Systems.
         Expecting device dev-disk-by\x2dpartlabel-factory.device...
         Expecting device sys-subsystem-net-devices-usb0.device...
[  OK  ] Reached target Paths.
[  OK  ] Set up automount Arbitrary Executable File Formats F...utomount Point.
[  OK  ] Reached target Swap.
[  OK  ] Set up automount boot.automount.
[  OK  ] Created slice Root Slice.
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on udev Kernel Socket.
[  OK  ] Listening on Delayed Shutdown Socket.
[  OK  ] Listening on udev Control Socket.
[  OK  ] Listening on /dev/initctl Compatibility Named Pipe.
[  OK  ] Created slice User and Session Slice.
[  OK  ] Created slice System Slice.
         Starting udev Coldplug all Devices...
         Mounting POSIX Message Queue File System...
         Starting Journal Service...
[  OK  ] Started Journal Service.
         Starting Create list of required static device nodes...rrent kernel...
         Starting Apply Kernel Variables...
         Starting Load Kernel Modules...
         Mounting Debug File System...
[  OK  ] Reached target Slices.
         Starting Remount Root and Kernel File Systems...
[  OK  ] Created slice system-getty.slice.
[  OK  ] Created slice system-serial\x2dgetty.slice.
         Mounting Temporary Directory...
[  OK  ] Set up automount home.automount.
[  OK  ] Mounted Debug File System.
[  OK  ] Mounted POSIX Message Queue File System.
[  OK  ] Mounted Temporary Directory.
[  OK  ] Started Create list of required static device nodes ...current kernel.
[  OK  ] Started Apply Kernel Variables.
[  OK  ] Started Remount Root and Kernel File Systems.
[  OK  ] Started udev Coldplug all Devices.
[  OK  ] Started Load Kernel Modules.
         Mounting Configuration File System...
         Mounting FUSE Control File System...
         Starting Load/Save Random Seed...
         Starting Create Static Device Nodes in /dev...
[  OK  ] Mounted FUSE Control File System.
[  OK  ] Mounted Configuration File System.
[  OK  ] Started Load/Save Random Seed.
[  OK  ] Started Create Static Device Nodes in /dev.
         Starting udev Kernel Device Manager...
[  OK  ] Reached target Local File Systems (Pre).
         Mounting /var/volatile...
[  OK  ] Started udev Kernel Device Manager.
[  OK  ] Mounted /var/volatile.
[  OK  ] Reached target Local File Systems.
         Starting Trigger Flushing of Journal to Persistent Storage...
         Starting Create Volatile Files and Directories...
[  OK  ] Started Create Volatile Files and Directories.
         Starting Network Time Synchronization...
         Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Started Trigger Flushing of Journal to Persistent Storage.
[  OK  ] Found device /dev/ttyMFD2.
[  OK  ] Found device /dev/disk/by-partlabel/factory.
         Mounting Mount for factory...
[  OK  ] Mounted Mount for factory.
[  OK  ] Started Network Time Synchronization.
[  OK  ] Started Update UTMP about System Boot/Shutdown.
[  OK  ] Reached target System Initialization.
[  OK  ] Reached target Timers.
[  OK  ] Listening on D-Bus System Message Bus Socket.
         Starting Restore Sound Card State...
[  OK  ] Reached target Sound Card.
[  OK  ] Created slice system-systemd\x2dfsck.slice.
         Starting File System Check on /dev/disk/by-partlabel/home...
[  OK  ] Created slice system-systemd\x2drfkill.slice.
         Starting Load/Save RF Kill Switch Status of rfkill2...
         Starting Load/Save RF Kill Switch Status of rfkill0...
         Starting Load/Save RF Kill Switch Status of rfkill1...
[  OK  ] Started Load/Save RF Kill Switch Status of rfkill2.
[  OK  ] Started Load/Save RF Kill Switch Status of rfkill0.
[  OK  ] Started Load/Save RF Kill Switch Status of rfkill1.
[  OK  ] Found device /sys/subsystem/net/devices/usb0.
[    8.036399] systemd-fsck[174]: /dev/mmcblk0p10: recovering journal
[    8.100699] systemd-fsck[174]: /dev/mmcblk0p10: clean, 14/87120 files, 14183/348155 blocks
[  OK  ] Started File System Check on /dev/disk/by-partlabel/home.
         Mounting /home...
[  OK  ] Listening on sshd.socket.
[  OK  ] Mounted /home.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
         Starting Cleanjournal service...
[  OK  ] Started Cleanjournal service.
         Starting Crashlog service...
[  OK  ] Started Crashlog service.
         Starting Edison PWR button handler...
[  OK  ] Started Edison PWR button handler.
         Starting Daemon to load edison mcu app binary...
[  OK  ] Started Daemon to load edison mcu app binary.
Application available at (physical) address 0x04819000
        VRL mapped to 0xff217000
        App size = 11508 bytes

        App Authentication feature is disabled!
        Resetting IPC

*** Ready to receive application *** 
         Starting Start or stop WiFI AP Mode in Edison...
[  OK  ] Started Start or stop WiFI AP Mode in Edison.
         Starting Bluetooth rf kill event daemon...
[  OK  ] Started Bluetooth rf kill event daemon.
         Starting Daemon to handle arduino sketches...
[  OK  ] Started Daemon to handle arduino sketches.
         Starting Daemon to reset sketches...
[  OK  ] Started Daemon to reset sketches.
         Starting Login Service...
         Starting Permit User Sessions...
         Starting D-Bus System Message Bus...
[  OK  ] Started D-Bus System Message Bus.
         Starting Network Service...
         Starting Watchdog sample daemon...
[  OK  ] Started Watchdog sample daemon.
[  OK  ] Started Permit User Sessions.
[  OK  ] Started Network Service.
[  OK  ] Started Login Service.
         Mounting Arbitrary Executable File Formats File System...
         Starting Network Name Resolution...
[  OK  ] Reached target Network.
         Starting Zero-configuration networking...
         Starting Mosquitto - lightweight server implementati...SN protocols...
         Starting Getty on tty1...
[  OK  ] Started Getty on tty1.
         Starting Serial Getty on ttyMFD2...
[  OK  ] Started Serial Getty on ttyMFD2.
[  OK  ] Reached target Login Prompts.
[  OK  ] Mounted Arbitrary Executable File Formats File System.
[  OK  ] Started Network Name Resolution.
[  OK  ] Started Restore Sound Card State.
[  OK  ] Started Mosquitto - lightweight server implementatio...T-SN protocols.
[  OK  ] Started Zero-configuration networking.
         Starting The Edison status and configuration service...
[  OK  ] Started The Edison status and configuration service.
         Starting Intel_XDK_Daemon...
[  OK  ] Started Intel_XDK_Daemon.
         Starting File System Check on /dev/disk/by-partlabel/boot...
         Starting PulseAudio Sound System...
[   11.195640] systemd-fsck[252]: dosfsck 2.11, 12 Mar 2005, FAT32, LFN
[   11.198015] systemd-fsck[252]: /dev/mmcblk0p7: 5 files, 2695/2923 clusters
[  OK  ] Started File System Check on /dev/disk/by-partlabel/boot.
         Mounting /boot...
[  OK  ] Mounted /boot.
         Starting Bluetooth service...
[  OK  ] Started PulseAudio Sound System.
[  OK  ] Started Bluetooth service.
[  OK  ] Reached target Multi-User System.

Poky (Yocto Project Reference Distro) 1.6.1 edison ttyMFD2

edison login: 

 

 

Créditos

 

Imagem de destaque: http://dfrobot.com

Figura 1: http://www.slideshare.net/IntelSoftware

Figuras 2, 3 e 4: https://software.intel.com

 

Para saber mais

 

Embedded Linux Build Systems

Cozinhando com o Yocto Project

Desvendando Yocto Project – Primeiros passos

NEWSLETTER

Receba os melhores conteúdos sobre sistemas eletrônicos embarcados, dicas, tutoriais e promoções.

Obrigado! Sua inscrição foi um sucesso.

Ops, algo deu errado. Por favor tente novamente.

Licença Creative Commons Esta obra está licenciada com uma Licença Creative Commons Atribuição-CompartilhaIgual 4.0 Internacional.

Diego Sueiro
Formado em Engenharia de Controle e Automação pela UNIFEI e CEO do Embarcados, atualmente trabalho na Inglaterra com Desenvolvimento de Sistemas Linux Embarcado Real Time. Sou consultor e desenvolvedor de software para Sistemas Embarcados com vasta experiência em projetos com processadores de 8bits a 32bits, sistemas bare metal, RTOS, Linux Embarcado e Android Embarcado. Um apaixonado por Pink Floyd e Empreendedorismo.

Deixe um comentário

avatar
 
  Notificações  
Notificar