2016年10月8日 星期六

Using openembedded to build QEMU


這篇文章主要來說明如何使用Openembedded/Krogoth來build出QEMU for ARM。
步驟大概就是:
先下載yp-krogoth之後,source目錄下的oe-init-build-env,接著再編輯conf/local.conf,最後就是執行bitbake core-image-minimal。
我的Krogoth最後一個commit ID是e93596f。
brook@vista:~/projects$ git clone -b krogoth git://git.yoctoproject.org/poky.git yp-krogoth
Cloning into 'yp-krogoth'...
remote: Counting objects: 339411, done.
remote: Compressing objects: 100% (82247/82247), done.
remote: Total 339411 (delta 251486), reused 338934 (delta 251035)
Receiving objects: 100% (339411/339411), 127.65 MiB | 4.49 MiB/s, done.
Resolving deltas: 100% (251486/251486), done.
Checking connectivity... done.
brook@vista:~/projects$ cd yp-krogoth/
brook@vista:~/projects/yp-krogoth$ git log --oneline -1
e93596f binutils: fix AR issue when opkg is unpacking IPKs containing empty entries
brook@vista:~/projects/yp-krogoth$ . oe-init-build-env
You had no conf/local.conf file. This configuration file has therefore been
created for you with some default values. You may wish to edit it to, for
example, select a different MACHINE (target hardware). See conf/local.conf
for more information as common configuration options are commented.

You had no conf/bblayers.conf file. This configuration file has therefore been
created for you with some default values. To add additional metadata layers
into your configuration please add entries to conf/bblayers.conf.

The Yocto Project has extensive documentation about OE including a reference
manual which can be found at:
    http://yoctoproject.org/documentation

For more information about OpenEmbedded see their website:
    http://www.openembedded.org/


### 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'
brook@vista:~/projects/yp-krogoth/build$ vim conf/local.conf
...內容請看一段
brook@vista:~/projects/yp-krogoth/build$ bitbake core-image-minimal
WARNING: Host distribution "Ubuntu-16.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.
Parsing recipes...done.
Parsing of 871 .bb files complete (0 cached, 871 parsed). 1301 targets, 66 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.30.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-16.04"
TARGET_SYS        = "arm-poky-linux-gnueabi"
MACHINE           = "qemuarm"
DISTRO            = "poky"
DISTRO_VERSION    = "2.1.1"
TUNE_FEATURES     = "arm armv5 thumb dsp"
TARGET_FPU        = "soft"
meta
meta-poky
meta-yocto-bsp    = "krogoth:e93596fe74927e2e2f4dd7f671994ccb9744cff8"

NOTE: Fetching uninative binary shim from http://downloads.yoctoproject.org/releases/uninative/1.0.1/x86_64-nativesdk-libc.tar.bz2;sha256sum=acf1e44a0ac2e855e81da6426197d36358bf7b4e88e552ef933128498c8910f8
NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
...略
brook@vista:~/projects/yp-krogoth/build$ ./tmp/sysroots/x86_64-linux/usr/bin/qemu-system-arm -kernel ./tmp/deploy/images/qemuarm/zImage-qemuarm.bin -M versatilepb -drive file=/home/jpr/projects/yp-krogoth/build/tmp/deploy/images/qemuarm/core-image-minimal-qemuarm.ext4,if=virtio,format=raw -no-reboot -show-cursor -usb -usbdevice tablet -m 128 -nographic -append 'root=/dev/vda rw console=ttyAMA0,115200 console=tty ip=192.168.7.2::192.168.7.1:255.255.255.0 mem=128M highres=off rootfstype=ext4 ' 
audio: Could not init `oss' audio driver
ALSA lib ../../alsa-lib-1.1.0/src/confmisc.c:768:(parse_card) cannot find card '0'
...略
qemuarm login: root
root@qemuarm:~# uname -a
Linux qemuarm 4.4.11-yocto-standard #1 PREEMPT Sun Oct 9 11:36:44 CST 2016 armv5tejl GNU/Linux


conf/local.conf相關修改
change MACHINE for "qemux86" to "qemuarm"
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"
#MACHINE ?= "genericx86"
#MACHINE ?= "genericx86-64"
#MACHINE ?= "mpc8315e-rdb"
#MACHINE ?= "edgerouter"
#
# This sets the default machine to be qemux86 if no other machine is selected:
#MACHINE ??= "qemux86"
...
commout out these 2 lines
#PACKAGECONFIG_append_pn-qemu-native = " sdl"
#PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"



    參考資料:
  1. Yocto Project Quick Start
  2. Yocto Project Build System/Download




2016年10月1日 星期六

QC的partition table大小設定與實際大小對應關係


這裡記錄一下QC的9x40 partition table configure file(common/build/partition_nand.xml)size與實際的大小怎麼換算。 大概就兩類tag,一個tag是size_blks,以eraseblock為單位。另一個是tag是size_kb,所以實際大小還要轉成eraseblock。 如:
/ # cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00280000 00040000 "sbl"
mtd1: 00280000 00040000 "mibib"
mtd2: 00c00000 00040000 "efs2"
mtd3: 00140000 00040000 "tz"
mtd4: 00100000 00040000 "rpm"
mtd5: 00140000 00040000 "aboot"
...

partition table configure file內容
<partition>
    <name length="16" type="string">0:SBL</name>
    <size_blks length="4">0x8</size_blks>
    <pad_blks length="4">0x2</pad_blks>
    ...
</partition>
...
<partition>
    <name length="16" type="string">0:EFS2</name>
    <size_kb length="4">11264</size_kb>
    <pad_kb length="4">1024</pad_kb>
    ....
</partition>
SBL的設定為0x8+0x2個eraseblock,所以/proc/mtd大小為 (8 + 2) * 256 * 1024 = 0x280000。 EFS2的設定為11264+1024 KB,所以/proc/mtd大小為ceiling(11264 / 256)+ceiling(1024 / 256) = 48個eraseblock,所以/proc/mtd大小為48 * 256 * 1024 = 0xC0000。 eraseblock就是上面的erasesize,0x40000 / 1024 = 256kb。


2016年9月17日 星期六

build 32bit app on 64bit Machine -- /usr/bin/ld: skipping incompatible


我將Ubuntu從14.04換到16.04後,系統好像移除了一些package,導致build 32bit的程式會failed。 安裝lib32gcc-4.7-dev之後就解了。
brook@vista:~$ uname -a
Linux vista 4.4.0-36-generic #55-Ubuntu SMP Thu Aug 11 18:01:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
brook@vista:~$ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
brook@vista:~$ gcc -m32 x.c
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
brook@vista:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.4-3ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.4 (Ubuntu/Linaro 4.7.4-3ubuntu12)
brook@vista:~$ sudo apt-get install lib32gcc-4.7-dev





熱門文章