Pages

2017-02-20

Yocto Project - useful 'bitbake' commands


bitbake commandDescription
bitbake <image>Bake an image (add -k to continue building even errors are found in the tasks execution)
bitbake <package> -c <task>Execute a particular package's task. Default Tasks names: fetch, unpack, patch, configure, compile, install, package, package_write, and build.

Example: To (force) compiling a kernel and then build, type:
$ bitbake  linux-imx -f -c compile
$ bitbake linux-imx
bitbake <image > -g -u depexpShow the package dependency for image.

Example: To show all packages included on fsl-image-gui
$ bitbake fsl-image-gui -g -u depexp

NOTE: This command will open a UI window, so it must be execute on a console inside the host machine (either virtual or native).
bitbake <package> -c  devshellOpen a new shell where with neccesary system values already defined for package
hobbitbake frontend/GUI.
bitbake <package> -c listtasksList all tasks for package
bitbake virtual/kernel -c menuconfigInteractive kernel configuration
bitbake <image> -c fetchallFetch sources for a particular image
bitbake-layers show-layersShow layers
bitbake-layers show-recipes "*-image-*"Show possible images to bake. Without "*-images-*", it shows ALL recipes
bitbake -g <image> && cat pn-depends.dot | grep -v -e '-native' | grep -v digraph | grep -v -e '-image' | awk '{print $1}' | sort | uniqShow image's packages
bitbake -g <pkg> && cat pn-depends.dot | grep -v -e '-native' | grep -v digraph | grep -v -e '-image' | awk '{print $1}' | sort | uniqShow package's dependencies
bitbake –v <image> 2>&1 | tee image_build.log Print (on console) and store verbose baking
bitbake -s | grep <pkg>Check if certain package is present on current Yocto Setup



Freescale - Yocto - openssl (perl error)


The meta-toolchain of NXP(Freescale) i.MX6ULL BSP Package for Yocto can not build the openssl library, because of failing on running 'Configure'.

So, the below script is needed.
(sysroot-path must be adjusted to your directory structure.)


#!/bin/bash

export SDKTARGETSYSROOT=/opt/toolchains/fsl-imx-fb-4.1.15-2.0.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi
export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT
export PKG_CONFIG_PATH=$SDKTARGETSYSROOT/usr/lib/pkgconfig
export CONFIG_SITE=/opt/toolchains/fsl-imx-fb-4.1.15-2.0.1/site-config-cortexa7hf-neon-poky-linux-gnueabi
export OECORE_NATIVE_SYSROOT="/opt/toolchains/fsl-imx-fb-4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux"
export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"
export OECORE_ACLOCAL_OPTS="-I /opt/toolchains/fsl-imx-fb-4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/share/aclocal"
unset command_not_found_handle
export CC="arm-poky-linux-gnueabi-gcc  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
export CXX="arm-poky-linux-gnueabi-g++  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
export CPP="arm-poky-linux-gnueabi-gcc -E  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
export AS="arm-poky-linux-gnueabi-as "
export LD="arm-poky-linux-gnueabi-ld  --sysroot=$SDKTARGETSYSROOT"
export GDB=arm-poky-linux-gnueabi-gdb
export STRIP=arm-poky-linux-gnueabi-strip
export RANLIB=arm-poky-linux-gnueabi-ranlib
export OBJCOPY=arm-poky-linux-gnueabi-objcopy
export OBJDUMP=arm-poky-linux-gnueabi-objdump
export AR=arm-poky-linux-gnueabi-ar
export NM=arm-poky-linux-gnueabi-nm
export M4=m4
#export TARGET_PREFIX=arm-poky-linux-gnueabi-
export CONFIGURE_FLAGS="--target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"
export CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-imx6ull14x14evk/1.0-r8=/usr/src/debug/meta-environment-imx6ull14x14evk/1.0-r8 -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/sysroots/x86_64-nativesdk-pokysdk-linux= "
export CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-imx6ull14x14evk/1.0-r8=/usr/src/debug/meta-environment-imx6ull14x14evk/1.0-r8 -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/sysroots/x86_64-nativesdk-pokysdk-linux= "
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"
export CPPFLAGS=""
export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"
export OECORE_DISTRO_VERSION="4.1.15-2.0.1"
export OECORE_SDK_VERSION="4.1.15-2.0.1"
export ARCH=arm
#export CROSS_COMPILE=arm-poky-linux-gnueabi-

./Configure linux-armv4 --prefix=/home/cmjo/build-pack-openssl zlib-dynamic shared

According to the manual, 'environment-setup-cortexa7hf-neon-poky-linux-gnueabi' must be loaded with 'source' or '.'.

