Pages

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


2013-12-30

xbionic - ntdll.dll (Windows Native APIs)


1. [ntdll.dll] Header and Code from the scratch

    For implementing the system-call of Linux, Windows Native APIs will be used.
    And the API-set will be re-written from the scrach.

    [WinDDK] has the useful package to start, but that is too complicate.

    So, the structures and functions are extracted one by one whenever it is used.


2. Current Codes

    The porting process is on the stable stage, so the file system is almost fixed.
    See the below files :

    - Main Headers
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/ntstatus.h
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/nttypes.h
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/ntdll.h
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/ntsock.h

    - Supporting Headers
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/poppack.h
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/pshpack1.h
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/pshpack2.h
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/pshpack4.h
       https://github.com/webos21/xbionic/blob/master/lib/mingw32/include/pshpack8.h

    - Implementing Source
       https://github.com/webos21/xbionic/blob/master/xbionic/libc/arch-win/_nt_imp/ntdll.c
       https://github.com/webos21/xbionic/blob/master/xbionic/libc/arch-win/_nt_imp/ntsock.c

xbionic - bionic libc for windows


1. What is [xbionic]


1-1. Bionic Libc

    Android has the own standard c library, Bionic Libc.
    It is just for the Linux OS, more precisely the Linux Kernel.

    The implementation is very dependent on the System Call of Linux.
    Because it stands for providing the light-weight standard c library, so it is natural.

    Android version 4.4 (codename KitKat) has began to support the 64-bit CPU.
    So, the Bionic Libc is evolving to support it.


1-2. Cygwin & MinGW for Developing on Windows

    Cygwin(or MinGW) is the best choice to develop on Windows OS.

    But, there is some missing features. For example, [the Group Source on Multicast],
    [Getting the list of Ethernet Interfaces], [Socket Options], [Signal] and so on.

    Inspite of these missing features, it is quite useful.


1-3. Bionic Libc for Windows
    For overcome the missing features of Cygwin(or MinGW) and getting more flexible
    standard c library, it is started the porting Bionic Libc on Windows 7.

    [xbionic] is that project.  And, it is also the begining of Android Platform for Windows.
    That means running the Android Apps directly on Windows without QEMU.


2. the Way to port the Bionic Libc on Windows

2-1. only use the [ntdll.dll]

    [ntdll.dll] has the Windows Native API.  It is not documented by Microsoft.
    But, [WinDDK] has small piece of reference code and documents,
    and the undocumented project of NTinternal - http://undocumented.ntinternals.net/ -
    has the good API documents.  Also, the ReactOS Project has the good usage.

    On the source tree of Bionic Libc, libc/arch-x86 is the base directory
    to fork the [arch-win].
    And the implementation of linux system-call is re-written by Windows Native APIs.


2-2. Building System

    Same as any other android libraries, bionic libc has android building system
    - [Android.mk].

    But, I need the independent building system, so the Make and ANT is used
    for compiling and linking the project.


2-3. VCS - GitHub

    The project is started on GitHub.  https://github.com/webos21/xbionic.git
    Anyone can participate and help.