레이블이 EVM-RaspberryPi3-B인 게시물을 표시합니다. 모든 게시물 표시
레이블이 EVM-RaspberryPi3-B인 게시물을 표시합니다. 모든 게시물 표시

3/15/2020

Raspberry Pi3 에 Yocto 와 Qt 적용한 Image (정리못함)

1. Raspberry Pi 와 Qt5 관련정보사항 


Yocto Recipe 작성방법 


기본적으로 Raspberry Pi 기반으로 나만의 Qt를 이용하여 나만의 Yocto로 구성하고자하는 마음으로 이것을 시작했다. 

  • Raspberry Pi용 Image 생성 (Yocto 기반)
Raspberry Pi에 적용할 Yocto 기반으로 구성된 Qt를 포함 Image를 생성하는 방법 
  1. 이미 구성된 Yocto Layer들과 Recipe들을 직접 Download 
  2. Yocto의 각 Layer들 별로 Download 후 별도의 Image Recipe를 구성하여 빌드 

간단하게만 Build 테스트 만 했지만, 실제로 Image를 Write해서 다 확인하지는 않았으며, 틀린부분은 추후 시간이 있을 때 수정하여 보완하도록 하자.

  • 상위 진행결과   
완벽히는 구성을 못했지만, Qt기반으로 실행가능한 정도로만 구성하여 동작확인을 하였다. 
아래와 같이 Laptop이 아래와 같이 Ubuntu Laptop 지워져서 정리 포기함  

상위 부분은 앞으로 진행못할 거 같으며, 추후 기회가 있다면 그때 다시 하도록 하자. 
그리고, 아래의 내용은 이전에 정리해둔 것이므로 나중에 참조만 하도록하자.
이후 변경된 내용은 백업을 못한 내 잘못이 더 크다. 

그리고, 칩제조사 TI/NXP에서 제공하는 Yocto가 아닌 Poky 와 OpenEmbedded 기반으로 간단하게 구성하여 누구나 할 수 있다. 


1.1  이미 구성된 Yocto 기반으로 Image 생성 

Yocto를 별도로 구성할 필요 없이 repo를 이용하여 Yocto를 전체 Layer들을 직접 Download 한 후 Manual 대로 설정 한 후 bitbake로 실행하여 Image 생성 


QT 관련설치
  https://doc.qt.io/QtForDeviceCreation/qtee-custom-embedded-linux-image.html
  https://code.qt.io/cgit/yocto/boot2qt-manifest.git/tree/

  • 기존에 존재하는 Yocto (QT 테스트)
아래와 같이 처음 Qt 테스트 진행 
$ sudo apt-get install gawk curl git-core git-lfs diffstat unzip texinfo build-essential \
chrpath libsdl1.2-dev xterm gperf bison gcc-multilib g++-multilib repo

$ cd rasp-qt

$ repo init -u git://code.qt.io/yocto/boot2qt-manifest -m warrior.xml  // ok

$ repo init -u git://code.qt.io/yocto/boot2qt-manifest -m zeus.xml // not work 

$ repo sync

$ MACHINE=raspberrypi3 source ./setup-environment.sh

$ bitbake b2qt-embedded-qt5-image

$ bitbake meta-toolchain-b2qt-embedded-qt5-sdk


2. Yocto 의 Layer를 직접 구성 후 Image 생성 

본인이 Yocto의 Main인 Poky 부터 필요한 Layer들을 각 모아서 구성한 후, 필요한 Image recipe 역시 직접 만들어서 구성한 후, 
이 기반으로 최종 Raspberry Pi Image 생성 

  • 이전에 구성한 Raspberry Pi Yocto 

  • Yocto에서 먼저확인 해봐야할 것
Yocto의 Version 정보와 Dependencies 이 될 것 같다. 
항상 최신버전만을 받았지만, 이번에는 다양한 Version을 받아보기 위해서 일단 아래에서 branch 정보를 파악해서 원하는 것으로 받기로 했다.

  • QT 설치방법 
현재 Image가 안되며, layer를 추가한 후 아래 medium을 똑같이 해보자
  https://makersweb.net/embedded/12540
  https://medium.com/@shigmas/yocto-pi-and-qt-e9f2df38a610
  https://jumpnowtek.com/rpi/Raspberry-Pi-Systems-with-Yocto.html

  • Yocto Version(Branch) 정보확인 
Yocto에 Version에 부여된 이름이 각각 존재 (zeus로 version(branch) 결정)

  • 본인 설치할 Layer 선택
  1. ref -> Branch 및 Tag  확인 
  2. about->Dependencies 확인 
  http://git.yoctoproject.org/cgit.cgi/
  https://www.yoctoproject.org/software-overview/layers/
  http://layers.openembedded.org/layerindex/branch/master/layers/


  • meta-raspberrypi 의 branch 파악
Yocto version: zeus 파악
  http://git.yoctoproject.org/cgit.cgi/meta-raspberrypi/refs/
  https://js94.tistory.com/entry/Yocto-Project-Reference-manual-chap3-35

  • Yocto 의 Layer를 각 구성 방법  
  1. 상위와는 다르게 각각의 Layer들을 별도로 다운받아 본인 직접구성 (poky, openembedded)
  2. 별도의 Layer들을 추가하는 방식으로 구성
  3. 추후 더 필요하다면 확장하는 방식으로 구성 
$ mkdir -p works/raspberrypi/sources

$ cd works/raspberrypi/source

$ pwd
/home/jhlee/works/raspberrypi/sources

$ git clone -b zeus  git://git.yoctoproject.org/poky
$ git clone -b zeus  git://git.openembedded.org/meta-openembedded
$ git clone -b zeus  https://github.com/agherzan/meta-raspberrypi
$ git clone -b zeus  git://github.com/meta-qt5/meta-qt5.git       // 처음에 못찾다가 상위 Layer에서 찾음 


  • 기본구성 후 conf/machine 확인 
우선 machine Layer 의 설정을 알기 위해서 검색 
물론 QEMU도 확인가능 
$ find . -name machine | xargs ls   // conf/machine 관련된 부분 전부 검색 
./meta-raspberrypi/conf/machine:
include     raspberrypi0-wifi.conf  raspberrypi3-64.conf  raspberrypi4-64.conf  raspberrypi-cm3.conf  raspberrypi.conf
raspberrypi0.conf  raspberrypi2.conf    raspberrypi3.conf  raspberrypi4.conf     raspberrypi-cm.conf

./poky/meta/conf/machine:
include  qemuarm.conf qemumips64.conf  qemuppc.conf    qemux86-64.conf
qemuarm64.conf qemuarmv5.conf qemumips.conf  qemuriscv64.conf  qemux86.conf

./poky/meta-selftest/conf/machine:
qemux86copy.conf

./poky/meta-yocto-bsp/conf/machine:
beaglebone-yocto.conf  edgerouter.conf genericx86-64.conf  genericx86.conf  include  mpc8315e-rdb.conf 

MACHINE 설정부터 BBLAYERS 확인  
$ find . -name local.conf*  // conf/local.conf 부분 검색 
./poky/meta-poky/conf/local.conf.sample
./poky/meta-poky/conf/local.conf.sample.extended


$ vi ./poky/meta-poky/conf/local.conf.sample  // 추후 build에 이 파일 기준으로 적용됨 
....
MACHINE ?= "raspberrypi3-64"
# This sets the default machine to be qemux86-64 if no other machine is selected:
#MACHINE ??= "qemux86-64"


$ vi ./poky/meta-poky/conf/bblayers.conf.sample // 추후 build에 이 파일 기준으로 적용됨, Build 설정 이후로 수정하기로 결정  

BBLAYERS ?= " \
  ##OEROOT##/meta \
  ##OEROOT##/meta-poky \
  ##OEROOT##/meta-yocto-bsp \
  "

  • 현재 구성된 Yocto 구성도 

$ pwd
/home/jhlee/works/raspberrypi/sources

$ tree -t -L 2   // Yocto 전체 Layer와 각 구성확인 
.
├── meta-openembedded
│   ├── contrib
│   ├── COPYING.MIT
│   ├── meta-filesystems
│   ├── meta-gnome
│   ├── meta-initramfs
│   ├── meta-multimedia
│   ├── meta-networking
│   ├── meta-oe
│   ├── meta-perl
│   ├── meta-python
│   ├── meta-webserver
│   ├── meta-xfce
│   └── README
├── meta-raspberrypi
│   ├── classes
│   ├── conf
│   ├── COPYING.MIT
│   ├── docs
│   ├── dynamic-layers
│   ├── files
│   ├── README.md
│   ├── recipes-bsp
│   ├── recipes-connectivity
│   ├── recipes-core
│   ├── recipes-devtools
│   ├── recipes-graphics
│   ├── recipes-kernel
│   ├── recipes-multimedia
│   └── wic
├── poky
│   ├── bitbake
│   ├── contrib
│   ├── documentation
│   ├── LICENSE
│   ├── LICENSE.GPL-2.0-only
│   ├── LICENSE.MIT
│   ├── meta
│   ├── meta-poky
│   ├── meta-selftest
│   ├── meta-skeleton
│   ├── meta-yocto-bsp
│   ├── oe-init-build-env
│   ├── README.hardware -> meta-yocto-bsp/README.hardware
│   ├── README.OE-Core
│   ├── README.poky -> meta-poky/README.poky
│   ├── README.qemu
│   └── scripts
└── meta-qt5
    ├── classes
    ├── conf
    ├── COPYING.MIT
    ├── files
    ├── lib
    ├── licenses
    ├── README.md
    ├── recipes-connectivity
    ├── recipes-devtools
    ├── recipes-multimedia
    ├── recipes-python
    └── recipes-qt

  • Build 환경구성 
기본 Build 환경구성 확인 과 Build 
$ cd ..

$ pwd
/home/jhlee/works/raspberrypi

$ source sources/poky/oe-init-build-env rpi-build  // Yocto Poky 기반으로 Build 환경설정 
or
$ . sources/poky/oe-init-build-env rpi-build

### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'


Other commonly useful commands are:
 - 'devtool' and 'recipetool' handle common recipe tasks
 - 'bitbake-layers' handles common layer tasks
 - 'oe-pkgdata-util' handles common target package task

$ pwd
/home/jhlee/works/raspberrypi/rpi-build

  • Build 환경구성 확장  
BBLAYERS에 추가된 Layer들을 추가하여 확장하여 이를 확장 
$ cd .. 

$ pwd
/home/jhlee/works/raspberrypi

$ tree -t -L 2  // Yocto 전체 Layer 와 Build 관련부분 파악 
.
├── sources
│   ├── meta-openembedded
│   ├── meta-raspberrypi
│   ├── meta-qt5
│   └── poky
└── rpi-build
    └── conf

$ cd ./rpi-build  // Build 환경으로 다시  

$ JHLEE=$HOME/works/raspberrypi/sources

$ echo $JHLEE
/home/jhlee/raspberrypi/sources

$ cat conf/bblayers.conf 
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \
  /home/jhlee/works/raspberrypi/sources/poky/meta \
  /home/jhlee/works/raspberrypi/sources/poky/meta-poky \
  /home/jhlee/works/raspberrypi/sources/poky/meta-yocto-bsp \
  "

//meta-raspberrypi 필요한 Layer들 별도로 추가 (dependecies)
$ echo "BBLAYERS += \"$JHLEE/meta-openembedded/meta-oe\"" >> conf/bblayers.conf
$ echo "BBLAYERS += \"$JHLEE/meta-openembedded/meta-multimedia\"" >> conf/bblayers.conf
$ echo "BBLAYERS += \"$JHLEE/meta-openembedded/meta-networking\"" >> conf/bblayers.conf
$ echo "BBLAYERS += \"$JHLEE/meta-openembedded/meta-python\"" >> conf/bblayers.conf

$ echo "BBLAYERS += \"$JHLEE/meta-raspberrypi\"" >> conf/bblayers.conf
$ echo "BBLAYERS += \"$JHLEE/meta-qt5\"" >> conf/bblayers.conf

$ cat conf/bblayers.conf    // 최종 bitbake Layer 관련설정 확인  
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \
  /home/jhlee/works/raspberrypi/sources/poky/meta \
  /home/jhlee/works/raspberrypi/sources/poky/meta-poky \
  /home/jhlee/works/raspberrypi/sources/poky/meta-yocto-bsp \
  "
BBLAYERS += "/home/jhlee/works/raspberrypi/sources/meta-openembedded/meta-oe"
BBLAYERS += "/home/jhlee/works/raspberrypi/sources/meta-openembedded/meta-multimedia"
BBLAYERS += "/home/jhlee/works/raspberrypi/sources/meta-openembedded/meta-networking"
BBLAYERS += "/home/jhlee/works/raspberrypi/sources/meta-openembedded/meta-python"
BBLAYERS += "/home/jhlee/works/raspberrypi/sources/meta-raspberrypi"
BBLAYERS += "/home/jhlee/works/raspberrypi/sources/meta-qt5"