But, after loading that script, the [perl] is not running properly for lack of dependent modules.

Above script must be executed directly on host shell.
(DO NOT load the Build-ENV script)

Then, you can compile the openssl successfully.




2017-02-08

Freescale i.MX6ULL 14x14 EVK - Yocto Build


1) Host Package

   * for Yocto Project
     $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat libsdl1.2-dev

   * for iMX
    $ sudo apt-get install libsdl1.2-dev xterm 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

   * for Ubuntu 12.04
    $ sudo apt-get install uboot-mkimage

   * for Ubuntu 14.04
    $ sudo apt-get install u-boot-tools


2) repo

   $ mkdir ~/bin
   $ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
   $ chmod 755 ~/bin/repo


3) Get source code

   $ mkdir fsl-release-bsp
   $ cd fsl-release-bsp
   $ repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth
   $ repo sync


4) Build Configuration

   $ DISTRO=fsl-imx-fb MACHINE=imx6ull14x14evk source fsl-setup-release.sh -b imx6ull14x14evk-fb


5) Build

   $ bitbake fsl-image-gui


5) QEMU test

   $ runqemu qemux86-64 ./tmp/deploy/images/imx6qsabresd/zImage-imx6qsabresd.bin ./tmp/deploy/images/imx6qsabresd/core-image-minimal-imx6qsabresd.ext4


6) Build Toolchain

   # Using the Build-Directory
     $ bitbake meta-ide-support

   # Create the Toolchain Installer and Install
     $ bitbake meta-toolchain
     $ sh tmp/deploy/sdk/poky-eglibc-x86_64-arm-toolchain-1.4.1.sh
     $ source /opt/poky/1.4.1/environment-setup-armv7a-vfp-neon-poky-linux-gnueabi
     $ arm-poky-linux-gnueabi-gcc -v

  # More Advanced Toolchain!!!
     $ bitbake fsl-image-gui -c populate_sdk


7) Kernel Config and Rebuild

   # check the python script
   $ bitbake -e virtual/kernel

   $ bitbake linux-imx -c menuconfig
   $ bitbake linux-imx -c diffconfig

   # re-compile kernel, forcely!!
   $ bitbake linux-imx -c compile -f

   # clean kernel only
   $ bitbake linx-imx -c clean

   # rebuild image
   $ bitbake fsl-image-gui


8) Post Build
   # It is not required if you build the [populate_sdk]!!!
    [add libraries] zlib, openssl


2017-01-19

Raspberry Pi - sdb2 super block corruption


* Superblock : bad magic number (dump file link)

