Difference between revisions of "IoTGateway/BSP/Linux/Quark/Yocto LBV2 User Guide"

From ESS-WIKI
Jump to: navigation, search
(Creating boot-up on-board flash from built sdcard image)
Line 178: Line 178:
  
 
=Customization=
 
=Customization=
==<span style="color:#0070c0;">Package addition</span>==
 
===<span style="color:#0070c0;">To add tcf-agent & openssh-sftp-server</span>===
 
:Navigate to the directory where fsl-image-adv.inc located
 
::<code>$ cd <span style="color:#7030a0;">'''${BSP_HOME}'''</span>/sources/meta-advantech/recipes-fsl/images</code>
 
:Add following line to fsl-image-adv.inc
 
::<code>IMAGE_INSTALL += " tcf-agent openssh-sftp-server "</code>
 
:[[IoTGateway/BSP/Linux/iMX6/Yocto_LBV5_User_Guide#To_continue_an_exist_build_environment|Continue an exist build environment]] and [[IoTGateway/BSP/Linux/iMX6/Yocto_LBV5_User_Guide#To_build_sdcard_image|build sdcard image]]
 
 
===<span style="color:#0070c0;">To add chromium browser</span>===
 
:Navigate to the directory where local.conf located
 
::<code>$ cd <span style="color:#7030a0;">'''${BSP_HOME}'''</span>/<span style="color:#7030a0;">'''${BDIR</span><span style="color:#7030a0;">}'''</span>/conf</code>
 
:Add following two lines to local.conf
 
::<code>CORE_IMAGE_EXTRA_INSTALL += "chromium"</code>
 
::<code>LICENSE_FLAGS_WHITELIST="commercial"</code>
 
:[[IoTGateway/BSP/Linux/iMX6/Yocto_LBV5_User_Guide#To_continue_an_exist_build_environment|Continue an exist build environment]] and [[IoTGateway/BSP/Linux/iMX6/Yocto_LBV5_User_Guide#To_build_sdcard_image|build sdcard image]]
 
 
 
==<span style="color:#0070c0;">Setting up SDK</span>==
 
==<span style="color:#0070c0;">Setting up SDK</span>==
:Please follow the section,[[IoTGateway/BSP/Linux/iMX6/Yocto_LBV5_User_Guide#To_build_toolchain_installer|To build toolchain installer]], to build one toolchain installer
+
:Please follow the section,[[IoTGateway/BSP/Linux/Quark/Yocto_LBV2_User_Guide#To_build_toolchain_installer|to build toolchain installer]], to build one toolchain installer first.
 
:Perform the following command in terminal console
 
:Perform the following command in terminal console
 
::<code>$ cd <span style="color:#7030a0;">'''${BSP_HOME}'''</span>/<span style="color:#7030a0;">'''BDIR</span><span style="color:#7030a0;">}'''</span>/tmp/deploy/sdk</code>
 
::<code>$ cd <span style="color:#7030a0;">'''${BSP_HOME}'''</span>/<span style="color:#7030a0;">'''BDIR</span><span style="color:#7030a0;">}'''</span>/tmp/deploy/sdk</code>
::<code>$ sudo ./poky-eglibc-x86_64-fsl-image-qt5-cortexa9hf-vfp-neon-toolchain-<span style="color:#7030a0;">'''${POKY}'''</span>.sh</code>
+
::<code>$ sudo ./iot-devkit-glibc-x86_64-image-full-i586-toolchain-<span style="color:#7030a0;">'''${POKY}'''</span>.sh</code>
 +
 
 
:Enter directory or press Enter while following question shows up:
 
:Enter directory or press Enter while following question shows up:
::[[File:setting_up_sdk_1.png]]
+
<tt><big>
 +
::<span style="color:white;background:black">Enter target directory for SDK (default: /opt/iot-devkit/1.7.2):</span>
 +
</big></tt>
 +
 
 
:Just press Enter while following question shows up:
 
:Just press Enter while following question shows up:
::[[File:setting_up_sdk_2.png]]
+
<tt><big>
 +
::<span style="color:white;background:black">You are about to install the SDK to "/opt/iot-devkit/1.7.2". Proceed[Y/n]?</span>
 +
</big></tt>
 
:While following message shows up means the SDK is ready.
 
:While following message shows up means the SDK is ready.
::[[File:setting_up_sdk_3.png]]
+
<tt><big>
 +
::{| style="color:white;background:black"
 +
|Extracting SDK...done
 +
|-
 +
|Setting it up...done
 +
|-
 +
|SDK has been successfully set up and is ready to be used.
 +
|}
 +
</big></tt>
  
 
==<span style="color:#0070c0;">Setting up cross compiling environment</span>==
 
==<span style="color:#0070c0;">Setting up cross compiling environment</span>==
 
:SDK has been set up (ref. [[#Setting_up_SDK|Setting up SDK]])
 
:SDK has been set up (ref. [[#Setting_up_SDK|Setting up SDK]])
 
:Perform the following command in terminal console
 
:Perform the following command in terminal console
::<code>$ source /opt/poky/<span style="color:#7030a0;">'''${POKY}'''</span>/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi</code>
+
::<code>$ source /opt/iot-devkit/<span style="color:#7030a0;">'''${POKY}'''</span>/environment-setup-i586-poky-linux</code>
 
 
==<span style="color:#0070c0;">Building & updating u-boot manually</span>==
 
===<span style="color:#0070c0;">To build u-boot</span>===
 
:The cross compiling environment has been set up. (ref. [[#Setting_up_cross_compiling_environment|Setting up cross compiling environment]])
 
:Make one copy from Yocto working directory
 
::<code>$ mkdir -p ~/code</code>
 
::<code>$ pushd <span style="color:#7030a0;">'''${BSP_HOME}'''</span>/<span style="color:#7030a0;">'''${BDIR}'''</span>/tmp/work/<span style="color:#7030a0;">'''${MC}'''</span>-poky-linux-gnueabi/</code>
 
::<code>$ rm -rf ~/code/u-boot-imx</code>
 
::<code>$ cp -a ./u-boot-imx/<span style="color:#7030a0;">'''${UBOOT}'''</span>/git ~/code/u-boot-imx</code>
 
::<code>$ popd</code>
 
:Configure u-boot
 
::<code>$ cd ~/code/u-boot-imx</code>
 
::<code>$ make distclean</code>
 
::<code>$ make <span style="color:#7030a0;">'''${MX6PROC}${BOARD}${BOARD_REV}'''</span>_<span style="color:#7030a0;">'''${MEM_SIZE}'''</span>_config</code>
 
:Start building u-boot
 
::<code>$ make -j4 LDFLAGS=</code>
 
:The two files, u-boot-crc.bin & u-boot-crc.bin.crc, are located in directory "~/code/u-boot-imx".
 
 
 
===<span style="color:#0070c0;">To update u-boot to target device</span>===
 
:Perform the following command to transfer to exist boot-up SD card
 
::<code>$ dd if=u-boot_crc.bin.crc of=<span style="color:#7030a0;">'''${SD_DEVICE}'''</span> bs=512 seek=2 conv=fsync</code>
 
::<code>$ dd if=u-boot-crc.bin of=<span style="color:#7030a0;">'''${SD_DEVICE}'''</span> bs=512 seek=3 conv=fsync</code>
 
:Make sure new u-boot does work then perform the following commands to transfer to on-board flash
 
::<code># dd if=u-boot_crc.bin.crc of=/dev/mmcblk0 bs=512 seek=2 conv=fsync</code>
 
::<code># dd if=u-boot-crc.bin of=/dev/mmcblk0 bs=512 seek=3 conv=fsync</code>
 
 
 
==<span style="color:#0070c0;">Building & updating kernel/modules/dtb manually</span>==
 
===<span style="color:#0070c0;">To build kernel/modules/dtb</span>===
 
:The cross compiling environment has been set up. (ref. [[#Setting_up_cross_compiling_environment|Setting up cross compiling environment]])
 
 
 
:Make one copy from Yocto working directory
 
::<code>$ mkdir -p ~/code</code>
 
::<code>$ pushd <span style="color:#7030a0;">'''${BSP_HOME}'''</span>/<span style="color:#7030a0;">'''${BDIR}'''</span>/tmp/work/<span style="color:#7030a0;">'''${MC}'''</span>-poky-linux-gnueabi/</code>
 
::<code>$ rm -rf ~/code/linux-imx</code>
 
::<code>$ cp -a ./linux-imx/${KERNEL}/git ~/code/inux-imx</code>
 
::<code>$ popd</code>
 
 
 
:Configure linux kernel
 
::<code>$ cd ~/code/linux-imx</code>
 
::<code>$ make distclean</code>
 
::<code>$ make imx_v7_adv_defconfig</code>
 
::<code>$ make menuconfig PKG_CONFIG_SYSROOT_DIR= PKG_CONFIG_PATH=</code>
 
 
 
:Start building linux kernel
 
::<code>$ make -j4 zImage LOADADDR=0x10008000 LDFLAGS=</code>
 
 
 
:The kernel image file, zImage, is located in the directory "./arch/arm/boot/".
 
 
 
:Start building kernel modules
 
::<code>$ make -j4 modules LDFLAGS=</code>
 
 
 
:Copy all modules to a temporary rootfs directory, "~/temp/rootfs"
 
::<code>$ make modules_install INSTALL_MOD_PATH=~/temp/rootfs</code>
 
 
 
:Start building device tree blob
 
::<code>$ make -j4 <span style="color:#7030a0;">'''${IMX6PROC}'''</span>-<span style="color:#7030a0;">'''${BOARD}'''</span>-<span style="color:#7030a0;">'''${BOARD_REV}'''</span>.dtb</code>
 
 
 
:The device tree blob, <span style="color:#7030a0;">'''${IMX6PROC}'''</span>-<span style="color:#7030a0;">'''${BOARD}'''</span>-<span style="color:#7030a0;">'''${BOARD_REV}'''</span>.dtb, is located in the directory "./arch/arm/boot/dts/".
 
 
 
===<span style="color:#0070c0;">To update kernel/modules/dtb to target device</span>===
 
:Copy zImage & <span style="color:#7030a0;">'''${IMX6PROC}'''</span>-<span style="color:#7030a0;">'''${BOARD}'''</span>-<span style="color:#7030a0;">'''${BOARD_REV}'''</span>.dtb to the 1<sup>st</sup> partition of SD card
 
:Copy modues to the 2<sup>nd</sup> partition of SD card.
 
:Make sure all new linux kernel, device tree and kernel modules work well, then copy all of them to the on-board flash
 
  
 
=System Recovery=
 
=System Recovery=
 
Please refer to [[#Creating_boot-up_on-board_flash_from_prebuilt_image|Creating boot-up on-board flash from prebuilt image]] / [[#Creating_boot-up_on-board_flash_from_built_sdcard_image|sdcard image]] to create a boot-up SD card and transfer whole system to on-board flash.
 
Please refer to [[#Creating_boot-up_on-board_flash_from_prebuilt_image|Creating boot-up on-board flash from prebuilt image]] / [[#Creating_boot-up_on-board_flash_from_built_sdcard_image|sdcard image]] to create a boot-up SD card and transfer whole system to on-board flash.

Revision as of 08:49, 15 April 2016

Yocto Linux BSP Ver.2 User Guide for Quark series

Getting Started

Prerequisites

All operations in this guide are based on Ubuntu 12.04 LTS 64bit only.
First please install Ubuntu 12.04 LTS 64bit* with minimum 2GB memory.
* ubuntu-12.04.1-desktop-amd64.iso

To install required packages

Please login and perform the following commands:

$ sudo apt-get install ssh
$ sudo apt-get install ia32-libs libx11-dev:i386 libreadline6-dev:i386 \
libgl1-mesa-glx:i386 zlib1g-dev:i386 uuid-dev:i386 liblzo2-dev:i386 \ 
libncurses5-dev:i386
$ sudo apt-get install \
bison build-essential ccache dpkg flex gcc g++ gettext intltool \
libarchive-zip-perl libfreetype6-dev libdbus-glib-1-dev liborbit2-dev \
libxml2-dev libx11-dev libgtk2.0-dev liblzo2-2 libtool m4 \
patch rpm tcl uboot-mkimage uuid zlib1g zlib1g-dev \
git gnupg flex bison gperf build-essential  zip \
curl libc6-dev libncurses5-dev x11proto-core-dev libx11-dev:i386 \
libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib \
mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \
gcc-4.6 g++-4.6 cpp-4.6 gcc-4.6-multilib uuid-dev liblzo2-dev \
uboot-mkimage libarchive-zip-perl \
wget git-core unzip texinfo gawk diffstat build-essential chrpath \
sed cvs subversion coreutils texi2html \
docbook-utils python-pysqlite2 help2man make gcc g++ \
desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial \
autoconf automake groff curl lzop asciidoc xterm
$ sudo apt-get install libncurses5-dev:i386 liblzo2-dev:i386 uuid-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
$ tar zcvf ~/usr_lib_i386-linux-gnu_for_Building_Android_KK.tar.gz \
/usr/lib/i386-linux-gnu/{libuuid.a,libuuid.so,liblzo2.so,liblzo2.a}
$ sudo apt-get install uuid-dev liblzo2-dev
$ sudo tar zxvf ~/usr_lib_i386-linux-gnu_for_Building_Android_KK.tar.gz -C /

To install JDK

Please download "jdk-6u45-linux-x64.bin" manually, put it to directory ~/FILES/ and perform the following commands:

$ cd /usr/lib
$ sudo ~/FILES/jdk-6u45-linux-x64.bin
$ sudo mkdir jvm
$ cd jvm
$ sudo mv ../jdk1.6.0_45 .
$ cd jdk1.6.0_45/
$ sudo update-alternatives --install /usr/bin/java    java    /usr/lib/jvm/jdk1.6.0_45/jre/bin/java    2
$ sudo update-alternatives --install /usr/bin/javac   javac   /usr/lib/jvm/jdk1.6.0_45/bin/javac   2
$ sudo update-alternatives --install /usr/bin/jar     jar     /usr/lib/jvm/jdk1.6.0_45/bin/jar     2
$ sudo update-alternatives --install /usr/bin/javap   javap   /usr/lib/jvm/jdk1.6.0_45/bin/javap   2
$ sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.6.0_45/bin/javadoc 2
$ sudo update-alternatives --config javap
$ sudo update-alternatives --config javadoc
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config jar
$ cd ~/
$ sudo sh -c "echo "JAVA_HOME=/usr/lib/jvm/jdk1.6.0_45" >> /etc/environment"

Conventions

${BOARD_ID} : board ID

e.g. ubc222 or ubc221

${IMAGE_PACK} : prebuilt image pack

e.g. ubc222 or ubc221

${IMAGE_DIR} : the directory prebuilt image pack extracted to

e.g. ~/U222LIV2011_quark_2016-01-29

${BSP_PACK} : BSP pack

e.g. U222LIV2011_quark_2016-01-29.zip

${BSP_HOME} : the directory BSP pack extracted to

e.g. ~/LBV2011/meta-clanton_v1.2.0

${BDIR} : build directory

e.g. yocto_build

${DEPLOY_IMAGE} : all built images are located in this relative path starts from ${BDIR}

e.g. tmp/deploy/images/quark

${DEPLOY_SDK} : the built SDK is located in this relative path starts from ${BDIR}

e.g. tmp/deploy/sdk

${SD_MOUNT} : mount point of SD card in Ubuntu

e.g. /media/sdf1

${POKY} : Yocto poky version

e.g. 1.7.2

debug console / serial console

serial terminal program (e.g. minicom, putty, teraterm ...) that serial port is configured to 115200 8N1

terminal console

terminal program (e.g. gnome-terminal, xfce4-terminal ...)

Introducing BSP

The BSP is based on Yocto Project with Intel enhanced features for Quark, plus specific target board features from Advantech Inc..

Naming Rule

The tarball/prebuilt image name is consist of the model name followed by "LB" or "LI" plus version number and released date.
For example, U222LBV2011_2016-01-29.zip which "U222" stands for UBC-222, "LB" is acronym of Linux BSP, "V2011" stands for Version 2.011.
For example, U222LBV2011_quark_2016-01-29.zip which "LI" is acronym for prebuilt Linux Image.

BSP pack

Unpack BSP pack to home directory by performing the following command:
$ unzip ${BSP_PACK} -d ~/
The description of some important folders list below:
$BSP_HOME/meta-clanton_v1.2.0
meta-advantech/ : meta layer by Advantech
meta-intel-*/ : meta layer by Intel
setup.sh : to setup one new build environment
oe-init-build-env : to initiate build environment

Prebuilt image pack

Perform the following command to unpack prebuilt-image-pack to home directory
$ unzip ${PREBUILT_IMAGE_PACK} -d ~/
Prepare one FAT32 formatted SD card, and mount it to mount point
$ cp -a ${PREBUILT_IMAGE_DIR}/sdcard/* ${SD_MOUNT}/

Build Instructions

To create one new build environment

Perform the following commands in terminal console
$ cd ${BSP_HOME}
$ ./setup.sh
$ BOARD=${BOARD_ID} source ./oe-init-build-env ${BDIR}

To continue an exist build environment

Perform the following commands in terminal console
$ cd ${BSP_HOME}
$ BOARD=${BOARD_ID} source ./oe-init-build-env

To build all image files

To create/continue a build environment
Perform the following command in terminal console
$ bitbake image-full
The following files will be located in directory "./tmp/deploy/images/quark" while building process finished successfully.

boot/grub/grub.conf
bzImage
core-image-minimal-initramfs-quark.cpio.gz
grub.efi
image-full-quark.ext3

To build toolchain installer

To create/continue a build environment
Perform the following command in terminal console
$ bitbake image-full -c populate_sdk
The installer, iot-devkit-glibc-x86_64-image-full-i586-toolchain-${POKY}.sh, will be located in the directory "./tmp/deploy/sdk".</code>

To build grub individually

To create/continue a build environment
Perform the following command in terminal console
$ bitbake grub
The file, grub.efi, will be located in directory, ./tmp/deploy/images/quark.

To build linux kernel individually

To create/continue a build environment
Perform the following command in terminal console
to show up menuconfig
$ bitbake linux-yocto-quark -c menuconfig
to do build
$ bitbake linux-yocto-quark
The file, bzImage, will be located in directory, ./tmp/deploy/images/quark.

To build initramfs individually

To create/continue a build environment
Perform the following command in terminal console
$ bitbake core-image-minimal-initramfs
The file, core-image-minimal-initramfs-quark.cpio.gz, will be located in directory, ./tmp/deploy/images/quark.

Customization

Setting up SDK

Please follow the section,to build toolchain installer, to build one toolchain installer first.
Perform the following command in terminal console
$ cd ${BSP_HOME}/BDIR}/tmp/deploy/sdk
$ sudo ./iot-devkit-glibc-x86_64-image-full-i586-toolchain-${POKY}.sh
Enter directory or press Enter while following question shows up:

Enter target directory for SDK (default: /opt/iot-devkit/1.7.2):

Just press Enter while following question shows up:

You are about to install the SDK to "/opt/iot-devkit/1.7.2". Proceed[Y/n]?

While following message shows up means the SDK is ready.

Extracting SDK...done
Setting it up...done
SDK has been successfully set up and is ready to be used.

Setting up cross compiling environment

SDK has been set up (ref. Setting up SDK)
Perform the following command in terminal console
$ source /opt/iot-devkit/${POKY}/environment-setup-i586-poky-linux

System Recovery

Please refer to Creating boot-up on-board flash from prebuilt image / sdcard image to create a boot-up SD card and transfer whole system to on-board flash.