// priority 의 경우 어떻게 측정되는 지 추후 더 파악 (만약 Package가 제대로 설치되어있지 않으면 실행이 안됨) 
$ bitbake-layers show-layers  
NOTE: Starting bitbake server...
layer                 path                                      priority
==========================================================================
meta                  /home/jhlee/works/raspberrypi/sources/poky/meta  5
meta-poky             /home/jhlee/works/raspberrypi/sources/poky/meta-poky  5
meta-yocto-bsp        /home/jhlee/works/raspberrypi/sources/poky/meta-yocto-bsp  5
meta-oe               /home/jhlee/works/raspberrypi/sources/meta-openembedded/meta-oe  6
meta-multimedia       /home/jhlee/works/raspberrypi/sources/meta-openembedded/meta-multimedia  6
meta-networking       /home/jhlee/works/raspberrypi/sources/meta-openembedded/meta-networking  5
meta-python           /home/jhlee/works/raspberrypi/sources/meta-openembedded/meta-python  7
meta-raspberrypi      /home/jhlee/works/raspberrypi/sources/meta-raspberrypi  9
meta-qt5              /home/jhlee/works/raspberrypi/sources/meta-qt5  7


  • 전체 Image Recipe 찾기 
현재 사용중인 Image Recipe를 찾아 역으로 분석하여 기본구조를 파악하자 
$ find ../sources -name *image*.bb   // bitbake 의 image bb recipe 파일 전부 검색  
../sources/meta-openembedded/meta-filesystems/recipes-filesystems/images/meta-filesystems-image-base.bb
../sources/meta-openembedded/meta-filesystems/recipes-filesystems/images/meta-filesystems-image.bb
../sources/meta-openembedded/meta-webserver/recipes-core/images/meta-webserver-image-base.bb
../sources/meta-openembedded/meta-webserver/recipes-core/images/meta-webserver-image.bb
../sources/meta-openembedded/meta-multimedia/recipes-multimedia/images/meta-multimedia-image-base.bb
../sources/meta-openembedded/meta-multimedia/recipes-multimedia/images/meta-multimedia-image.bb
../sources/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb
../sources/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb
../sources/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb
../sources/meta-openembedded/meta-initramfs/recipes-core/images/meta-initramfs-image.bb
../sources/meta-openembedded/meta-networking/recipes-core/images/meta-networking-image.bb
../sources/meta-openembedded/meta-networking/recipes-core/images/meta-networking-image-base.bb
../sources/meta-openembedded/meta-xfce/recipes-core/images/core-image-minimal-xfce.bb
../sources/meta-openembedded/meta-python/recipes-core/images/meta-python-image-base.bb
../sources/meta-openembedded/meta-python/recipes-core/images/meta-python-ptest-image.bb
../sources/meta-openembedded/meta-python/recipes-core/images/meta-python-image.bb
../sources/meta-openembedded/meta-oe/recipes-core/images/meta-oe-image-base.bb
../sources/meta-openembedded/meta-oe/recipes-core/images/meta-oe-ptest-image.bb
../sources/meta-openembedded/meta-oe/recipes-core/images/meta-oe-image.bb
../sources/meta-openembedded/meta-oe/recipes-graphics/libsdl/libsdl-image_1.2.12.bb
../sources/meta-openembedded/meta-oe/recipes-graphics/libsdl/libsdl2-image_2.0.3.bb
../sources/meta-openembedded/meta-oe/recipes-support/imagemagick/imagemagick_7.0.8.bb
../sources/meta-openembedded/meta-perl/recipes-perl/images/meta-perl-ptest-image.bb
../sources/meta-openembedded/meta-perl/recipes-perl/images/meta-perl-image.bb
../sources/meta-raspberrypi/recipes-core/images/rpi-hwup-image.bb
../sources/meta-raspberrypi/recipes-core/images/rpi-basic-image.bb
../sources/meta-raspberrypi/recipes-core/images/rpi-test-image.bb
../sources/poky/meta-skeleton/recipes-multilib/images/core-image-multilib-example.bb
../sources/poky/meta-selftest/recipes-test/container-image/container-image-testpkg.bb
../sources/poky/meta-selftest/recipes-test/container-image/container-test-image.bb
../sources/poky/meta-selftest/recipes-test/images/wic-image-minimal.bb
../sources/poky/meta-selftest/recipes-test/images/test-empty-image.bb
../sources/poky/meta-selftest/recipes-test/images/error-image.bb
../sources/poky/meta-selftest/recipes-test/images/oe-selftest-image.bb
../sources/poky/meta-selftest/recipes-test/multiconfig/multiconfig-image-packager_0.1.bb
../sources/poky/meta/recipes-extended/images/core-image-kernel-dev.bb
../sources/poky/meta/recipes-extended/images/core-image-testmaster.bb
../sources/poky/meta/recipes-extended/images/core-image-full-cmdline.bb
../sources/poky/meta/recipes-extended/images/core-image-testmaster-initramfs.bb
../sources/poky/meta/recipes-rt/images/core-image-rt.bb
../sources/poky/meta/recipes-rt/images/core-image-rt-sdk.bb
../sources/poky/meta/recipes-core/images/core-image-minimal.bb
../sources/poky/meta/recipes-core/images/core-image-tiny-initramfs.bb
../sources/poky/meta/recipes-core/images/core-image-minimal-dev.bb
../sources/poky/meta/recipes-core/images/build-appliance-image_15.0.0.bb
../sources/poky/meta/recipes-core/images/core-image-minimal-mtdutils.bb
../sources/poky/meta/recipes-core/images/core-image-minimal-initramfs.bb
../sources/poky/meta/recipes-core/images/core-image-base.bb
../sources/poky/meta/recipes-core/ovmf/ovmf-shell-image.bb
../sources/poky/meta/recipes-sato/images/core-image-sato-dev.bb
../sources/poky/meta/recipes-sato/images/core-image-sato-ptest-fast.bb
../sources/poky/meta/recipes-sato/images/core-image-sato-sdk.bb
../sources/poky/meta/recipes-sato/images/core-image-sato-sdk-ptest.bb
../sources/poky/meta/recipes-sato/images/core-image-sato.bb
../sources/poky/meta/recipes-graphics/images/core-image-weston.bb
../sources/poky/meta/recipes-graphics/images/core-image-clutter.bb
../sources/poky/meta/recipes-graphics/images/core-image-x11.bb
../sources/poky/meta/recipes-graphics/xorg-lib/xcb-util-image_0.4.0.bb
../sources/meta-qt5/recipes-qt/qt5/qtimageformats_git.bb

$ cd ../sources/meta-qt5
$ mkdir -p recipes-core/images
$ cd recipes-core/images

$ vi core-image-qt5.bb     // Qt기반으로 Image Recipe 파일 직접구성 (기본은 core-image-base) 
$ cat core-image-qt5.bb 
SUMMARY = "Qt5 image that fully supports the target device hardware."
LICENSE="MIT"

include recipe-core/images/core-image-base.bb

QT_BASE = " \
    qtbase \
    qtbase-dev \
    qtbase-mkspecs \
    qtbase-plugins \
    qtbase-tools \
"
 
QT_PKGS = " \
    qt3d \
    qt3d-dev \
    qt3d-mkspecs \
    qtcharts \
    qtcharts-dev \
    qtcharts-mkspecs \
    qtconnectivity-dev \
    qtconnectivity-mkspecs \
    qtquickcontrols2 \
    qtquickcontrols2-dev \
    qtquickcontrols2-mkspecs \
    qtdeclarative \
    qtdeclarative-dev \
    qtdeclarative-mkspecs \
    qtgraphicaleffects \
    qtgraphicaleffects-dev \
"

IMAGE_INSTALL += " \
    ${QT_BASE} \
    ${QT_PKGS} \
"

export IMAGE_BASENAME = "core-image-qt5"

$ bitbake core-image-qt5

$ devtool build core-image-qt5 source 

$ bitbake -e |grep IMAGE_FSTYPE

$ find .. -name bitbake.conf
../sources/poky/bitbake/lib/bb/tests/runqueue-tests/conf/bitbake.conf
../sources/poky/meta/conf/bitbake.conf

Build는 되지만, Image가 생성이 안되었으며,  간단하게 따라한 것이니, 추후에 시간이 있을 경우, QT Package 와 함께 
그때 세부적 분석한 후 관련 Recipe들을 수정하여 구성하자. 
너무 대충 구성한 것 같음. 


  • 아래는 Image Recipe를 만들때, 너무 좋은 예제인 것 같아, 추후에 참조 
LoRa 작업을 하면서 아래 Recipe를 각각 다 만들었는데,  괜찮게 만든 것 같아 추후에 다시 참조하며, Raspberry Pi3에 넣도록 하자 
Raspberry Pi3 와 LoRa Gateway 검색해보면 관련자료는 많이 나온다. 

LoRa Gateway 와 Packet Forwarder 

더불어 QT에도 추후에 추가도 가능하며, 이 부분은 Background로 돌리수도 있다. 

$ vi ../sources/meta-lora-net/recipes-core/images/core-lora-image.bb
SUMMARY = "Lora Gateway Image dev image"

include recipes-core/images/core-image-base.bb

IMAGE_INSTALL += "lora-gateway lora-pkt-fwd"

export IMAGE_BASENAME = "core-lora-image"

my_postprocess_function() {
   echo "hello" > ${IMAGE_ROOTFS}/hello.txt
}

ROOTFS_POSTPROCESS_COMMAND += "my_postprocess_function; "


$ sample ROOTFS_POSTPROCESS_COMMAND
#
# Copyright (C) 2010 Intel Corporation.
#
require recipes-core/images/poky-image-minimal.bb

SRC_URI = "file://interfaces"

IMAGE_INSTALL += "dropbear mediatomb task-poky-nfs-server"

LICENSE = "MIT"

ROOTFS_POSTPROCESS_COMMAND += "setup_target_image ; "

# Manual workaround for lack of auto eth0 (see bug #875)
setup_target_image() {
       install -m 0644 ${WORKDIR}/interfaces ${IMAGE_ROOTFS}/etc/network/interfaces
}

$ gateway.bb

SUMMARY = "LoRa Gateway project"
SECTION = "libs/network"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=a2bdef95625509f821ba00460e3ae0eb"

SRC_URI = "https://github.com/Lora-net/lora_gateway/archive/v${PV}.tar.gz"

SRC_URI[md5sum] = "5d07f8471e1a67920787e3879afe0cb6"
SRC_URI[sha256sum] = "1a0447d5e8183d08e6dce5f739f6872b9c57824b98f4078830d5ee21b15782c1"

S = "${WORKDIR}/lora_gateway-${PV}"

CFLAGS_append = "-I ${S}/libloragw/inc -I ${S}/libloragw -I ${S}/util_pkt_logger/inc "