$ sudo dd if=/dev/sdb2 bs=1024 count=2 | hexdump -C
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000380  b0 c9 0e 00 80 19 3b 00  98 6d 02 00 17 26 22 00  |......;..m...&".|
00000390  fc 5d 0b 00 00 00 00 00  02 00 00 00 02 00 00 00  |.]..............|
000003a0  00 80 00 00 00 80 00 00  d0 1f 00 00 3e d2 2f 58  |............>./X|
000003b0  03 00 00 00 03 00 ff ff  53 ef 03 00 01 00 00 00  |........S.......|
000003c0  2d c4 2f 58 b0 c9 0e 00  80 19 3b 00 98 6d 02 00  |-./X......;..m..|
000003d0  53 25 22 00 fc 5d 0b 00  00 00 00 00 02 00 00 00  |S%"..]..........|
000003e0  02 00 00 00 00 80 00 00  00 80 00 00 d0 1f 00 00  |................|
000003f0  bf d2 2f 58 03 00 00 00  05 00 ff ff 53 ef 03 00  |../X........S...|
00000400  01 00 00 00 3d d2 2f 58  00 00 00 00 00 00 00 00  |....=./X........|
00000410  01 00 00 00 00 00 00 00  0b 00 00 00 00 01 00 00  |................|
00000420  3c 00 00 00 42 02 00 00  73 00 00 00 ad 62 03 a1  |<...B...s....b..|
00000430  ec 50 4f 44 a1 c0 e6 c3  dd 4c 92 02 00 00 00 00  |.POD.....L......|
00000440  00 00 00 00 00 00 00 00  00 00 00 00 2f 00 65 64  |............/.ed|
00000450  69 61 2f 63 6d 6a 6f 2f  61 64 36 32 30 33 61 31  |ia/cmjo/ad6203a1|
00000460  2d 65 63 35 30 2d 34 66  34 34 2d 61 31 63 30 2d  |-ec50-4f44-a1c0-|
00000470  65 36 63 33 64 64 34 63  39 32 30 32 00 00 00 00  |e6c3dd4c9202....|
00000480  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000490  00 00 e6 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000004a0  00 00 00 00 08 00 00 00  00 00 00 00 00 00 00 00  |................|
000004b0  58 e2 0c f7 9d 8c 4c 05  8d eb a6 52 51 90 7e 3c  |X.....L....RQ.~<|
000004c0  01 01 00 00 0c 00 00 00  00 00 00 00 6e c8 50 56  |............n.PV|
000004d0  0a f3 01 00 04 00 00 00  00 00 00 00 00 00 00 00  |................|
000004e0  00 40 00 00 00 80 06 00  00 00 00 00 00 00 00 00  |.@..............|
000004f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000510  00 00 00 04 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000520  1c 00 1c 00 02 00 00 00  f1 7f 00 00 00 00 00 00  |................|
00000530  00 00 00 00 00 00 00 00  04 00 00 00 ba 7b cc 02  |.............{..|
00000540  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000550  00 00 00 00 00 00 00 00  01 00 00 00 11 00 00 00  |................|
00000560  6b 54 00 00 00 00 00 00  00 00 00 00 65 78 74 34  |kT..........ext4|
00000570  5f 69 67 65 74 00 00 00  00 00 00 00 00 00 00 00  |_iget...........|
00000580  00 00 00 00 00 00 00 00  00 00 00 00 a6 10 00 00  |................|
00000590  11 00 00 00 6b 54 00 00  a6 10 00 00 00 00 00 00  |....kT..........|
000005a0  00 00 00 00 65 78 74 34  5f 69 67 65 74 00 00 00  |....ext4_iget...|
000005b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|




* Superblock : after fsck (dump file link)

$ sudo fsck /dev/sdb2
fsck from util-linux 2.27.1
e2fsck 1.42.13 (17-May-2015)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
/dev/sdb2: recovering journal
fsck.ext2: unable to set superblock flags on /dev/sdb2


/dev/sdb2: ***** FILE SYSTEM WAS MODIFIED *****

/dev/sdb2: ********** WARNING: Filesystem still has errors **********
 

$ sudo fsck /dev/sdb2
fsck from util-linux 2.27.1
e2fsck 1.42.13 (17-May-2015)
Setting free inodes count to 744873 (was 744872)
/dev/sdb2: clean, 224263/969136 files, 1620552/3873152 blocks


$ sudo dd if=/dev/sdb2 bs=1024 count=2 | hexdump -C
2+0 records in
2+0 records out
2048 bytes (2.0 kB, 2.0 KiB) copied, 0.00621587 s, 329 kB/s
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000380  b0 c9 0e 00 80 19 3b 00  98 6d 02 00 17 26 22 00  |......;..m...&".|
00000390  fc 5d 0b 00 00 00 00 00  02 00 00 00 02 00 00 00  |.]..............|
000003a0  00 80 00 00 00 80 00 00  d0 1f 00 00 3e d2 2f 58  |............>./X|
000003b0  03 00 00 00 03 00 ff ff  53 ef 03 00 01 00 00 00  |........S.......|
000003c0  2d c4 2f 58 b0 c9 0e 00  80 19 3b 00 98 6d 02 00  |-./X......;..m..|
000003d0  53 25 22 00 fc 5d 0b 00  00 00 00 00 02 00 00 00  |S%"..]..........|
000003e0  02 00 00 00 00 80 00 00  00 80 00 00 d0 1f 00 00  |................|
000003f0  bf d2 2f 58 03 00 00 00  05 00 ff ff 53 ef 03 00  |../X........S...|
00000400  b0 c9 0e 00 80 19 3b 00  98 6d 02 00 38 5f 22 00  |......;..m..8_".|
00000410  a9 5d 0b 00 00 00 00 00  02 00 00 00 02 00 00 00  |.]..............|
00000420  00 80 00 00 00 80 00 00  d0 1f 00 00 1e 6c 20 57  |.............l W|
00000430  bc 48 80 58 03 00 ff ff  53 ef 01 00 01 00 00 00  |.H.X....S.......|
00000440  67 75 20 57 00 00 00 00  00 00 00 00 01 00 00 00  |gu W............|
00000450  00 00 00 00 0b 00 00 00  00 01 00 00 3c 00 00 00  |............<...|
00000460  42 02 00 00 73 00 00 00  ad 62 03 a1 ec 50 4f 44  |B...s....b...POD|
00000470  a1 c0 e6 c3 dd 4c 92 02  00 00 00 00 00 00 00 00  |.....L..........|
00000480  00 00 00 00 00 00 00 00  2f 00 6e 74 2f 73 64 63  |......../.nt/sdc|
00000490  61 72 64 00 64 65 76 2f  70 69 2d 67 65 6e 2f 65  |ard.dev/pi-gen/e|
000004a0  78 70 6f 72 74 2d 6a 65  73 73 69 65 2f 72 6f 6f  |xport-jessie/roo|
000004b0  74 66 73 00 00 00 00 00  00 00 00 00 00 00 00 00  |tfs.............|
000004c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 e6 00  |................|
000004d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000004e0  08 00 00 00 00 00 00 00  00 00 00 00 58 e2 0c f7  |............X...|
000004f0  9d 8c 4c 05 8d eb a6 52  51 90 7e 3c 01 01 00 00  |..L....RQ.~<....|
00000500  0c 00 00 00 00 00 00 00  6e c8 50 56 0a f3 01 00  |........n.PV....|
00000510  04 00 00 00 00 00 00 00  00 00 00 00 00 40 00 00  |.............@..|
00000520  00 80 06 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000530  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000540  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 04  |................|
00000550  00 00 00 00 00 00 00 00  00 00 00 00 1c 00 1c 00  |................|
00000560  02 00 00 00 f1 7f 00 00  00 00 00 00 00 00 00 00  |................|
00000570  00 00 00 00 04 00 00 00  06 57 cc 02 00 00 00 00  |.........W......|
00000580  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000800



* Superblock : after RPi more fixed (only dump file link)


* Analysis
 - According to the Ext4 disk layout,
   first 1024 byte (if the disk size is 16GB) must be 0 padded.
 - But, the real data was not. (0x400 = 1024)
 - And the magic signature, 0x0438 and 0x0439 is not 0xEF53 before fixing.


* Question
 - Why the first 1024 byte is not 0 padded?
 - What causes this corruption?


2017-01-18

Raspberry Pi MBR - Partition Expansion



* SD Card is SanDisk 16GB


* Before Expansion (linux partition is about 9GB)

  $ hexdump -C t20r18-mbr-20161031.img
00000000  fa b8 00 10 8e d0 bc 00  b0 b8 00 00 8e d8 8e c0  |................|
00000010  fb be 00 7c bf 00 06 b9  00 02 f3 a4 ea 21 06 00  |...|.........!..|
00000020  00 be be 07 38 04 75 0b  83 c6 10 81 fe fe 07 75  |....8.u........u|
00000030  f3 eb 16 b4 02 b0 01 bb  00 7c b2 80 8a 74 01 8b  |.........|...t..|
00000040  4c 02 cd 13 ea 00 7c 00  00 eb fe 00 00 00 00 00  |L.....|.........|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001b0  00 00 00 00 00 00 00 00  1f da 06 00 00 00 00 82  |................|
000001c0  03 00 0c 28 20 08 00 20  00 00 00 e0 01 00 00 00  |...( .. ........|
000001d0  01 00 83 fe ff ff 00 00  02 00 00 00 fa
00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400




* After Expansion (linux partition is about 15GB)

  $ hexdump -C sd_fixed.img
00000000  fa b8 00 10 8e d0 bc 00  b0 b8 00 00 8e d8 8e c0  |................|
00000010  fb be 00 7c bf 00 06 b9  00 02 f3 a4 ea 21 06 00  |...|.........!..|
00000020  00 be be 07 38 04 75 0b  83 c6 10 81 fe fe 07 75  |....8.u........u|
00000030  f3 eb 16 b4 02 b0 01 bb  00 7c b2 80 8a 74 01 8b  |.........|...t..|
00000040  4c 02 cd 13 ea 00 7c 00  00 eb fe 00 00 00 00 00  |L.....|.........|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001b0  00 00 00 00 00 00 00 00  1f da 06 00 00 00 00 82  |................|
000001c0  03 00 0c 28 20 08 00 20  00 00 00 e0 01 00 00 00  |...( .. ........|
000001d0  01 00 83 03 d0 2f 00 00  02 00 00 cc d8 01
00 00  |...../..........|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400



* Analysis
  - 0x01ce | Status         | Value 0x00   => Valid (0x00 or 0x80)
  - 0x01cf | Head           | Value 0x00
  - 0x01d0 | Sector         | Value 0x01
  - 0x01d1 | Cylinder       | Value 0x00
  - 0x01d2 | Partition Type | Value 0x83   => Linux
    =================== below values are different =====================
  - 0x01d3 | Head           | Value 0x03
  - 0x01d4 | Sector         | Value 0xd0
  - 0x01d5 | Cylinder       | Value 0x2f
  - 0x01d6 ~ 0x01d9 : LBA of first absolute sector in the partition
  - 0x01da ~ 0x01dd : Number of sectors in partition