do_install() {
 bbplain "--------    Lora Gateway Install -----------------"
 install -d ${D}${bindir}
 install -d ${D}${docdir}
 install -d ${D}${libdir}/libloragw/inc
 install -d ${D}${includedir}/libloragw
 
 install -D -m 0644 ${B}/libloragw/inc/* ${D}${includedir}/libloragw
 
 install -D -m 0644 ${B}/libloragw/inc/* ${D}${libdir}/libloragw/inc
 install -D -m 0644 ${B}/libloragw/libloragw.a ${D}${libdir}/libloragw/libloragw.a
 install -D -m 0644 ${S}/libloragw/library.cfg ${D}${libdir}/libloragw/library.cfg
 
 install ${B}/libloragw/test_* ${D}${bindir}
 install ${B}/util_*/util_* ${D}${bindir}
 install ${S}/*.sh ${D}${bindir}
 
 install -D -m 0644 ${S}/readme.md ${D}${docdir}/libloragw/changelog.md
 install -D -m 0644 ${S}/libloragw/readme.md ${D}${docdir}/libloragw/README.md
 install -D -m 0644 ${S}/util_lbt_test/readme.md ${D}${docdir}/libloragw/util_lbt_test.md
 install -D -m 0644 ${S}/util_pkt_logger/readme.md ${D}${docdir}/libloragw/util_pkt_logger.md
 install -D -m 0644 ${S}/util_spectral_scan/readme.md ${D}${docdir}/libloragw/util_spectral_scan.md
 install -D -m 0644 ${S}/util_spi_stress/readme.md ${D}${docdir}/libloragw/util_spi_stress.md
 install -D -m 0644 ${S}/util_tx_continuous/readme.md ${D}${docdir}/libloragw/util_tx_continuous.md
 install -D -m 0644 ${S}/util_tx_test/readme.md ${D}${docdir}/libloragw/util_tx_test.md
 
 install -D -m 0644 ${S}/util_pkt_logger/global_conf.json ${D}${docdir}/libloragw/global_conf.json
 install -D -m 0644 ${S}/util_pkt_logger/local_conf.json ${D}${docdir}/libloragw/local_conf.json
}

PACKAGE_DEBUG_SPLIT_STYLE = "debug-without-src"

PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-dev ${PN}-staticdev"

# Avoid QA Issue: No GNU_HASH in the elf binary
INSANE_SKIP_${PN} = "ldflags"

FILES_${PN}-dbg = " \
 ${bindir}/.debug \
 ${libdir}/libloragw/.debug \
"
FILES_${PN} = " \
 ${bindir}/* \
 ${docdir}/* \
"
FILES_${PN}-dev = " \
 ${includedir}/libloragw/* \
"
FILES_${PN}-staticdev = " \
 ${libdir}/libloragw/inc/*.h \
 ${libdir}/libloragw/*.a \
 ${libdir}/libloragw/*.cfg \
"
FILES_${PN}-doc = " \
 ${docdir} \
"




$ packet.bb
SUMMARY = "LoRa network packet forwarder project"
SECTION = "libs/network"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=22af7693d7b76ef0fc76161c4be76c45"

SRC_URI = "https://github.com/Lora-net/packet_forwarder/archive/v${PV}.tar.gz"

SRC_URI[md5sum] = "a1f942e0cc7b02d604b11c8cb5f2a029"
SRC_URI[sha256sum] = "e68fadf6f1d2e5e7b601e504d5efb48b0a8f374c2c29c0476ab2fe9db68d33ae"

DEPENDS += "lora-gateway" 

S = "${WORKDIR}/packet_forwarder-${PV}"

CFLAGS_append = "-I ${includedir}/libloragw -I ${S}/lora_pkt_fwd/inc -I ${S}/util_tx_test/inc "

do_configure_prepend() {
 export LGW_PATH="${STAGING_LIBDIR}/libloragw"
}

do_compile_prepend() {
 export LGW_PATH="${STAGING_LIBDIR}/libloragw"
}

do_install() {
        bbplain "--------    Lora Packet Forward Install -----------------"
 install -d ${D}${bindir}
 install -d ${D}${docdir}/lora-pkt-fwd/conf
 
 install ${B}/lora_pkt_fwd/lora_pkt_fwd ${D}${bindir}
 install ${B}/util_*/util_* ${D}${bindir}
 
 install -D -m 0644 ${S}/PROTOCOL.TXT ${D}${docdir}/lora-pkt-fwd/PROTOCOL.TXT
 install -D -m 0644 ${S}/lora_pkt_fwd/readme.md ${D}${docdir}/lora-pkt-fwd/readme.md
 install -D -m 0644 ${S}/lora_pkt_fwd/global_conf.json ${D}${docdir}/lora-pkt-fwd/global_conf.json
 install -D -m 0644 ${S}/lora_pkt_fwd/local_conf.json ${D}${docdir}/lora-pkt-fwd/local_conf.json
 install -D -m 0755 ${S}/lora_pkt_fwd/update_gwid.sh ${D}${docdir}/lora-pkt-fwd
 install -D -m 0644 ${S}/lora_pkt_fwd/cfg/*.json.* ${D}${docdir}/lora-pkt-fwd/conf
 
 rm -f ${D}${bindir}/util_tx_test
 rm -f ${D}${bindir}/.debug/util_tx_test
}

PACKAGE_DEBUG_SPLIT_STYLE = "debug-without-src"

PACKAGES = "${PN}-dbg ${PN} ${PN}-doc"

# 상위에서 설명한 QA관련에러 
# Avoid QA Issue: No GNU_HASH in the elf binary
INSANE_SKIP_${PN} = "ldflags"

FILES_${PN}-dbg = " \
 ${bindir}/.debug \
"
FILES_${PN} = " \
 ${bindir}/* \
 ${docdir}/* \
"
FILES_${PN}-doc = " \
 ${docdir} \
"

$ packet.bbappend

## files로 만들경우, 기본 FILEPATH에 포함이 되어있으므로, 간단히 관리되며, Package 와 Version 별로 관리시 다음과 같이 관리  
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
#FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
#FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}"
SRC_URI += "file://001_packet_forwarder_lora_pkt_fwd.c.patch"
SRC_URI += "file://002_packet_forwarder_global_conf.json.patch"



ROOTFS_PREPROCESS_COMMAND
ROOTFS_POSTPROCESS_COMMAND
SDK_POSTPROCESS_COMMAND
POPULATE_SDK_POST_TARGET_COMMAND
POPULATE_SDK_POST_HOST_COMMAND
IMAGE_POSTPROCESS_COMMAND
IMAGE_PREPROCESS_COMMAND

ROOTFS_POSTINSTALL_COMMAND
           
  https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#migration-1.6-variable-changes-variable-entry-behavior

Yocto PTEST
  https://wiki.yoctoproject.org/wiki/Ptest
  https://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html#testing-packages-with-ptest


Image BB File 예제
  https://github.com/openembedded/openembedded-core/blob/master/meta/recipes-core/images/build-appliance-image_15.0.0.bb

Image BB File 예제와 PATCH
  https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842475/PetaLinux+Yocto+Tips

MD5 Checksum
  https://docs.windriver.com/bundle/Wind_River_Linux_Toolchain_and_Build_System_Users_Guide_8.0_1/page/tan1478821620236.html

  http://variwiki.com/index.php?title=Yocto_Build_Release

6/24/2018

MagicMirror and Smart Mirror 테스트

1. MagicMirror 

요즘 Raspberry Pi를 가지고 MagicMirror를 만들것이 유행이 되어서 그냥 따라해보기로 했다.
Magic Mirror는 LCD에  필름을 붙혀 거울처럼 사용하는데, 이 LCD에 각 기능을 넣어 Magic Mirror혹은 Smart Mirror라고 해서 사용하는데, 보기에도 편할 것 같다. 

  • 기본설정 
Raspberry Pi3 준비하고 Raspbian OS를 설치하고 기본설정을 해주자
  https://ahyuo.blogspot.com/2018/06/raspberry-pi3-raspbian-os.html

  • Magic Mirror 최종 결과물 및 설치방법 
  아래와 같이 자세히 설명해주는 Youtube
  https://www.youtube.com/watch?v=pcmjht0Hqvw

이미 소스는 존재하며,이를 이용하여 간단히 구현된 것을 보자

1.1 Node.js (NPM)

Web에 관련된 Node.js 관련사항을 잘 모르기때문에 간단히 아래와 같이 정리만 한다.
npm은 (Node Package Manager)라고 하면  아래 사이트에서 관리되는 것 같다.

NPM 사이트
  https://www.npmjs.com/

npm을 이용하여 Node.js를 관리하는 Package Manager라는데, 정확히 동작원리는 아직 모르겠다.

NPM관련내용
  https://ko.wikipedia.org/wiki/Npm_(%EC%86%8C%ED%94%84%ED%8A%B8%EC%9B%A8%EC%96%B4)


  • NPM 명령어 확인 
명령어가 많아서 사용을 해보면서 익혀야 할 것 같은데,  추후 Node.js에 관심을 가질때 그때 하도록하자.


$ npm help
Usage: npm 

where  is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
    explore, get, help, help-search, i, init, install,
    install-test, it, link, list, ln, login, logout, ls,
    outdated, owner, pack, ping, prefix, profile, prune,
    publish, rb, rebuild, repo, restart, root, run, run-script,
    s, se, search, set, shrinkwrap, star, stars, start, stop, t,
    team, test, token, tst, un, uninstall, unpublish, unstar,
    up, update, v, version, view, whoami

npm  -h     quick help on 
npm -l           display full usage info
npm help   search for help on 
npm help npm     involved overview

Specify configs in the ini-formatted file:
    /home/pi/.npmrc
or on the command line via: npm  --key value
Config info can be viewed via: npm help config


아래와 같이 쉽게 download가 Node.js를 node_modules에서쉽게 관리되는 것 같다.

$ npm install upper-case  # upper-case를 download를 한다고 함 
$ cd node_modules
$ ls upper-case  

아래와 같이 실행을 하면 npm에 관련된 package가 동작이 되는 것 같다.

$ cd ~/project
$ npm start 

NPM은 상위 node_modules는 Project 별로 별도로도 관리가 가능하며, 상위에 등록하고 싶다면 아래와 같이 하면된다.

$ cd ./usr/lib/node_modules/     # Main에 node_modules이 존재한것을 확인 가능 
$ ls
npm  pm2
$ ls /usr/bin/pm2       # 실행 파일 확인 
/usr/bin/pm2
$ ls /usr/bin/npm       # 실행 파일 확인 
/usr/bin/npm

pm2는 Autostart를 위해서 NPM package과 함께 shell script을 만들어 사용하는 것 같다.

NPM
  https://www.w3schools.com/nodejs/nodejs_npm.asp

PM2
  http://pm2.keymetrics.io/docs/usage/startup/

이것을 자세히 알려면 천상 Node.js까지 알아야 할 것 같은데,  그냥 기본 사용법만 알고 추후 시간되면 알아보자.

1.2 Magic Mirror 설치 및 동작 

  • Magic Mirror 및 Smart Mirror Github
  https://github.com/evancohen/smart-mirror
  https://github.com/MichMich/MagicMirror


$ bash -c "$(curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installers/raspberry.sh)"
or 
$ curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installers/raspberry.sh | bash

$ cd ~/MagicMirror
$ npm start 

상위처럼 하면 실행이 되지만 MagicMirror를 보면 내부에 config/config.js를 이용하여 각 Website의 키 값을 설정하도록 되어 있다.

  • pm2의 기능 
pm2를 이용하여 Autostart를 하는데 나에게 있어서 보고 한번 테스트 정도이지 별로 다 이용하고 싶지가 않은기능이다.

6/22/2018

Raspberry-Pi3 RASPBIAN OS 설정 및 VNC 연결

1. Raspberry 기본사용법 

Raspberry를 소스를 보면 거의 Node.js 즉 Javascript 기준으로 된 Project가 많으며, 이를 이해하기 위해서 아래와 같이 기본적으로 알아두자

  • Raspberry Pi Image Download
  https://www.raspberrypi.org/downloads/

  • Image Write 방법 
  https://ahyuo.blogspot.com/2017/10/raspberry-pi.html
  https://ahyuo.blogspot.kr/2016/05/sd-card-writer-window.html

HDMI 모니터를 지속적으로 사용하면 좋겠지만, 여분의 모니터가 없을 경우 VNC와 SSH를 이용하여 원격접속하여 Raspberry를 이용해야 할 것이다.

  • 기본사용법 
  https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp

  • GPIO 사용법 
  https://www.w3schools.com/nodejs/nodejs_raspberrypi_gpio_intro.asp
  https://wikidocs.net/3172
  https://wikidocs.net/20429

  • Raspberry Camera 연결 및 기본 사용법
Raspberry Pi용 Camera를 구입하여, CSI Interface로 연결하여 테스트 진행 
  https://wikidocs.net/3178
  https://wikidocs.net/3251
  https://www.raspberrypi.org/documentation/raspbian/applications/camera.md
  https://www.raspberrypi.org/documentation/configuration/camera.md


1.1. Raspberry HDMI 연결 

VNC와 SSH를 이용한다고 하더라도 처음 한번은 HDMI 모니터에 연결하여 아래와 같이 기본설정을 해줘야 한다.

  • Terminal 실행 (Mac 주소 파악)
우선 우측의 WIFI 접속하기전에 AP에 DHCP를 고정으로 할당하기 위해서 아래와 같이 Mac주소를 알아내자.
나의 경우는 Raspberry PI의 WIFI만 이용할 것이므로 wlan0의 Mac 주소로 할당을 할 것이다.


WLAN 과 ETH 상태확인 
$ ifconfig  //현재 wlan0 상태와 eth0 연결상태확인 
....
wlan0: flags=4163 up  mtu 1500
...
ether b8:27:eb:ba:e2:ad  
....

  1. 현재 사용중인 AP를 DHCP Server 상위 Mac Address에 맞게 고정 IP로 할당
  2. Raspberry의 상위 우측의 WIFI 연결 후  다시 설정된 IP확인 

WLAN 상태 및 기능확인 
$ iwconfig  // 현재 wlan0 의 ESSID 와 Mode 확인 (Managed)
wlan0     IEEE 802.11 ESSID:"JHLEE_AP"
          Mode:Managed   Frequecy:2.417 GHz .....
          ....
          
          
$ iw list // WIFI Phy 정보도 확인가능 (monitor 모드 미제공)
....
Supported interface mode:  //이부분 확인 후  다음 Supported TX/RX Frame Tyepe 확인 
    * IBSS
    * manged
    * AP
    * P2P-Client
    * P2P-GO
    * P2P-device 
    ....
    
    software interface modes (can always be added):  // 이 부분 확인     

WLAN0 monitor 모드 
Raspberry Pi에서 monitor 모드 사용하고자하면, USB Dongle을 이용하시길 

  • GUI 화면 SSH Server 및 VNC Server 설정 
GUI 화면에서 아래와 같이 상단 좌측의 위 버튼을 누르면 아래와 같이 설정 가능하다
쉽게

  Preferences->Raspberry Pi Configuration->Interfaces



Interfaces 에서 VNC와 SSH 및 Camera를 Enable 해주고, 아래와 같이 GUI 우측 상단에 WIFI 설정을 하여 AP에 연결하자


만약 Terminal에서 AP를 설정한다고 하면 아래와 같이 해주자.

$ sudo vi /etc/wpa_supplicant/wpa_supplicant.conf 
network={
        ssid="JHLEE_AP"
        psk=xxxxx"          # Password 
        key_mgmt=WPA-PSK
}

1.2 VNC Server 와 VNC Viewer 설치 

Raspberry 안에 VNC Server를 설치 후 Window/Linux에서 VNC Viewer(Client)를 통해 Display 장치 없이 원격으로 이를 제어하자. 

  • VNC Server 와 VNC Viewer 확인 
기본적으로 Rasbperry Pi Image에  VNC Server 와 VNC View는 내부에 포함하고 있지만 없을 경우 아래와 같이 설치해주자.

$ sudo apt-get update
$ sudo apt-get install realvnc-vnc-server 
$ sudo apt-get install realvnc-vnc-viewer

현재 확인을 해보니, tightvnc는 지원을 안해주는 것 같다.

  • Terminal에서 VNC and SSH Server 설정 
$ sudo raspi-config 
 interfacing options 
     -> vnc-server enable


  • VNC 와 SSH Server의 기본 ID와 PW
기본 Raspberry Pi의 ID와 Password는 아래와 동일하다

ID: pi 
PW:raspberry 

만약 변경하고자 한다면
  Preferences->Raspberry Pi Configuration->System->Change Password



1.3. Window/Linux의 VNC Viewer 설치 및 연결 

RealVNC를 Window용으로 다운받아 설치를 하자

   VNC-Viewer-6.17.1113-Windows.exe

  • Window/Linux Download 
   https://www.realvnc.com/en/connect/download/viewer/

이제 Network가 정상적으로 연결이 되고, VNC Server가 동작이 되면 Window에서 Remote Control이 되므로, 이제 HDMI 모니터 대신 VNC Viewer를 사용하자

기타 VNC Viewer
  https://www.tightvnc.com/


2. 각 기타 설정 변경 

  • Display 화면의 Resolution 변경 
GUI에서 아래와 같이 본인이 원하는 Resolution으로 변경을 해주자.

  Preferences->Raspberry Pi Configuration->System->Set Resolution

  Default(720x480)
  1920x1080으로 변경


아래와 같이 Full HD로 변경 우측에 VNC 및 WIFI 부분을 확인 가능


아래와 같이 다양한 옵션이 있으니, 가급적 아래와 명령어로 수정을 하자.
상위 모든 수정은 아래의 raspi-config에서 가능하다.

  • 시간과 지역설정 
일단 아래와 같이 시간만 설정을 해보고, WIFI-Country도 기본설정을 하자.

TimeZone 
 - Area : Asia
 - Location: Seoul

  • GUI에서 지역 및 시간 설정 
   Preferences->Raspberry Pi Configuration->Localisation

  • Terminal에서 설정 
$ sudo raspi-config 
 Localisation Options
     -> I1 Change Locale             // Language 설정 , Korea , UTF8 설정  
     -> I2 Change Timezone           // Timezone       
     -> I3 Change Keyboard Layout    // Keyboard 설정 
     -> I3 Wi-fi Country             // WIFI Country 변경  


4/29/2018

Raspberry Pi 의 Device Tree 및 cmdline 수정

1. Raspberry Pi Booting 및 설정 분석

  • Raspberry Pi Boot관련정보 
  1. cmdline.txt : kernel cmdline 수정가능 
  2. config.txt : Raspberry 설정 파일 
  3. bootcode.bin : Raspberry bootloader로 SoC에의해 Loading 되고 start*.elf를 로딩
  4. start.elf, start_x.elf, start_db.elf, start_cd.elf : firmware로 사용되지만 elf파일형식 
  5. fixup.dat, fixup_x.dat, fixup_db.dat, fixup_cd.dat : start*.elf의 linker file 
  6. *.dtb : Device Tree Blob

  https://wikidocs.net/3198
  https://wikidocs.net/18317


1.1 /boot 파일 확인 

일단 아래를 보면, dtb 파일과 kernel.img가 많아서 현재 사용중인 이미지를 알아야겠다.
추측을 하면 아래의 것을 사용할 것으로 짐작

$ cd /boot
bcm2708-rpi-0-w.dtb     bcm2709-rpi-2-b.dtb       bootcode.bin   fixup_cd.dat  issue.txt         LICENSE.oracle  start.elf
bcm2708-rpi-b.dtb       bcm2710-rpi-3-b.dtb       cmdline.txt    fixup.dat     kernel7.img       overlays        start_x.elf
bcm2708-rpi-b-plus.dtb  bcm2710-rpi-3-b-plus.dtb  config.txt     fixup_db.dat  kernel.img        start_cd.elf
bcm2708-rpi-cm.dtb      bcm2710-rpi-cm3.dtb       COPYING.linux  fixup_x.dat   LICENCE.broadcom  start_db.elf


1.2 DTS 와 DTB 구조 복습 (Device Tree) 

Device Tree 의 기본이해 (관련예제도 링크)
  https://ahyuo79.blogspot.com/2015/08/kernel-boot-kernel-device-tree.html
  https://www.elinux.org/images/a/ad/Arm-soc-checklist.pdf

Device Tree Spec (v0.2 와 v0.1) 및 각 문법 이해 (필독)
  https://www.devicetree.org/specifications/
  https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.2
  https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.1

Device Tree 활용
  https://elinux.org/Device_Tree_Usage


  • DTS의 기본구조 
/ 로 시작하여 model과 아래 좌측을 부터 정의하기 시작하여 구성

  • 상위기본구성 분석
  1. / 의 model= MACHINE 정보이름과 compatibale 에 해당 arch를 선택 (MACHINE 정보)
  2.  #address-cells 1 , #size-cells  1 의 의미는 
    1. child의 address cell u32 갯수와 size cell u32 갯수 말하며 이는 reg에 적용 
  3. memory@0 의 의미는 memory address 0 의미 
    1. reg = <0  0x20000000) address 와 size 
  4. uart@fe00100 의 의미는 uart 의 address는 0xfe00100 
    1. reg = <0xfe001000 0x100 > 은 address 와 size 



  • Sample DTS (Deivce Tree Syntax) 구조 (상위 Spec 문서참조)
아래와 같이 DTS도 Version 이 존재하며, 각 Version 별로 문법이 변경될 것이므로 이부분을 반드시 확인
C와 같이 Preprocessor가 먼저 진행 빌드되므로 이점 주의 
$ vi arch/arm/boot/dts/mysample.dts  //kernel or uboot 
/dts-v1/;  // device tree spec 를 반드시 참조하며, 각 node의 manual 별도로 보자 

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

//커널의  ./include/dt-bindings/  
//커널의 ./scripts/dtc/include-prefixes/dt-bindings    
// dtc는 ./scripts/dtc 에 존재 

#include "sample.dtsi"


// 아래와 같이 C처럼 Preprocess(상위 include)가 동작가능하며, 주석도 /**/ // 둘다 가능

#define TEST  //preprocess 도 동작가능 C처럼 Preprocess가 다른 것 보다 먼저 실행되는 것을 주의  

#if 1 // jhlee 

#endif

#ifndef TEST

#endif

#ifdef TEST

#endif

#if defined(TEST) //jhlee

#else //orgin

#endif




/ {   // / { 는 DTS Main을 의미하며, 만약 sample.dtsi 이 것이 포함이 되어 있다면, 그곳에 위치에 들어간다고 생각하면됨

//보통 Kernel에서 model 에 정보를 넣으면, 부팅시 Machine Name 확인가능 
//조금 고급스럽게 하고자 하면 색 정보도 같이 넣어 만들자  
//sample.dtsi 이미 있지만, 중복으로 넣어 최종이것으로 빌드하면 최종값으로 적용가능  
        //model = "fsl,mpc8572da";     
        //MACHINE 정보 Name이며 마음대로 변경,DT_MACHINE_START (Device Tree용) or MACHINE_START         
        model = "EVM_JHLEE";       
        compatible = "fsl,mpc8572da";       //board 호환성이며, "manufacturer,model" kernel 검색 
};
// }; 는 상위 model 때문에 삽입 

#if 1 //아래 다시 중복설정할 경우 이것이 최종 값으로 결정되며, model만 재선언 (제조사 생략)하여, 내맘대로 변경    
/ {
      // Kernel Boot시 색깔까지 넣어 표시   
      model = "\x1b[1m \x1b[93m  Jeonghun Board Ver 0.0 \x1b[0m"; // Machin Name을 변경      
};
#endif 

// 주석 
/* 주석 */


/* 
보통 gpio node가 구성되고, PINMUX에서 GPIO로 설정하면, User에서 /sys/class/gpio/export 를 이용하여 직접사용가능 
GPIO4_18  보통 (4-1)*32+18 = 114  
GPIO4_19  보통 (4-1)*32+18 = 115
*/
/*
 /sys/class/gpio/export 
 /sys/class/gpio/gpio114/direction
 https://www.kernel.org/doc/Documentation/gpio/sysfs.txt
 항상 compatible 에서 device driver와 연결하므로, Kernel에서 Pinmux를 하였다고, 자동으로 /sys/class/gpio/export에 적용되지 않는다 
 */ 

  • 필요없는 부분 중복된 부분삭제 관련예제
  1. /delete-node/      : node or lable 삭제
  2. /delete-property/ : node 의 property 삭제
  3. /omit-if-no-ref/    : dtc에게 사용하지 않는다면, 삭제 
  https://elinux.org/Device_Tree_Source_Undocumented

상위에서 설명했듯이 중복많이 허용하며, 최종선언된 dts기준으로 파싱을 시작하기때문에 필요없다면, 
나만의 dts를 만들경우 최종 dts include하고 필요없는 것을 정리하도록하자  

// 이미 이전에 선언된 uart1 label 의 property의 status를 okay ->disabled 변경 
&uart1 {
   status = "disabled";
};

// 이미 이전에 선언된 uart1 lalel 의 특정 property만 삭제 
&uart1 {
    /delete-property/ fsl,uart-has-rtscts;
};


/* 

node의 구성 은 보통 label: node로  or node로만 구성될 수가 있으며, label에는 &를 사용 

label: node  

adv_bridge0: adv7535@3d {
...
};

adv_bridge1: adv7535@3d {
...
};
*/
 

// node를 삭제방법은 label에는 &사용하며, node 를 직접입력할 경우 &불필요

/delete-node/ &adv_bridge0;
/delete-node/ &adv_bridge1;

  • OS에서는 호환성목적으로 aliases 기능을 사용
각 Chip label 이름이 다 다르게 정의될 수 있으므로, OS가 알수 있도록 이를 변경 
// aliases는 node의 새로 naming 하여 쉽게 node구성하며, 주로 OS 즉 linux 호환성을위해서 사용해준다  
// 구성은 이전과 같이 label에 &사용
aliases {
     rtc0 = &snvsrtc;
     rtc1 = &rtc;
};


chosen {
      bootargs = "root=/dev/nfs rw nfsroot=192.168.1.1 console=ttyS0,115200";
};

https://elinux.org/Device_Tree_Usage#aliases_Node

  • #xxx-cells 의 의미 
child의 cells 의 갯수를 정의해주는 것으로 기본적인 address-cells 과 size-cells 이 존재한다.
더불어 다양한 #로 시작하는 cells들이 존재 
/dts-v1/;

/ {
    #address-cells = <1>; // address-cells의 의미 child의 reg의 address u32 갯수  
    #size-cells = <1>;    // size-cells 의 의미 child의 reg의 size u32 갯수  

    ...

    serial@101f0000 {
        compatible = "arm,pl011";
        reg = <0x101f0000 0x1000 >; // 상위 address-cells 수(1) 와 size-cells 수(1)로 결정
    };

    serial@101f2000 {
        compatible = "arm,pl011";
        reg = <0x101f2000 0x1000 >;
    };

    gpio@101f3000 {
        compatible = "arm,pl061";
        reg = <0x101f3000 0x1000
               0x101f4000 0x0010>; // 상위 address-cells 수(1) 와 size-cells 수(1)로 결정 연속 2개 
    };

    interrupt-controller@10140000 {
        compatible = "arm,pl190";
        reg = <0x10140000 0x1000 >;
    };

    spi@10115000 {
        compatible = "arm,pl022";
        reg = <0x10115000 0x1000 >;
    };

    ...

https://elinux.org/Device_Tree_Usage#Memory_Mapped_Devices
};

  • range 의 의미 
OS는 virtual address를 사용하며, 이를 위해서 memory map-io로 연결하여 사용한다. 
이때 각 영역의 부분의 정의해주는 것이 range의 기능이다. 
/dts-v1/;

/ {
    compatible = "acme,coyotes-revenge";
    #address-cells = <1>;  //parent의 reg의 address u32 수  
    #size-cells = <1>     //parent의 reg의 size u32 수  
    ...
    external-bus {
        #address-cells = <2>;  //child의 reg의 address u32 수  
        #size-cells = <1>;     //child의 reg의 size u32 수  
 
/*
range(Address Translation) 는 address translation을 위한 list 구성 
   1. the child's #address-cells value(2),  
   2. the parent's #address-cells value(1), 
   3. the child's #size-cells(1) 
마지막 size로 memory map을 하여 영역 넣어구성 아래와 같이 mapping 

- Offset 0 from chip select 0 is mapped to address range 0x10100000 - 0x1010ffff
- Offset 0 from chip select 1 is mapped to address range 0x10160000 - 0x1016ffff
- Offset 0 from chip select 2 is mapped to address range 0x30000000 - 0x30ffffff

*/
        ranges = <0 0  0x10100000   0x10000     // Chipselect 1, Ethernet
                  1 0  0x10160000   0x10000     // Chipselect 2, i2c controller
                  2 0  0x30000000   0x1000000>; // Chipselect 3, NOR Flash

        ethernet@0,0 {
            compatible = "smc,smc91c111";
            reg = <0 0 0x1000>;  // 상위 child address 2개 와 size 1  
        };

        i2c@1,0 {
            compatible = "acme,a1234-i2c-bus";
            #address-cells = <1>; // node child address u32 수  
            #size-cells = <0>;    // node child reg의 e u32 수  
            reg = <1 0 0x1000>;   // 상위 child address  2개 와 size 1  
            rtc@58 {
                compatible = "maxim,ds1338";
                reg = <58>;             //상위 node child (1,0) 
            };
        };

        flash@2,0 {
            compatible = "samsung,k8f1315ebm", "cfi-flash";
            reg = <2 0 0x4000000>;
        };
    };
};
https://elinux.org/Device_Tree_Usage#Ranges_.28Address_Translation.29
https://elinux.org/Device_Tree_Usage#PCI_Host_Bridge
https://elinux.org/Device_Tree_Usage#How_Interrupts_Work



Kernel GPIO 기본사용법
  https://www.kernel.org/doc/Documentation/gpio/gpio-legacy.txt

  • Device Tree 관련문서
Device Tree는 현재 각 Platform Device Driver마다 각각의 설정값들이 존재하는데, 관련부분을 아래에서 검색해서 찾자
  https://www.kernel.org/doc/Documentation/devicetree/bindings/

  • DTB (Flattened Device Tree 라고 불림) 의 구조 





1.3 Device Tree 비교 및 확인 

Raspberry Pi에 dtc 설치 되었는지 확인

  • 사용중인 Device Tree를 확인
/proc/device-tree 정보를 dtc를 이용하여 dts 파일생성방법, 역으로 생성했기때문에 원래사용하던 dts와는 완전동일할 수는 없다.

$ dtc -I fs -O dts -o current.dts /proc/device-tree/ 

  • DTB To DTS로 변경 
dtb 파일을 dts 파일로 역으로 변경했으므로, 상위와 같이 원래 dts와 완전동일할 수가 없음

$ sudo dtc -I dtb -O dts -o bcm2710-rpi-3-b-plus.dts /boot/bcm2710-rpi-3-b-plus.dtb
$ sudo dtc -I dtb -O dts -o bcm2710-rpi-3-b.dts /boot/bcm2710-rpi-3-b.dtb
$ sudo dtc -I dtb -O dts -o bcm2708-rpi-b-plus.dts /boot/bcm2708-rpi-b-plus.dtb

  • DTS 비교 
사용 중인  DTS 상위 DTB 다르기 때문에 일단 상위 /boot의 dtb 사용을 의심.

$ diff -urN current.dts bcm2710-rpi-3-b-plus.dts 
--- current.dts 2019-02-18 23:34:57.966477519 +0900
+++ bcm2710-rpi-3-b-plus.dts 2019-02-18 23:36:18.841755013 +0900
@@ -1,1159 +1,941 @@
 /dts-v1/;
 
+/memreserve/ 0x0000000000000000 0x0000000000001000;
 / {
- compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
- serial-number = "000000003befb7f8";
- model = "Raspberry Pi 3 Model B Rev 1.2";
- memreserve = 0x3b400000 0x4c00000="";
+ compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837";
+ model = "Raspberry Pi 3 Model B+";

$ diff -urN current.dts bcm2710-rpi-3-b.dts 
--- current.dts 2019-02-18 23:34:57.966477519 +0900
+++ bcm2710-rpi-3-b.dts 2019-02-18 23:42:58.263596240 +0900
@@ -1,1159 +1,940 @@
 /dts-v1/;
 
+/memreserve/ 0x0000000000000000 0x0000000000001000;
 / {
  compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
- serial-number = "000000003befb7f8";
- model = "Raspberry Pi 3 Model B Rev 1.2";
- memreserve = <0x3b400000 0x4c00000="">;
+ model = "Raspberry Pi 3 Model B";
  interrupt-parent = <0x1>;
  #address-cells = <0x1>;
  #size-cells = <0x1>;

$ diff -urN current.dts bcm2708-rpi-b-plus.dts | head -n 30
--- current.dts 2019-02-18 23:34:57.966477519 +0900
+++ bcm2708-rpi-b-plus.dts 2019-02-18 23:51:14.696159160 +0900
@@ -1,1235 +1,1066 @@
 /dts-v1/;
 
+/memreserve/ 0x0000000000000000 0x0000000000001000;
 / {
- compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
- serial-number = "000000003befb7f8";
- model = "Raspberry Pi 3 Model B Rev 1.2";
- memreserve = <0x3b400000 0x4c00000="">;
+ compatible = "brcm,bcm2835";
+ model = "Raspberry Pi Model B+";
  interrupt-parent = <0x1>;
  #address-cells = <0x1>;
  #size-cells = <0x1>;

  • bootcode 분석
현재 사용중인 Device Tree를 정확하게 잘 몰라 다른 bootloader 를 분석했지만, 역시나. grep을 이용하여 dtb를 찾으려해도 찾지를 못했다.

$ hd /boot/bootcode.bin 
...
0000c6e0  75 70 0a 00 46 61 69 6c  65 64 20 74 6f 20 69 6e  |up..Failed to in|
0000c6f0  69 74 69 61 6c 69 73 65  20 6c 69 6e 6b 0a 00 00  |itialise link...|
0000c700  49 6e 69 74 69 61 6c 69  73 65 20 68 75 62 0a 00  |Initialise hub..|
0000c710  46 6f 75 6e 64 20 25 64  20 70 6f 72 74 73 2c 20  |Found %d ports, |
0000c720  6d 75 6c 74 69 5f 74 74  20 3d 20 25 64 0a 00 53  |multi_tt = %d..S|
0000c730  65 74 74 69 6e 67 20 69  6e 74 65 72 66 61 63 65  |etting interface|
0000c740  20 25 64 0a 00 46 61 69  6c 65 64 20 74 6f 20 73  | %d..Failed to s|
0000c750  65 74 20 69 6e 74 65 72  66 61 63 65 20 25 64 0a  |et interface %d.|
0000c760  00 45 6e 61 62 6c 69 6e  67 20 50 4f 52 54 20 50  |.Enabling PORT P|
0000c770  4f 57 45 52 20 6f 6e 20  70 6f 72 74 20 25 64 0a  |OWER on port %d.|
0000c780  00 46 61 69 6c 65 64 20  74 6f 20 73 65 74 20 66  |.Failed to set f|
0000c790  65 61 74 75 72 65 20 48  55 42 5f 46 45 41 54 55  |eature HUB_FEATU|
0000c7a0  52 45 5f 50 4f 52 54 5f  50 4f 57 45 52 20 25 64  |RE_PORT_POWER %d|
0000c7b0  0a 00 57 61 69 74 69 6e  67 20 66 6f 72 20 64 65  |..Waiting for de|
0000c7c0  76 69 63 65 73 20 74 6f  20 72 65 73 70 6f 6e 64  |vices to respond|
0000c7d0  20 74 6f 20 72 65 73 65  74 0a 00 46 6f 75 6e 64  | to reset..Found|
0000c7e0  20 64 65 76 69 63 65 20  6f 6e 20 70 6f 72 74 20  | device on port |
0000c7f0  25 64 0a 00 46 6f 75 6e  64 20 68 69 67 68 73 70  |%d..Found highsp|
0000c800  65 65 64 20 64 65 76 69  63 65 0a 00 48 75 62 20  |eed device..Hub |
0000c810  64 65 76 69 63 65 20 66  6f 75 6e 64 20 61 74 20  |device found at |
0000c820  61 64 64 72 20 25 64 2c  20 65 6e 75 6d 65 72 61  |addr %d, enumera|
0000c830  74 69 6e 67 20 48 55 42  0a 00 44 65 76 69 63 65  |ting HUB..Device|
0000c840  20 66 6f 75 6e 64 3a 20  74 79 70 65 20 3d 20 25  | found: type = %|
0000c850  73 2c 20 61 64 64 72 20  3d 20 25 64 0a 00 4d 61  |s, addr = %d..Ma|
0000c860  73 73 20 73 74 6f 72 61  67 65 00 45 74 68 65 72  |ss storage.Ether|
0000c870  6e 65 74 20 61 64 61 70  74 65 72 00 49 67 6e 6f  |net adapter.Igno|
0000c880  72 69 6e 67 20 6c 6f 77  20 73 70 65 65 64 20 64  |ring low speed d|
0000c890  65 76 69 63 65 0a 00 44  65 76 69 63 65 20 66 61  |evice..Device fa|
0000c8a0  69 6c 65 64 20 74 6f 20  72 65 73 70 6f 6e 64 20  |iled to respond |
0000c8b0  74 6f 20 72 65 73 65 74  0a 00 00 00 79 00 00 00  |to reset....y...|
....

$ strings /boot/bootcode.bin | grep dtb

  • 제공하는 Kernel Image 분석 
/boot/kernel.img 와 kernel7.img는 아래와 같이 다르게 나오며, 압축때문인 것으로 생각이 된다.

$ cat /proc/version 
Linux version 4.14.34-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1110 SMP Mon Apr 16 15:18:51 BST 2018

$ hd /boot/kernel.img | grep 'Linux'

$ strings /boot/kernel.img | grep 'Linux'
Uncompressing Linux...

$ strings /boot/kernel7.img | grep 'Linux'
Uncompressing Linux...


uImage라고 한다면, 64 byte의 헤더를 버려야 하지만, 상위 이미지를 보면 uImage 구조와 다른 것 같다.
zImage라고 생각이 들어 아래와 같이 시도해본다.


uImage 구조체
  http://www.isysop.com/unpacking-and-repacking-u-boot-uimage-files/
  http://forum.falinux.com/zbxe/index.php?document_srl=564748&mid=lecture_tip

zImage 구조
  https://wiki.kldp.org/KoreanDoc/html/EmbeddedKernel-KLDP/kernel-image-file-structure.html

zImage (LZMA)
  https://stackoverflow.com/questions/37672417/getting-kernel-version-from-the-compressed-kernel-image

GPIO
  https://www.kosagi.com/w/index.php?title=Definitive_GPIO_guide
  • 사용중인 Kernel 분석 
사용중인 Kernel은 잘 나온다. (압축이 되지 않았으니 잘나오는 것 같다)

$ sudo strings /dev/mem | grep 'Linux'   
....
Booting Linux on physical CPU 0x0
Linux version 4.14.34-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1110 SMP Mon Apr 16 15:18:51 BST 2018

4/22/2018

Raspberry-Pi3 관련프로젝트 및 OpenOCD 자료수집

1. Raspberry  Pi3 의 Projects 

Smart Mirror or Magic Mirror라고 불리우는 프로젝트로 라지베리파이를 이용하여 음성인식을하여 
각각 사물을 제어하는 IoT 프로젝트이다. 

나도 한번 만들어보고 싶지만, LCD 패널과 관련부품이 돈이 너무 많이 들어갈꺼 같아 현재 고려만 하고 있다. 

  • Smart Mirror 관련사이트 
  http://blog.embian.com/120
  http://jeongchul.tistory.com/425
  http://mazdah.tistory.com/786
  https://www.magicmirrorcentral.com/complete-raspberry-pi-magic-mirror-tutorial/


  • Smart Mirror 중요동영상 (EASY SMART MIRROR SETUP)
  https://www.youtube.com/watch?v=pcmjht0Hqvw
  https://www.youtube.com/watch?v=wdaBi33nd3k
  https://www.youtube.com/watch?v=cVmDjJmcd2M



1.2 IoT를 구성할 때 필요한 API 를 비롯하여 Device들 

  • Open API 관련 정리
IoT를 구현하기 위해서 연결할  OpenAPI 부분
  http://freemoa-blog.com/639

이외 Smart Plug 기능 및 Google Home에 연결할 수 있는


2. 라즈베리파이에서 Ecplise에 연결하여 테스트 해볼 기능들 

가장 만만한 것이 손쉽게 가능한 것이 GDB Server를 이용하여 Remote Debug일 것이다.

  • Remote GDB 사용 (GDB Server)
  http://geomodule.com/sw-eng-notes/2017/03/25/raspberry-pi-debugging-with-gdb-command-line/


2.1 LTTng 사용방법 모색 

이 전에 TI Chip를 사용했을 때 CCS Linux Version LTTng기능을 지원 한 적이 있어 사용한 경험이 있는데, 라즈베리파이에서도 이를 한번 적용하여 사용해보고 싶다.
추후에 Ecplise에 연결해서 Trace compass의 LTTng를 이용하여 Kernel을 Trace를 한번 해보도록 하자

  • LTTng Tracer Download
LTTng 관련 Tool을 쉽게 Download 가능
  1. LTTng-modules (Linux Kernel 용 Module)
  2. LTTng-UST (User Space Tracer)
  3. LTTng-Tool 상위 두개를 지원하여 Trace하는 Tool 
  https://lttng.org/download/


  • Eclipse LTTng/SourceAnalyzer (Linux Trace Toolkit Next Generation)
Eclipse 기반으로 다양하게 사용되는 것을 확인가능하며 아래의 사이트에서 확인 

  • Eclipse LTTng Kernel Analysis
Eclipse에서 쉽게 추가 가능하며 아래와 같이 Tracecompass Manual 참고  
  http://archive.eclipse.org/tracecompass/doc/stable/org.eclipse.tracecompass.doc.user/LTTng-Kernel-Analysis.html

  • Ecplise 관련 Manual (LTTng)
  https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.linuxtools.lttng.help%2Fdoc%2FInstallation.html



2.2 OpenOCD (On-Chip Debugger) 사용 방법 모색 

OpenOCD는 JTAG Interface를 통하여 Chip Level에서 Debugging을 하는 것이며, 이를 GDB로 연결하여 보통사용한다.
나의 경우는 주로 Ecpliise 기반의 IDE에서 사용한 것이며, Raspberry Pi3에서도 가능한지 한번 살펴 봐야할 것 같다.

  • OpenOCD란? 
  http://openocd.org/doc/html/About.html
  http://openocd.org/doc-release/README

  • OpenOCD Manual 
  http://openocd.org/doc/html/index.html#Top
  http://openocd.org/doc/html/OpenOCD-Concept-Index.html#OpenOCD-Concept-Index

가장 대표적일 것이 쉽게 사용하는 것이 ST사의 ST-Link 일 것 같다.


2.2.1 JTAG Interface의 변화 

우선 기존의 JTAG과 SWD를 간단히 이해해보도록 하자.
JTAG 설명은 너무많이 나오므로 아래사이트 참조하도록하자 


  • JTAG의 관련설명 
아래의 Wiki에서 쉽게 설명해주고 있어 구지 설명할 필요가 없음 
  https://en.wikipedia.org/wiki/JTAG
  https://ko.wikipedia.org/wiki/JTAG


  • JTAG의 기본구성
기본 구성은 Daisy-chained JTAG (IEEE 1149.1) 형식으로 아래와 같이 Chain 형식으로 연결되어 각 Device 에게 Read / Write를 할 수가 있다. 


https://en.wikipedia.org/wiki/JTAG
여기서 PIN의 기준은 TAP(Test Access Port), Device1,2,3 기준이므로 Pin의 in/out이 달라지므로 혼동하지 말자.

  1. TDI (Test Data In): JTAG의 Output으로 TMS에 따라 command/Data가 결정 
  2. TDO (Test Data Out): JTAG의 Input으로 Device의 Address/Data가 결정 
  3. TCK (Test Clock): JTAG의 Output Clock
  4. TMS (Test Mode Select):  JTAG의 Output TEST Mode 전환 
  5. TRST (Test Reset) optional): 사용은 옵션 JTAG의 Output 

JTAG PIN 

  https://www.electronics-notes.com/articles/test-methods/boundary-scan-jtag-ieee1149/jtag-interface-tap-test-access-port-connector.php

TAP(Test Access Port)의 상태 
  https://en.wikipedia.org/wiki/JTAG#JTAG_facilities


JTAG의 동작방식은 간단하며, TAP의 상태에 따라 TDI에 명령어와 Data를 넣어 TDO로 결과를 가져오는 방식이다.


  • Boundary Scan
JTAG 입장에서 보면 TMS/TCK/TDI에 결정이 되고 , TDO로 결과값을 보는 형식



  https://en.wikipedia.org/wiki/Boundary_scan

  • JTAG 와 SWD
STM의 ST-Linkv2를 사용하다 보면 JTAG or SWD(Serial Wired Debug)로 선택을 해서 사용한다.
SWD(Serial Wired Debug)로 JTAG의 축소판으로 Pin으로 최소 아래의 3PIN이 필수이며, JTAG Pin과 Match되는 부분은 아래와 같다.

  1. SWCLK(Serial Wire Clock): TCLK
  2. SWDIO(Serial Wire debug Data Input/Output): TMS
  3. SWO(Serial Wire trace Output): TDO

JTAG 과 SWD의 일반적인 Match 일뿐이지 SWDIO와 TMS는 동일하지 않으며, SWDIO는 Input/Output로 사용한다.
JTAG과 SWD 유사할 뿐이지 동작은 조금 다르며, TAP(Test Access Port) 대신 DAP(Debug Access Port)를 용어를 사용하지만, 내부적으로 보면 거의 유사
세부내용
  https://research.kudelskisecurity.com/2019/05/16/swd-arms-alternative-to-jtag/


  • TRACE32의 정보 (JTAG/SWD)
  http://www.trace32.com/archive/view.php?mnu=5&no=48&board=newsletter&uid=840&cp=1&field=&keyword=


  • JTAG과 SWD 차이 
  http://forum.falinux.com/zbxe/?document_srl=796669&mid=lecture_tip&order_type=asc&sort_index=readed_count


2.2.2 OpenOCD 에 사용되는 Hardware 

  • USB기반의 다양한 JTAG Interface가 이를 사용
  1. USB FT2232: USB To Serail로만 사용하는줄 알았는데, USB To JTAG로 가능 
  2. USB J-Link
  3. USB RLINK 
  4. USB ST-LINK
  5. 나머지들 아래참고 
  http://openocd.org/doc/html/Debug-Adapter-Hardware.html#Debug-Adapter-Hardware


  • FT2232 기반의 USB JTAG
  https://nexp.tistory.com/86
  https://www.ftdichip.com/Products/ICs/FT2232D.htm


2.2.3  Raspberry Pi3 의 연결 JTAG 연결방법

현재 생각으로 값싼 ST-Linkv2로 SWD가 지원을 하니, 이를 연결을 해볼 생각이다.
아래와 같이 나와 비슷한 생각을 한 사람이 있어 다행이지만, 테스트를 해보자.

  https://spin.atomicobject.com/2014/04/01/ethernet-adapter-jtag/

  • Raspberry PI3 JTAG Interface (Pin을 확인)
  https://movr0.com/2016/09/02/use-raspberry-pi-23-as-a-jtagswd-adapter/


2.2.4  OpenOCD를 GDB에 연결 

주로 Ecplise기반의 GDB에서 연결하여 사용을하고 있기 때문에 이 부분은 먼저 JTAG 부분먼저 확인을 하고 진행하자

  • STM를 사용할때 ST-Link를 이용하여 OpenOCD에서 GDB연결 
  https://m.blog.naver.com/PostView.nhn?blogId=abby21&logNo=80208277200&proxyReferer=https%3A%2F%2Fwww.google.com%2F


GDB 와 OpenOCD 를 연결하여 IDE에서 많이 Debug를 하고 있으며 대표적인 것이 ST-Link를 이용하는 것일 것 이다.
일단 하고 나의 라즈베리파이에서 OpenOCD를 적용하여 테스트를 진행하도록 하겠다.

Eclipse ARM OpenOCD Plug
  https://gnu-mcu-eclipse.github.io/
  https://gnu-mcu-eclipse.github.io/debug/
  https://gnu-mcu-eclipse.github.io/openocd/
  http://openocd.org/

4/19/2018

Raspberry-Pi3 HDMI 관련 설정

일단 RASPBIAN OS를 설치한 후 /boot로 가서 설정들을 확인하자.
쉽게 설정하고자 한다면,

$ sudo raspi-config // 각 설정  



  • *.dtb : device tree
  • cmdline.txt : kernel command line 쉽게 변경 가능
  • config.txt :  raspberry pi 설정


$ cd /boot/ 
bcm2708-rpi-0-w.dtb     bcm2708-rpi-cm.dtb   bcm2710-rpi-3-b-plus.dtb  cmdline.txt    fixup_cd.dat  fixup_x.dat  kernel.img        overlays      start.elf
bcm2708-rpi-b.dtb       bcm2709-rpi-2-b.dtb  bcm2710-rpi-cm3.dtb       config.txt     fixup.dat     issue.txt    LICENCE.broadcom  start_cd.elf  start_x.elf
bcm2708-rpi-b-plus.dtb  bcm2710-rpi-3-b.dtb  bootcode.bin              COPYING.linux  fixup_db.dat  kernel7.img  LICENSE.oracle    start_db.elf


  • HDMI config.txt 설정 방법 

  https://wikidocs.net/7826
  https://wikidocs.net/3198



리모콘 기능을 위해서 아래와 같이 CEC관련 자료 수집

  • Raspberry PI Turn On HDMI CEC
  https://timleland.com/raspberry-pi-turn-tv-onoff-cec/
  https://www.youtube.com/watch?v=Z-KaPnAGPNQ


2/26/2018

Raspberry-Pi3 와 Linux Yocto 기본구성 과 이해

1. Yocto 구성설명 

Yocto의 Quick Build 방법과 기존에 존재하는 Layer를 쉽게 추가하는 방법을 아래의 링크에서 쉽게 설명을 해주고 있으므로, 반드시 알아두자

  • Yocto의 사용법 (Cookbook)
Yocto에 대한 현재 Quick Guide / Reference Manul 와 Cookbook Topics 에서 쉽게확인
  https://wiki.yoctoproject.org/wiki/Cookbook

  • OS Image에 추가하는 방법 (Cookbook Topics)
아래의 구성할 문서의 순서랑 거의 동일하며 Layer 추가하는 방법 및 수정방법이 괜찮다
  https://wiki.yoctoproject.org/wiki/Cookbook:Example:Adding_packages_to_your_OS_image

  • Application 개발관련내용(Cookbook Topics) 
기존의 bitbake-layers 와 다르게 devtool 을 이용한 recipe 추가방법이 새로움
  https://wiki.yoctoproject.org/wiki/Application_Development_with_Extensible_SDK


  • Yocto 기본사용법확인
이전에 Yocto Reference Manual 기반으로 필요한 환경변수 및 구조설명
  https://ahyuo79.blogspot.com/2015/10/yocto.html


https://yoctoproject.org/docs/2.7/mega-manual/mega-manual.html#what-is-the-yocto-project

  • Layer 의 우선순위 (Layer Priority)
이전에 $ bitbake-layers show-layers 명령으로 우선순위를 보기는 했지만 우선순위 동작원리를 미쳐 파악을 못했다.

$ bitbake-layers show-layers  // Layer Priority 확인 및 구성확인 

$ bitbake-layers layerindex-show-depends meta-raspberrypi    // meta-raspberrypi의 의존성 확인, Layer를 추가할 때 의존성을 확인필요 

$ bitbake-layers -h 
usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h]  ...

BitBake layers utility

optional arguments:
  -d, --debug           Enable debug output
  -q, --quiet           Print only errors
  -F, --force           Force add without recipe parse verification
  --color COLOR         Colorize output (where COLOR is auto, always, never)
  -h, --help            show this help message and exit

subcommands:
  
    add-layer           Add one or more layers to bblayers.conf.
    remove-layer        Remove one or more layers from bblayers.conf.
    flatten             flatten layer configuration into a separate output
                        directory.
    show-layers         show current configured layers.
    show-overlayed      list overlayed recipes (where the same recipe exists
                        in another layer)
    show-recipes        list available recipes, showing the layer they are
                        provided by
    show-appends        list bbappend files and recipe files they apply to
    show-cross-depends  Show dependencies between recipes that cross layer
                        boundaries.
    layerindex-fetch    Fetches a layer from a layer index along with its
                        dependent layers, and adds them to conf/bblayers.conf.
    layerindex-show-depends
                        Find layer dependencies from layer index.
    create-layer        Create a basic layer

Use bitbake-layers  --help to get help on a specific command


https://dornerworks.com/blog/building-linux-with-yocto
상위 사이트에서 Layer의 우선순위에 대해서 너무 쉽게 그림으로 설명을 해주었지만,궁금한 사항이 두 가지가 더 생겼다.

  • 궁금사항 
  1. Layer의 우선순위는 어떻게 정해지는 것인가? 
  2. Recipe의 우선순위는 어떻게 정해지는가? 

1번째의 질문의 답은 처음 conf/bblayers.conf에서 정해지는 것으로 착각했으나,  각 개별 Layer의 conf에  BBFILE_PRIORITY_xxx , suffix는 layer 이름에 의해 정해진다.


  • meta-oe Layer 의 예제 (oe는 open embedded 약어)
$ vi meta-openembedded/meta-oe/conf/layer.conf    // 각 Layer의 conf에 의해 정의됨

BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_PRIORITY_openembedded-layer = "6"        // openembedded layer 우선순위 

LAYERDEPENDS_openembedded-layer = "core"        //의존성 

LAYERSERIES_COMPAT_openembedded-layer = "thud warrior zeus"  // Yocto version 호환성 


  • meta-networking Layer 예제
$ vi meta-openembedded/meta-networking/conf/layer.conf 

BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \              // 등록되는 순서에 의해 동작될것이라고 생각 
            ${LAYERDIR}/recipes-*/*/*.bbappend"


BBFILE_PRIORITY_networking-layer = "5"     //networking layer의 우선순위 (같은 meta-openembdedded에 속해있지만 다름)

LAYERDEPENDS_networking-layer = "core"                // 의존성이 상당함 
LAYERDEPENDS_networking-layer += "openembedded-layer"
LAYERDEPENDS_networking-layer += "meta-python"

LAYERSERIES_COMPAT_networking-layer = "thud warrior zeus"


2번째의 질문의 답은 처음 Layer의 conf에서 BBFILES의 등록되는 순서가 아닐까 역시 잠시 착각 했는데, BBFILES은 등록만 할뿐 모든 Recipe는 사용하지 않는다는 사실을 깜빡했다.
잘 생각을 해보면, 최종 target image.bb파일이 존재하여, IMAGE_INSTALL에 들어간 Package들만을 설치진행한다.
기본으로 설치되는 부분은 class라는 공유개념이 존재하며,모든 recipe들은 사용하지 않는다.
즉  image -> core-image ->  include ***.bb 확장되어가는 구조


2. Raspberry Pi  개발환경 구성

  1. OS: Ubuntu 16.04_LTS 64bit 
  2. Window 기반의 Virtual Box 사용 

  • 기본설치 
$ sudo apt install chrpath  diffstat gawk libncurses5-dev texinfo  

makeinfo -> texinfo 변경


2.1 Raspberry PI 관련사항 

  • Raspberry PI 설정 및 전체문서   
  https://wikidocs.net/book/483

  • Raspberry PI Kernel 
  https://wikidocs.net/3243
  https://wikidocs.net/3244

  • Raspberry Android Build 
  http://airpage.org/xe/project_data/25990


2.2  Raspberry Pi Yocto 전체구성 


상위 Raspberry PI Yocto 구성 를 보면  사용할 GIT는 아래와 같이 세개로 구성이 된다.

  • 기본 Yocto 시스템  및 추가 metalayer들 
  1. git://git.yoctoproject.org/poky       // 기본 Yocto System 인 Poky
  2. git://git.openembedded.org/meta-openembedded  // Yocto의 meta-layer (meta-oe) 추가 
  3. https://github.com/agherzan/meta-raspberrypi  // Yocto의 meta-layer (meta-raspberrypi) 추가 

  • Raspberry Pi Yocto 기본사용법 참고 사이트 
  http://www.jumpnowtek.com/rpi/Raspberry-Pi-Systems-with-Yocto.html
  http://www.yocto.co.kr/2016/01/yocto-project-2.html
  http://kernelhacks.com/raspberry-pi-3-with-yocto/


2.3 Yocto 구성 및 meta layer 추가 

Yocto의 Reference Manual에 Reference Distribution Layer인 Poky를 구성한 후 각 필요한 meta layer들을 각각 추가하여 구성한다.

  1. 필요한 Raspberry Pi를 위한 BSP Layer 추가 
  2. Emdedded 관련된 기본인 Base Layer 추가

  • Yocto의 기본인 Poky (Reference Distribution Layer) 구성 

Yocto의 기본시스템이 Pocky를 git로 download하여 아래와 같이 구성을 확인하자

$ mkdir raspberrypi
$ cd raspberrypi
$ git clone -b master  git://git.yoctoproject.org/poky

$ tree poky -L 1
poky
├── bitbake   // bin에 bitbake , bitbake-layers 가 존재하므로 중요   
├── contrib
├── documentation
├── LICENSE
├── LICENSE.GPL-2.0-only
├── LICENSE.MIT
├── meta
├── meta-poky
├── meta-selftest
├── meta-skeleton
├── meta-yocto-bsp
├── oe-init-build-env
├── README.hardware -> meta-yocto-bsp/README.hardware
├── README.OE-Core
├── README.poky -> meta-poky/README.poky
├── README.qemu
└── scripts  // devtool늘 비롯하여 각종 oe-xxxxx tools 제공 

$ cd poky
$ ls
LICENSE     README.hardware  README.qemu  documentation  meta-poky      meta-skeleton   oe-init-build-env
README.LSB  README.poky      bitbake      meta           meta-selftest  meta-yocto-bsp  scripts

  http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/


  • poky 에 meta-raspberrypi (BSP Layer) 추가 

$ pwd
/home/jhlee/raspberrypi/poky

$ git clone -b master https://github.com/agherzan/meta-raspberrypi

$ tree -L 1 meta-raspberrypi
meta-raspberrypi
├── classes
├── conf
├── COPYING.MIT
├── docs
├── dynamic-layers
├── files
├── README.md
├── recipes-bsp
├── recipes-connectivity
├── recipes-core
├── recipes-devtools
├── recipes-graphics
├── recipes-kernel
├── recipes-multimedia
└── wic


$ ls
LICENSE     README.hardware  README.qemu  documentation  meta-openembedded  meta-raspberrypi  meta-skeleton   oe-init-build-env
README.LSB  README.poky      bitbake      meta           meta-poky          meta-selftest     meta-yocto-bsp  scripts

  https://layers.openembedded.org/layerindex/branch/master/layer/meta-raspberrypi/
  https://github.com/agherzan/meta-raspberrypi
  http://meta-raspberrypi.readthedocs.io/en/latest/readme.html
  http://git.yoctoproject.org/cgit.cgi/meta-raspberrypi/


  • poky 에 meta-oe (Base Layer) 추가 

$ pwd
/home/jhlee/raspberrypi/poky

$ git clone -b master git://git.openembedded.org/meta-openembedded 

$ tree -L 1 meta-openembedded/
meta-openembedded/
├── contrib
├── COPYING.MIT
├── meta-filesystems
├── meta-gnome
├── meta-initramfs
├── meta-multimedia  // 이 아래의 4개의 layer만  rpi-build/conf/bblayers.conf 에 추가 
├── meta-networking
├── meta-oe
├── meta-perl
├── meta-python
├── meta-webserver
├── meta-xfce
└── README

  https://layers.openembedded.org/layerindex/branch/master/layer/meta-oe/
  http://cgit.openembedded.org/meta-openembedded/tree/


  • Yocto poky 에서 구조확인가능 
  http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/


2.4 이외의 meta-layer 추가방법  

Cookbook을 보면 자세히 나오며 각각 Layer들을 추가하여 확장하기가 쉽다. 다만, Type은 반드시 확인을 해야한다.

  • OpenEmbeded Layer Index 의 meta-oe Layer 검색
  1. meta-oe (meta-openembedded)  Layer Type Base를 찾음 
  2. meta-raspberrypi  검색 과 Layer Type BSP 확인 



Reference Manual에는 Layer Type은 3가지밖에 없지만, 이곳에는 다음과 같이 더 분류를 하고 의미가 조금 다른 것 같다.


  • Layer Type 
  1. Base: Emdedded에서 기본 Layer로 개발 Tools 및 Kernel 관련부부구성 
  2. Machine (BSP) : 각 개별 Board에 맞게 BSP 가 구성되어있어 선택 
  3. Distribution : Poky를 기반으로 확장된 배포판으로 구성되어짐
  4. Miscellaneous :  개발환경 혹은 특정 ARCH에 의존적으로 구성이됨 
  5. Software : 쉽게 추가가능한 Opensource (이 Layer를 추가)

Base는 현재 meta-oeopenembedded-core 두 종류로 제공하고 있지만, meta-oe만 주로 사용한다

  1. meta-oe : Embedded에서 필요한 개발 Tool 및 Kernel
  2. openembedded-core:  많은 부분이 poky와 중복되는 것 같음 


OpenEmbedded Layer Index
  https://layers.openembedded.org/layerindex/branch/master/layers/

Yocto Site
  http://git.yoctoproject.org/cgit.cgi/

3. Yocto의 설정확인 및 변경 

bitbake를 사용하기 위해서 아래와 같이 기본빌드환경을 설정해줘야 한다

pocky 안에 oe-init-build-env를 실행하면, bitbake 사용 및 rpi-build directory가 생성이 된다.
물론 그냥 poky안에서 oe-init-build는 상관은 없지만, 모든 빌드내용이 rpi-build에 저장되기때문에 이를 외부를 분리하는 것이다.

$ source poky/oe-init-build-env rpi-build

build directory(rpi-build) 의 이름을 변경을 해도 상관없음

  • Raspberry PI  Yocto 전체구성
물론 rpi-build를 poky 안에도 생성이 가능하지만 이를 외부를 분리하여 Yocto와 Build 부분을 분리한다.

$ tree -d -L 2
├── poky
│   ├── bitbake
│   ├── documentation
│   ├── meta
│   ├── meta-openembedded  // 추가될 layers로 하위 디렉토리에 layer가 존재 
│   ├── meta-poky
│   ├── meta-raspberrypi  // 추가될 layer
│   ├── meta-selftest
│   ├── meta-skeleton
│   ├── meta-yocto-bsp
│   └── scripts
└── rpi-build   // 이곳에서 빌드를 진행하므로, 추후 제거 할때도 이부분만 제거 (2.1 이후 생성)
    ├── cache 
    ├── conf             // 빌드할 Layers 및 MACHINE  설정 
    ├── downloads        // GIT Download   
    ├── sstate-cache
    └── tmp              // tmp/deploy/image/machine/xxxxx  배포 

  • rpi-build 의 user configuration 설정 
  1. ./conf/bblayers.conf     // build할 Layer 추가 
  2. ./conf/local.conf         // build될 machine 설정 


3.1 rpi-build/conf/bblayers.conf  

본인이 bitbake를 이용하여 빌드하고자하는 각 Layer들을 적용을 하자

  • rpi-build/conf/bblayers.conf 에 Layer 추가  
meta-openembedded의 경우 다수의 meta-layer로 구성이 되어있으므로 아래와 같이 추가.

$ cd rpi-build 
$ vi ./conf/bblayers.conf
.......
BBLAYERS ?= " \
  /home/jhlee/raspberrypi/poky/meta \
  /home/jhlee/raspberrypi/poky/meta-poky \
  /home/jhlee/raspberrypi/poky/meta-yocto-bsp \
  /home/jhlee/raspberrypi/poky/meta-openembedded/meta-oe \
  /home/jhlee/raspberrypi/poky/meta-openembedded/meta-multimedia \
  /home/jhlee/raspberrypi/poky/meta-openembedded/meta-networking \
  /home/jhlee/raspberrypi/poky/meta-openembedded/meta-python \
  /home/jhlee/raspberrypi/poky/meta-raspberrypi \
  "


3.2  rpi-build/conf/local.conf 

MACHINE의 설정전체 변수관련부분 설정 MACHINE이 아니더라도 본인이 원하는 부분을 설정을 하면 전체 적용되므로 중요

  • rpi-build/conf/local.conf 에 Machine 설정
이제 본인의 board machine을 찾았으니, 이를 적용하자 (상위 conf 제외한 이름)

$ cd rpi-build 
$ vi ./conf/local.conf 
#
# Machine Selection
#
# You need to select a specific machine to target the build with. There are a selection
# of emulated machines available which can boot and run in the QEMU emulator:
#
#MACHINE ?= "qemuarm"
#MACHINE ?= "qemuarm64"
#MACHINE ?= "qemumips"
#MACHINE ?= "qemumips64"
#MACHINE ?= "qemuppc"
#MACHINE ?= "qemux86"
#MACHINE ?= "qemux86-64"
#
# There are also the following hardware board target machines included for 
# demonstration purposes:
#
#MACHINE ?= "beaglebone-yocto"
#MACHINE ?= "genericx86"
#MACHINE ?= "genericx86-64"
#MACHINE ?= "mpc8315e-rdb"
#MACHINE ?= "edgerouter"
#
MACHINE ?= "raspberrypi3-64"
# This sets the default machine to be qemux86 if no other machine is selected:
#MACHINE ??= "qemux86" 


3.3 MACHINE의 Config 확인 

conf/local.conf 에서 설정한 MACHINE 은 항상 동일한 이름으로 conf가 존재하며 이를 찾아 관련설정을  확실히 확인하자 

  • MACHINE raspberrypi3-64.conf  확인 
$ cd pocky 
$ find . -name machine | xargs ls        // MACHINE의 이름을 모를 경우 모든 BSP Layer 검색 
./meta/conf/machine:
include         qemuarm.conf    qemuarm64.conf   qemumips.conf     qemumips64.conf  
qemuppc.conf    qemux86-64.conf qemux86.conf

./meta-raspberrypi/conf/machine:
include/                raspberrypi-cm3.conf    raspberrypi0-wifi.conf  raspberrypi2.conf       raspberrypi3.conf       
raspberrypi-cm.conf     raspberrypi.conf        raspberrypi0.conf       raspberrypi3-64.conf  

./meta-selftest/conf/machine:
qemux86copy.conf

./meta-yocto-bsp/conf/machine:
beaglebone-yocto.conf  edgerouter.conf  genericx86-64.conf  genericx86.conf  include  mpc8315e-rdb.conf

or 
$ find . -name raspberrypi3-64.conf  // MACHINE 이름을 정확히 아는 경우 

주로 확인해야 할 것이 UBOOT 설정 과 KERNEL 및 Device Tree 가 될 것 같다

  • 지원 MACHINE 이름 
  https://layers.openembedded.org/layerindex/branch/master/machines/


4. Bitbake로 기본 빌드 

bitbake는 상위 pocky->bitbake안에 존재하므로 이것이 PATH에 적용이 되지 않을 경우는 아래와 같이 동작하지 않는다.
다시 설정하고 싶다면 2.를 다시 설정하면 되며, 상위 저장된 설정도 기억하고 있다.

  • Bitbake로 빌드진행  
$ bitbake core-image-base 

빌드를 할 경우, 상당한 시간과 용량을 필요로 하며, 용량은 VDI의 경우 최소 50G로 잡자.
처음 30G (Ubuntu까지 설치된 상태)로 빌드를 진행을  했는데, 용량부족으로 실패했다.


4.1 core-image-minimal 와 core-image-base 차이 

yocto에서 image를 생성하기 위해서 상위 target 설정이외 sato or x11 등 다양하게 확장제공하고 있지만, 일단 2개의 정확한 차이를 알아두고 어떻게 확장하는지 알아보자.

  • bitbake에서 image를 만들때 가장 많이 사용하는 Target or Recipe 
  1. core-image-minimal: 기본으로 boot하고 기본동작되는 확인
  2. core-image-base: core-image-minimal 에 MACHINE의 HW의 모든기능을 제공 및 테스트 가능 

  • core-image-base 와 core-image-minimal 각 위치확인 
$ pwd
/home/jhlee/raspberrypi/poky

$ find . -name core-image-minimal*
./meta/recipes-core/images/core-image-minimal-mtdutils.bb
./meta/recipes-core/images/core-image-minimal-initramfs.bb
./meta/recipes-core/images/core-image-minimal.bb
./meta/recipes-core/images/core-image-minimal-dev.bb

$ find . -name core-image-base*
./meta/recipes-core/images/core-image-base.bb

  • core-image-minimal 의 구성확인  
  1. IMAGE_INSTALL : packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL} 직접정의 
  2. inherit core-image : core-image*.bbclass를 사용 

$ cat ./meta/recipes-core/images/core-image-minimal.bb // 아래의 core-image.bbclass 부분과 비교 
SUMMARY = "A small image just capable of allowing a device to boot."

IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"

IMAGE_LINGUAS = " "

LICENSE = "MIT"

inherit core-image

IMAGE_ROOTFS_SIZE ?= "8192"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "" ,d)}" 


  • core-image-base 의 구성  (core-image.bbclass의 IMAGE_INSTALL 사용)
  1. IMAGE_INSTALL:  설정정의가 없으므로, core-image*.bbclass에 정의된 것으로 동작 
  2. inherit core-image : core-image*.bbclass를 사용 

$ cat ./meta/recipes-core/images/core-image-base.bb
SUMMARY = "A console-only image that fully supports the target device \
hardware."

IMAGE_FEATURES += "splash"

LICENSE = "MIT"

inherit core-image 


  • core-image.bbclass  ( inherit core-image 검색)
core-image-minimal 과 core-image-base 의 차이는 IMAGE_INSTALL 차이 
core-image-base의 경우 packagegroup-base-extended 부분이 추가됨


$ find . -name core-image*bb* 
..
./meta/classes/core-image.bbclass
..
$ cat ./meta/classes/core-image.bbclass //  inherit core-image 관련부분 확인 

CORE_IMAGE_BASE_INSTALL = '\
    packagegroup-core-boot \
    packagegroup-base-extended \
    \
    ${CORE_IMAGE_EXTRA_INSTALL} \
    '

IMAGE_INSTALL ?= "${CORE_IMAGE_BASE_INSTALL}"  

inherit image 


  • image.bbclass (inherit image)
image를 만드는 시작점인 것 같으며, 소스를 보면 전체 동작방식을 대충 이해가 가며 python으로도 구성이되어 소스내용이 길다.

$ find . -name image*bb*  // inherit image 관련부분 검색  
..
./meta/classes/image.bbclass

$ cat ./meta/classes/image.bbclass  
IMAGE_CLASSES ??= ""

# rootfs bootstrap install
# warning -  image-container resets this
ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts"

# Handle inherits of any of the image classes we need
IMGCLASSES = "rootfs_${IMAGE_PKGTYPE} image_types ${IMAGE_CLASSES}"
# Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base
# in the non-Linux SDK_OS case, such as mingw32
IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}"
IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
IMGCLASSES += "image_types_wic"
IMGCLASSES += "rootfs-postcommands"
IMGCLASSES += "image-postinst-intercepts"
inherit ${IMGCLASSES}
..... 너무길어 중략 (do_rootfs 비롯하여 다른 중요부분도 한번봐야함)


공통적으로 inherit core-image로 공유해서 사용되어지고 있으며, 이 부분은 bbclass 로 되어있고, 이 공유하며,
중요한 부분은 IMAGE_INSTALL 의 정의차이를 보면 될 것 같다.

아래링크참조
  https://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#ref-classes-core-image
  https://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#ref-classes-image
  https://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html


4.2 core-image-xxx 확장 및 본인의 Image target 확장 

recipe 내에서 include recipe-core/images/core-image-base.bb 추가하여 확장하는 구조이다.

  • raspberry pi target recipe 확장분석  
core-image-minimal 기반으로 본인이 필요한 Package들을 IMAGE_INSTALL 추가하는 방식
rpi-basic-image는 앞으로 안 사용되어질 거라고 하는데, core-image-base 로 하면 될 것 같다.

$ vi meta-raspberrypi/recipes-core/images/rpi-basic-image.bb  
# Base this image on core-image-minimal
include recipes-core/images/core-image-minimal.bb

# Include modules in rootfs
IMAGE_INSTALL += " \
        kernel-modules \
        "

SPLASH = "psplash-raspberrypi"

IMAGE_FEATURES += "ssh-server-dropbear splash"

do_image_prepend() {
    bb.warn("The image 'rpi-basic-image' is deprecated, please use 'core-image-base' instead")
}


  • 나만의 target image recipe 로 확장 
IMAGE_INSTALL에 본인이 필요한 Package들을 정의하여 넣고, 새로운 Target Image recipe로 정의

$ vi meta-raspberrypi/recipes-core/images/core-image-jhlee.bb  
SUMMARY = "JHLee Sample Test Image"

# Base this image on core-image-minimal
include recipes-core/images/core-image-base.bb

# ssh server and systemd and tcpdump
IMAGE_INSTALL += "openssh systemd-analyze tcpdump"
        
export IMAGE_BASENAME = "core-image-jhlee"



recipe 검색
  https://layers.openembedded.org/layerindex/branch/master/recipes/


4.3 SD Image 확인 및 Writing Image

  • How to find SD image
bitbake로 core-image-base 빌드 한 후 deploy에서 확인 (SD Image)

$ cd rpi-build/tmp/deploy/images/raspberrypi3-64
$ ls *.rpi*
core-image-base-raspberrypi3-64-20180526144104.rootfs.rpi-sdimg  core-image-base-raspberrypi3-64.rpi-sdimg 


  • How To write SD Image 
Linux에서 SD Disk를 접근가능하다면 Image Writing을 할수 있다. ( Virtual Box도 연결해서 하면되지만 절차가 복잡)

$ sudo dd if=core-image-base-raspberrypi3-64.rpi-sdimg of=/dev/sde bs=1M   // 이부분 SD Disk와 연결되었을 경우

상위명령어 대신 이 Image 파일을 Window로 가져와서 Win32DiskImager를 이용하자

  • Win32DiskImager
  https://ahyuo.blogspot.com/2016/05/sd-card-writer-window.html


4.4 Bitbake Build 분석 및 에러사항

  • Bitbake 빌드 분석 
WARNING: Host distribution "ubuntu-14.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Build Configuration:
BB_VERSION           = "1.37.0"
BUILD_SYS            = "x86_64-linux"        // HOST의 Build System 
NATIVELSBSTRING      = "universal-4.8"       // Ubuntu 일 경우 ubuntu로 표시  
TARGET_SYS           = "aarch64-poky-linux"  // Target system 이름 ARM을 사용할 경우 ARM이 표시됨 
MACHINE              = "raspberrypi3-64"     // Board의 Machine 이름   
DISTRO               = "poky"
DISTRO_VERSION       = "2.5"
TUNE_FEATURES        = "aarch64"              // Compiler 관련 설정  
TARGET_FPU           = ""                     // Hardware FPU 설정 
meta                 
meta-poky            
meta-yocto-bsp       = "master:13cc30cd7de4841990b600e83e1249c81a5171dd"
meta-oe              
meta-multimedia      
meta-networking      
meta-python          = "master:d59b9806f743cea0168cddf942a31dcf446839e6"
meta-raspberrypi     = "master:7f7bc9e778b6def018c451ecb23f5169cd18f5ed"


  • 문제사항 1
  https://github.com/WebPlatformForEmbedded/meta-wpe/issues/151

$ bitbake core-image-base 
ERROR: Unable to start bitbake server
ERROR: Last 10 lines of server log for this session (/home/jhlee/raspberrypi/rpi-build/bitbake-cookerdaemon.log):
    self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset)
  File "/home/jhlee/raspberrypi/poky/bitbake/lib/bb/cooker.py", line 197, in __init__
    self.initConfigurationData()
  File "/home/jhlee/raspberrypi/poky/bitbake/lib/bb/cooker.py", line 356, in initConfigurationData
    self.databuilder.parseBaseConfiguration()
  File "/home/jhlee/raspberrypi/poky/bitbake/lib/bb/cookerdata.py", line 317, in parseBaseConfiguration
    raise bb.BBHandledException
bb.BBHandledException
ERROR: The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:
  chrpath gawk makeinfo

아래 Package 설치 후 문제해결 (상위에 모두 표시)

$ sudo apt install gawk
$ sudo apt-get install chrpath
$ sudo apt-get install texinfo

  • 문제사항 2
WARNING: Host distribution "ubuntu-14.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
.......
ERROR: mpfr-native-3.1.5-r0 do_compile: oe_runmake failed
ERROR: mpfr-native-3.1.5-r0 do_compile: Function failed: do_compile (log file is located at /home/jhlee/raspberrypi/rpi-build/tmp/work/x86_64-linux/mpfr-native/3.1.5-r0/temp/log.do_compile.13203)
ERROR: Logfile of failure stored in: /home/jhlee/raspberrypi/rpi-build/tmp/work/x86_64-linux/mpfr-native/3.1.5-r0/temp/log.do_compile.13203
....
| x86_64-linux-libtool:   error: 'set_si_2exp.lo' is not a valid libtool object
| make[2]: *** [libmpfr.la] Error 1
| make[2]: Leaving directory `/home/jhlee/raspberrypi/rpi-build/tmp/work/x86_64-linux/mpfr-native/3.1.5-r0/build/src'
| make[1]: *** [all] Error 2
| make[1]: Leaving directory `/home/jhlee/raspberrypi/rpi-build/tmp/work/x86_64-linux/mpfr-native/3.1.5-r0/build/src'
| make: *** [all-recursive] Error 1
| ERROR: oe_runmake failed
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_compile (log file is located at /home/jhlee/raspberrypi/rpi-build/tmp/work/x86_64-linux/mpfr-native/3.1.5-r0/temp/log.do_compile.13203)
ERROR: Task (virtual:native:/home/jhlee/raspberrypi/poky/meta/recipes-support/mpfr/mpfr_3.1.5.bb:do_compile) failed with exit code '1'


Ubuntu 16으로 변경 후 문제 해결 (처음 Ubuntu 14.04로 진행함)
  https://stackoverflow.com/questions/36226828/yocto-bitbake-script-not-displaying-echo-statement