Difference between revisions of "Yocto tests"

From ElphelWiki
Jump to: navigation, search
m
 
(97 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==About==
+
==<font color="blue">About</font>==
* in Kubuntu 13.04
+
 
 +
<font size='4'><b>NOTE: a newer version of the article is available [[Poky_2.0_manual|here (poky 2.0)]]</b></font>
 +
 
 +
* Poky revision - DORA (1.5)
 +
* All of the described things happen in Kubuntu 13.04
 
* Building Linux images for Zynq platform - ARMv7
 
* Building Linux images for Zynq platform - ARMv7
  
==GIT==
+
==<font color="blue">Required packages</font>==
 
<font size='2'>
 
<font size='2'>
git clone -b dylan git://git.yoctoproject.org/poky.git
+
[http://www.yoctoproject.org/docs/1.5/ref-manual/ref-manual.html#required-packages-for-the-host-development-system src link]:
git clone -b dylan https://github.com/Xilinx/meta-xilinx.git meta-xilinx
+
* Essentials. Packages needed to build an image on a headless system:
  git clone git://git.code.sf.net/p/elphel/meta-elphel393 meta-elphel393
+
  sudo apt-get install gawk wget git-core diffstat unzip texinfo build-essential chrpath
 +
* Graphical Extras. Packages recommended if the host system has graphics support:
 +
sudo apt-get install libsdl1.2-dev xterm
 +
* Documentation. Packages needed if you are going to build out the Yocto Project documentation manuals:
 +
sudo apt-get install make xsltproc docbook-utils fop dblatex xmlto
 +
* ADT Installer Extras. Packages needed if you are going to be using the Application Development Toolkit (ADT) Installer:
 +
sudo apt-get install autoconf automake libtool libglib2.0-dev
 
</font>
 
</font>
  
==Configure==
+
==<font color="blue">Output targets</font>==
* Step 1: Init environment
+
Output folder: '''poky/build/tmp/deploy/images'''
 +
 
 +
These names are as they appear in the u-boot configuration header file - actual output files have different names:
 +
* '''boot.bin'''+('''u-boot.img''') - u-boot as the first stage bootloader = Secondary Program Loader tha boots '''u-boot.img'''
 +
* '''devicetree.dtb''' - device tree with described interfaces, zynq registers, interrupts and drivers
 +
* '''uImage''' - kernel, drivers
 +
* '''uramdisk.image.gz''' - applications
 +
Copy them on the micro SD card > run '''boot''' once in the u-boot command line.
 +
 
 +
 
 +
==<font color="blue">Boot options</font>==
 +
a. Unpack the root file system image to RAM at boot time.
 +
 
 +
Check u-boot config file.
 +
 
 +
Keep '''uramdisk.image.gz''' along with other files on FAT partition.
 +
 
 +
b. Keep the root file system on EXT2(EXT3,etc.) partition of SD card.
 +
 
 +
Create '''uEnv.txt''' on FAT partition. ''uEnv.txt'':
 +
uenv_boot=fatload mmc 0 0x3F00000 ${kernel_image} && fatload mmc 0 0x3E00000 ${devicetree_image} && bootm 0x3F00000 - 0x3E00000
 +
uenvcmd=run uenv_boot
 +
 
 +
Devicetree needs to be recompiled with changes in ''bootargs''-line:
 +
 
 +
for ext2:
 +
root=/dev/mmcblk0p2
 +
for ram:
 +
root=/dev/ram
 +
 
 +
==<font color="blue">Setup</font>==
 +
* Step 1: Copy into '''some_script.sh''', modify and run:
 
<font size='2'>
 
<font size='2'>
 +
'''#Part 1'''
 +
 +
git clone -b dora git://git.yoctoproject.org/poky.git poky
 +
cd poky; git checkout 50e9ccb2aff7b9f9dca4fda99a6832c60f64de3b
 +
 +
git clone -b dora https://github.com/openembedded/meta-oe.git meta-oe
 +
#'''has changed to git clone -b fido https://github.com/openembedded/meta-openembedded?!!!!!!!!''')
 +
cd meta-oe; git checkout ee173678383683e972c7d4d6f0ef5790bfa50274; cd ..
 +
 +
git clone -b dora https://github.com/Xilinx/meta-xilinx.git meta-xilinx
 +
cd meta-xilinx; git checkout aa7d677515ab7d45bbd3bdd6c5383f4143147c6d; cd ..
 +
 +
git clone -b master https://github.com/Elphel/meta-ezynq.git meta-ezynq
 +
cd meta-ezynq; git checkout 626e02fc0b9070458baae3e9a0153a2820ec6565; cd ..
 +
 +
git clone -b master https://github.com/Elphel/meta-elphel393.git meta-elphel393
 +
cd meta-elphel393; git checkout fcde04fa6f4f00c7fe593e5f96bf7b40dc50d2b3; cd ..
 +
 +
'''#Part 2 : init environment and auto-fill Yocto's conf-files'''
 +
 +
CURRENT_PATH=$(dirname $(readlink -f "$0"))
 +
. ./oe-init-build-env
 +
 +
BBLAYERS_CONF="conf/bblayers.conf"
 +
 +
echo "BBLAYERS = \" \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta-yocto \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta-yocto-bsp \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta-elphel393 \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta-ezynq \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta-oe/meta-oe \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta-oe/meta-webserver \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta-oe/meta-networking \\" >> $BBLAYERS_CONF
 +
echo "  $CURRENT_PATH/meta-xilinx \\" >> $BBLAYERS_CONF
 +
echo "  \"" >> $BBLAYERS_CONF
 +
 +
LOCAL_CONF="conf/local.conf"
 +
 +
# number of parallel tasks (including compiles)
 +
echo "BB_NUMBER_THREADS ?= \"'''8'''\"" >> $LOCAL_CONF
 +
# number of parallel compiles
 +
echo "PARALLEL_MAKE ?= \"-j '''8'''\"" >> $LOCAL_CONF
 +
# <font color='red'>change the MACHINE</font>
 +
echo "MACHINE ?= \"'''elphel393'''\"" >> $LOCAL_CONF
 +
# <font color='red'>Elphel's MIRROR website, '''\n''' is important</font>
 +
echo "MIRRORS =+ \"http://.*/.*    http://mirror.elphel.com/elphel393_mirror/ \n \"" >> $LOCAL_CONF
 +
 +
* Step 2: re-init environment
 
  cd poky
 
  cd poky
 
  . ./oe-init-build-env
 
  . ./oe-init-build-env
 +
 +
* Step 3: build bootable image (3 targets)
 +
bitbake u-boot-ezynq linux-xlnx core-image-elphel393
 
</font>
 
</font>
* Step 2: Edit ''build/conf/bblayers.conf'' - add paths to BBLAYERS:
+
====Notes====
 +
* Currently having 4 MACHINES: elphel393, microzed, zc706 and zedboard
 +
 
 +
==<font color="blue">Build bootloader</font>==
 
<font size='2'>
 
<font size='2'>
  <absolute-path>/meta-xilinx \
+
  bitbake u-boot-ezynq
  <absolute-path>/meta-xilinx/meta-zedboard \
+
or
  <absolute-path>/meta-elphel393 \
+
  bitbake u-boot
 +
or
 +
  bitbake virtual/bootloader
 
</font>
 
</font>
* Step 3: Edit ''build/conf/local.conf'' - set MACHINE and other things:
+
====Output====
<font size='2'>
+
* poky/build/tmp/deploy/images/'''boot.bin'''
  BB_NUMBER_THREADS = "8" (depends on the PC's CPU)
+
* poky/build/tmp/deploy/images/'''u-boot.img'''
  PARALLEL_MAKE = "-j 8" (depends on the PC's CPU)
+
 
  MACHINE ?= "zedboard"
+
====Notes====
</font>
 
===Notes===
 
 
<font color="red">
 
<font color="red">
*MACHINE="zedboard" is used to build the kernel. Doesn't matter for ramdisk.image.gz because the recipes don't have any bbappends for core-images.
+
* Is there a way to build it by running ''bitbake core-image-elphel393''
 
</font>
 
</font>
  
==Build kernel==
+
==<font color="blue">Build kernel</font>==
 
<font size='2'>
 
<font size='2'>
 
  bitbake linux-xlnx
 
  bitbake linux-xlnx
 +
or
 +
bitbake virtual/kernel
 
</font>
 
</font>
 +
====Output====
 +
* poky/build/tmp/deploy/images/'''uImage''' (kernel)
 +
* poky/build/tmp/deploy/images/'''devicetree.dtb''' (or some *.dtb)
  
==Build ramdisk.image.gz==
+
====Notes====
 +
* Sources are cloned to:
 
<font size='2'>
 
<font size='2'>
  bitbake elphel393
+
'''poky/build/tmp/work/MACHINE-poky-linux-gnueabi/linux-xlnx/.../linux'''
 +
</font>
 +
* If you change files like debug drivers for example, when done editing run:
 +
<font size='2'>
 +
  bitbake linux-xlnx -c compile
 +
bitbake linux-xlnx -c deploy
 
</font>
 
</font>
===Notes===
+
<font color="red">
 +
* When linux-xlnx is 'clean' it is built with the ramdisk.image.gz by ''bitbake core-image-elphel393'', however the boot.bin does not, why?
 +
</font>
 +
 
 +
 
 +
 
 +
==<font color="blue">Build ramdisk.image.gz</font>==
 +
<font size='2'>
 +
bitbake core-image-elphel393
 +
</font>
 +
====Output====
 +
* poky/build/tmp/deploy/images/'''uramdisk.image.gz''' (the file has *.u-boot extension after it's built)
 +
 
 +
====Notes====
 
<font size='2'>
 
<font size='2'>
<font color="red">
+
* Select root file system format in the recipe:
 +
IMAGE_FSTYPES = "tar.gz"
 
* Current packages:
 
* Current packages:
  ''elphel393.bb'':
+
  ''core-image-elphel393.bb'':
 
  IMAGE_INSTALL = "packagegroup-core-boot python-core ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}"
 
  IMAGE_INSTALL = "packagegroup-core-boot python-core ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}"
 
* Also works:
 
* Also works:
  ''elphel393.bb'':
+
  ''core-image-elphel393.bb'':
 
  IMAGE_INSTALL = "packagegroup-core-boot ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}"
 
  IMAGE_INSTALL = "packagegroup-core-boot ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}"
 
  IMAGE_INSTALL_append = "python-core"
 
  IMAGE_INSTALL_append = "python-core"
* Why ''python-core'' and not just ''python''?
+
<font color="black">
** ''poky/meta/recipes-devtools/python/python-2.7-manifest.inc'' has a list in PACKAGES items from which should go into IMAGE_INSTALL
+
* Why ''python-core'' and not ''python''?
 +
** ''poky/meta/recipes-devtools/python/python-2.7-manifest.inc'' has a list in PACKAGES, items from which should go into IMAGE_INSTALL
 
** Among all there's no ''python'' in the PACKAGES list.
 
** Among all there's no ''python'' in the PACKAGES list.
 
** Does '''hob''' install all the PACKAGES if ''python'' is checked? Haven't tried, also the used '''hob''' version doesn't support saving recipes.
 
** Does '''hob''' install all the PACKAGES if ''python'' is checked? Haven't tried, also the used '''hob''' version doesn't support saving recipes.
* '''(Is there a better solution?)''' Adding packages : '''apache2''', '''php''' and '''i2c-tools''', steps:
+
<font color='black'>
**Clone '''meta-oe''' from OpenEmbedded:
+
* Steps for adding packages:
git clone -b dylan https://github.com/openembedded/meta-oe.git
 
**Lines to ''bblayers.conf'':
 
    <absolute-path>/meta-oe/meta-oe \
 
    <absolute-path>/poky/meta-oe/meta-perl \
 
    <absolute-path>/poky/meta-oe/meta-webserver \
 
 
** ''elphel393.bb'' '''(some discussions mention the leading space is mandatory but somehow it works even without it)''':
 
** ''elphel393.bb'' '''(some discussions mention the leading space is mandatory but somehow it works even without it)''':
 
  IMAGE_INSTALL_append = "'''<mandatory space?>'''python-core \
 
  IMAGE_INSTALL_append = "'''<mandatory space?>'''python-core \
 
                         i2c-tools \
 
                         i2c-tools \
 +
                        mtd-utils \
 +
                        net-tools \
 +
                        openssh \
 
                         modphp \
 
                         modphp \
 
                         apache2 \
 
                         apache2 \
Line 72: Line 192:
 
  meta-oe/meta-oe/recipes-devtools/php/php.inc:
 
  meta-oe/meta-oe/recipes-devtools/php/php.inc:
 
  PACKAGES = "${PN}-dbg ${PN}-cli ${PN}-cgi ${PN}-fpm ${PN}-fpm-apache2 ${PN}-pear ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}"
 
  PACKAGES = "${PN}-dbg ${PN}-cli ${PN}-cgi ${PN}-fpm ${PN}-fpm-apache2 ${PN}-pear ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}"
*** PACKAGES includes ''php''. What is installed? (No ''php-cli'': missing /usr/bin/php) Didn't investigate.
+
*** PACKAGES list includes ''php''. What is installed? (No ''php-cli'': missing /usr/bin/php) Didn't investigate.
 +
</font>
 
*** What does hob build if ''php'' is checked? Didn't test.
 
*** What does hob build if ''php'' is checked? Didn't test.
*** Using ''php-cli'' installs php in the /usr/bin/. Tested.
+
*** <font color='black'>Using ''php-cli'' increases the unpacked image size from ~16MB to ~50MB.</font>
*** Using ''php-cli'' increases the unpacked image size from ~16MB to ~50MB.
+
</font>
**To fix the '''ERROR'''="'''Could not inherit file classes/vala.bbclass'''" in bitbake copy vala.bbclass from oe-core? or delete the conflicting recipes (2?)?
+
</font>
**To fix the '''ERROR'''="'''Failed to parse krb5_1.11.3.bb'''" in bitbake delete the directory ''meta-oe/meta-oe/recipes-connectivity/krb5''
+
 
 +
====U-boot and device tree related notes====
 
* '''The default UNPACKED ramdisk max size for zynq is 16MB - once it gets bigger you get KERNEL PANIC - the solution is [http://forums.xilinx.com/t5/Embedded-Linux/Need-bigger-ramdisk-32MB-on-ZC702/m-p/303457#M5775 modifying the device tree] - then recompile into DTB:'''
 
* '''The default UNPACKED ramdisk max size for zynq is 16MB - once it gets bigger you get KERNEL PANIC - the solution is [http://forums.xilinx.com/t5/Embedded-Linux/Need-bigger-ramdisk-32MB-on-ZC702/m-p/303457#M5775 modifying the device tree] - then recompile into DTB:'''
  *.dts, add to '''bootargs''' parameter ''ramdisk_size=32768'' (in KB), example:
+
  *.dts, add to '''bootargs''' parameter ''ramdisk_size=32768'' (takes KB), example:
  bootargs = "console=ttyPS0,115200 root=/dev/ram rw ip=192.168.1.10 earlyprintk '''ramdisk_size=32768'''";
+
  bootargs = "console=ttyPS0,115200 root=/dev/ram rw ip=192.168.1.10 earlyprintk '''ramdisk_size=65536'''";
 
* '''The default COMPRESSED ramdisk max size for zynq is 10MB set in u-boot''' - change according to your needs, example:
 
* '''The default COMPRESSED ramdisk max size for zynq is 10MB set in u-boot''' - change according to your needs, example:
 
  ''zynq_zed.h'':
 
  ''zynq_zed.h'':
Line 94: Line 216:
 
  devicetree = 0x3000000 - 0x2A00000 = 0x600000 = 6MB
 
  devicetree = 0x3000000 - 0x2A00000 = 0x600000 = 6MB
  
</font>
+
 
 +
 
 +
==<font color="blue">Build everything all together</font>==
 +
<font size='2'>
 +
bitbake u-boot-ezynq linux-xlnx core-image-elphel393
 
</font>
 
</font>
  
==Build toolchain==
+
==<font color="blue">Build toolchain (not necessary - needed only for building ezynq targets outside poky)</font>==
 
* Step 1: build
 
* Step 1: build
 
<font size='2'>
 
<font size='2'>
Line 104: Line 230:
  
 
* Step 2: install - launch installer from <some-path>/poky/build/tmp/deploy/
 
* Step 2: install - launch installer from <some-path>/poky/build/tmp/deploy/
 +
 +
 +
 +
==<font color="blue">Apply a patch from a recipe</font>==
 +
* Example file tree ([https://sourceforge.net/p/elphel/meta-elphel393 meta-elphel393]):
 +
<font size="2">
 +
meta-elphel393/
 +
    recipes-kernel/
 +
        linux/
 +
            ''linux-xlnx_3.8.bb''
 +
            ''linux-xlnx.inc''
 +
            linux-xlnx/
 +
                ''elphel393_defconfig_3.8.cfg''
 +
                ''elphel393.dts''
 +
                ''xilinx_nandps.patch''
 +
</font>
 +
* Goal: apply a patch to linux-xlnx files
 +
* Step 1:
 +
<font size="2">
 +
bitbake linux-xlnx
 +
</font>
 +
* Step 2: Go to where the linux-xlnx got cloned - find and edit the target file:
 +
<font size="2">
 +
poky/build/tmp/work/elphel393-poky-linux-gnueabi/linux-xlnx/.../linux/
 +
</font>
 +
* Step 3: In the mentioned above directory run:
 +
<font size="2">
 +
git diff > somefile.patch
 +
</font>
 +
* Step 4: Copy the patch file into ''recipes/kernel/linux/linux-xlnx/''.
 +
* Step 5: Edit the recipe, here it's linux-xlnx.inc, add a line like the following:
 +
<font size="2">
 +
Apply the patch when building for any MACHINE:
 +
SRC_URI_append += "file://xilinx_nandps.patch"
 +
or only a certain MACHINE="elphel393"
 +
SRC_URI_append_elphel393 += "file://xilinx_nandps.patch"
 +
</font>
 +
* Step 6(?):
 +
<font size="2">
 +
bitbake linux-xlnx -c clean -f
 +
bitbake linux-xlnx
 +
</font>
 +
 +
==<font color='blue'>Create *.bbappend for an existing package in meta-*</font>==
 +
* Define FILESEXTRAPATHS_prepend := "${THISDIR}/files:" for files that come with the bbappend - so the fetcher could find them
 +
* Try to add "_append" & "_prepend" to functions
 +
* If some do_function is incompatible just rewrite it
 +
 +
 +
==<font color='blue'>Switch to dora branch</font>==
 +
cd poky; git checkout dora
 +
cd meta-oe; git checkout dora
 +
cd meta-elphel393; git checkout master
 +
 +
==<font color='blue'>Branching in git</font>==
 +
<font size='2'>
 +
* switch to a branch:
 +
git checkout <name>
 +
* create a new local branch
 +
git checkout -b <new-branch> <existing-branch>
 +
* delete a local branch
 +
git branch -D <name>
 +
* create a new remote branch (from existing local)
 +
git push origin <name>
 +
* delete a remote branch
 +
git push origin :<name>
 +
</font>
 +
 +
==<font color='blue'>Disappeared errors</font>==
 +
**'''(Is there a better solution for kubuntu 13.04? in kubuntu 12.10 there is no such error - or is it just newer version?)''' To fix the '''ERROR'''="'''Could not inherit file classes/vala.bbclass'''" in bitbake copy vala.bbclass from oe-core? or delete the conflicting recipes (2?)?
 +
**'''(Is there a better solution for kubuntu 13.04? in kubuntu 12.10 there is no such error - or is it just newer version?)''' To fix the '''ERROR'''="'''Failed to parse krb5_1.11.3.bb'''" in bitbake delete the directory ''meta-oe/meta-oe/recipes-connectivity/krb5''
 +
 +
==<font color='blue'>RTC config example in DTS</font>==
 +
http://www.denx.de/wiki/DULG/Appendix
 +
 +
==<font color='blue'>Program bitstream from Linux</font>==
 +
<font size='2'>
 +
* PL status (1=programmed, 0=not):
 +
cat /sys/devices/amba.0/f8007000.ps7-dev-cfg/prog_done
 +
* Program (the driver understands both *.bit and *.bit.bin)
 +
cat test.bit > /dev/xdevcfg
 +
</font>
 +
 +
==<font color='blue'>Create and set up an own external mirror in Yocto/OpenEmbedded</font>==
 +
<font size='2'>
 +
* To the ''build/conf/local.conf'' add:
 +
SOURCE_MIRROR_URL = "file:///data/sources/"
 +
INHERIT += "own-mirrors"
 +
BB_GENERATE_MIRROR_TARBALLS = "1"
 +
* Rebuild the target
 +
<font color='red'>It didn't store anything in ''/data/sources/'', but in the ''build/downloads/'' instead - tar.gz + tar.gz's made from cloned git repositories.</font>
 +
* Upload the archives to your mirror website
 +
* To the ''build/conf/local.conf'' add:
 +
MIRRORS =+ "http://.*/.*    http://mirror.elphel.com/elphel393_mirror/ \n "
 +
* If no need - comment out the files in the ''build/conf/local.conf'':
 +
#SOURCE_MIRROR_URL = "file:///data/sources/"
 +
#INHERIT += "own-mirrors"
 +
#BB_GENERATE_MIRROR_TARBALLS = "1"
 +
</font>
 +
==<font color="blue">For future consideration</font>==
 +
===from [meta-xilinx] Best kernel recipe to work against===
 +
On Wed, Jan 7, 2015 at 5:42 AM, Philip Balister <philip@balister.org> wrote:
 +
> What's the officially supported best kernel to work against in meta-xilinx?
 +
>
 +
> linux-xlnx-3.14
 +
> linux-yocto-3.17
 +
 +
So it does depend on your preference and requirements. There are still
 +
some drivers missing from the mainline kernel, if you need those
 +
drivers/peripherals then you will most likely need to use the
 +
linux-xlnx kernel.
 +
 +
Shortlist of the main peripherals/drivers that are not yet in the
 +
mainline/linux-yocto kernel:
 +
  * USB (however there is now support upstream in 3.19)
 +
  * PL devcfg
 +
  * QSPI flash controller
 +
  * NAND flash controller
 +
(full list here: http://www.wiki.xilinx.com/Linux+Drivers)
 +
 +
Keep in mind though that the linux-xlnx kernels are short lived, so
 +
you will need to continue updating to newer versions if you want
 +
fixes, etc. And the recipes for the linux-xlnx kernels do not reflect
 +
the actual releases of the linux-xlnx kernel particularly well (since
 +
linux-xlnx releases against Vivado versions instead of linux kernel
 +
versions).
 +
 +
For reference, with microblaze mainline/linux-yocto is the best
 +
supported kernel.
 +
 +
Regards,
 +
Nathan
 +
 +
==<font color="blue">Some links</font>==
 +
* http://picozed.org/content/microzed-how-boot-sd-card
 +
* http://zedboard.org/content/cannot-use-sd-card-partition-root-filesystem
 +
* http://architechboards-microzed.readthedocs.org/en/latest/quick.html
 +
* http://architechboards-microzed.readthedocs.org/en/latest/board.html
 +
 +
1. u-boot environment variables:
 +
print all:
 +
~: printenv
 +
 +
setenv examples:
 +
~: setenv modeboot "run uenvboot"
 +
~: setenv uenvboot "fatload mmc 0 0x3000000 uEnv.txt && env import -t 0x3000000 $filesize && run uenv_boot"
 +
 +
2. Unpack image into SD card ext2 partition:
 +
 +
sudo tar -xzf core-image-minimal-dev-microzed.tar.gz -C /media/rootfs/

Latest revision as of 14:47, 28 January 2016

About

NOTE: a newer version of the article is available here (poky 2.0)

  • Poky revision - DORA (1.5)
  • All of the described things happen in Kubuntu 13.04
  • Building Linux images for Zynq platform - ARMv7

Required packages

src link:

  • Essentials. Packages needed to build an image on a headless system:
sudo apt-get install gawk wget git-core diffstat unzip texinfo build-essential chrpath
  • Graphical Extras. Packages recommended if the host system has graphics support:
sudo apt-get install libsdl1.2-dev xterm
  • Documentation. Packages needed if you are going to build out the Yocto Project documentation manuals:
sudo apt-get install make xsltproc docbook-utils fop dblatex xmlto
  • ADT Installer Extras. Packages needed if you are going to be using the Application Development Toolkit (ADT) Installer:
sudo apt-get install autoconf automake libtool libglib2.0-dev

Output targets

Output folder: poky/build/tmp/deploy/images

These names are as they appear in the u-boot configuration header file - actual output files have different names:

  • boot.bin+(u-boot.img) - u-boot as the first stage bootloader = Secondary Program Loader tha boots u-boot.img
  • devicetree.dtb - device tree with described interfaces, zynq registers, interrupts and drivers
  • uImage - kernel, drivers
  • uramdisk.image.gz - applications

Copy them on the micro SD card > run boot once in the u-boot command line.


Boot options

a. Unpack the root file system image to RAM at boot time.

Check u-boot config file.

Keep uramdisk.image.gz along with other files on FAT partition.

b. Keep the root file system on EXT2(EXT3,etc.) partition of SD card.

Create uEnv.txt on FAT partition. uEnv.txt:

uenv_boot=fatload mmc 0 0x3F00000 ${kernel_image} && fatload mmc 0 0x3E00000 ${devicetree_image} && bootm 0x3F00000 - 0x3E00000
uenvcmd=run uenv_boot

Devicetree needs to be recompiled with changes in bootargs-line:

for ext2:

root=/dev/mmcblk0p2

for ram:

root=/dev/ram

Setup

  • Step 1: Copy into some_script.sh, modify and run:

#Part 1

git clone -b dora git://git.yoctoproject.org/poky.git poky
cd poky; git checkout 50e9ccb2aff7b9f9dca4fda99a6832c60f64de3b

git clone -b dora https://github.com/openembedded/meta-oe.git meta-oe 
#has changed to git clone -b fido https://github.com/openembedded/meta-openembedded?!!!!!!!!)
cd meta-oe; git checkout ee173678383683e972c7d4d6f0ef5790bfa50274; cd ..

git clone -b dora https://github.com/Xilinx/meta-xilinx.git meta-xilinx
cd meta-xilinx; git checkout aa7d677515ab7d45bbd3bdd6c5383f4143147c6d; cd ..

git clone -b master https://github.com/Elphel/meta-ezynq.git meta-ezynq
cd meta-ezynq; git checkout 626e02fc0b9070458baae3e9a0153a2820ec6565; cd ..

git clone -b master https://github.com/Elphel/meta-elphel393.git meta-elphel393
cd meta-elphel393; git checkout fcde04fa6f4f00c7fe593e5f96bf7b40dc50d2b3; cd ..

#Part 2 : init environment and auto-fill Yocto's conf-files

CURRENT_PATH=$(dirname $(readlink -f "$0"))
. ./oe-init-build-env

BBLAYERS_CONF="conf/bblayers.conf"

echo "BBLAYERS = \" \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta-yocto \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta-yocto-bsp \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta-elphel393 \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta-ezynq \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta-oe/meta-oe \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta-oe/meta-webserver \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta-oe/meta-networking \\" >> $BBLAYERS_CONF
echo "  $CURRENT_PATH/meta-xilinx \\" >> $BBLAYERS_CONF
echo "  \"" >> $BBLAYERS_CONF

LOCAL_CONF="conf/local.conf"

# number of parallel tasks (including compiles)
echo "BB_NUMBER_THREADS ?= \"8\"" >> $LOCAL_CONF
# number of parallel compiles
echo "PARALLEL_MAKE ?= \"-j 8\"" >> $LOCAL_CONF
# change the MACHINE
echo "MACHINE ?= \"elphel393\"" >> $LOCAL_CONF
# Elphel's MIRROR website, \n is important
echo "MIRRORS =+ \"http://.*/.*     http://mirror.elphel.com/elphel393_mirror/ \n \"" >> $LOCAL_CONF
  • Step 2: re-init environment
cd poky
. ./oe-init-build-env
  • Step 3: build bootable image (3 targets)
bitbake u-boot-ezynq linux-xlnx core-image-elphel393

Notes

  • Currently having 4 MACHINES: elphel393, microzed, zc706 and zedboard

Build bootloader

bitbake u-boot-ezynq
or
bitbake u-boot
or
bitbake virtual/bootloader

Output

  • poky/build/tmp/deploy/images/boot.bin
  • poky/build/tmp/deploy/images/u-boot.img

Notes

  • Is there a way to build it by running bitbake core-image-elphel393

Build kernel

bitbake linux-xlnx
or
bitbake virtual/kernel

Output

  • poky/build/tmp/deploy/images/uImage (kernel)
  • poky/build/tmp/deploy/images/devicetree.dtb (or some *.dtb)

Notes

  • Sources are cloned to:

poky/build/tmp/work/MACHINE-poky-linux-gnueabi/linux-xlnx/.../linux

  • If you change files like debug drivers for example, when done editing run:

bitbake linux-xlnx -c compile
bitbake linux-xlnx -c deploy

  • When linux-xlnx is 'clean' it is built with the ramdisk.image.gz by bitbake core-image-elphel393, however the boot.bin does not, why?


Build ramdisk.image.gz

bitbake core-image-elphel393

Output

  • poky/build/tmp/deploy/images/uramdisk.image.gz (the file has *.u-boot extension after it's built)

Notes

  • Select root file system format in the recipe:
IMAGE_FSTYPES = "tar.gz"
  • Current packages:
core-image-elphel393.bb:
IMAGE_INSTALL = "packagegroup-core-boot python-core ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}"
  • Also works:
core-image-elphel393.bb:
IMAGE_INSTALL = "packagegroup-core-boot ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}"
IMAGE_INSTALL_append = "python-core"

  • Why python-core and not python?
    • poky/meta/recipes-devtools/python/python-2.7-manifest.inc has a list in PACKAGES, items from which should go into IMAGE_INSTALL
    • Among all there's no python in the PACKAGES list.
    • Does hob install all the PACKAGES if python is checked? Haven't tried, also the used hob version doesn't support saving recipes.

  • Steps for adding packages:
    • elphel393.bb (some discussions mention the leading space is mandatory but somehow it works even without it):
IMAGE_INSTALL_append = "<mandatory space?>python-core \
                       i2c-tools \
                       mtd-utils \
                       net-tools \
                       openssh \
                       modphp \
                       apache2 \
                       php-cli"
    • Why php-cli and not just php?
meta-oe/meta-oe/recipes-devtools/php/php.inc:
PACKAGES = "${PN}-dbg ${PN}-cli ${PN}-cgi ${PN}-fpm ${PN}-fpm-apache2 ${PN}-pear ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}"
      • PACKAGES list includes php. What is installed? (No php-cli: missing /usr/bin/php) Didn't investigate.

      • What does hob build if php is checked? Didn't test.
      • Using php-cli increases the unpacked image size from ~16MB to ~50MB.

U-boot and device tree related notes

  • The default UNPACKED ramdisk max size for zynq is 16MB - once it gets bigger you get KERNEL PANIC - the solution is modifying the device tree - then recompile into DTB:
*.dts, add to bootargs parameter ramdisk_size=32768 (takes KB), example:
bootargs = "console=ttyPS0,115200 root=/dev/ram rw ip=192.168.1.10 earlyprintk ramdisk_size=65536";
  • The default COMPRESSED ramdisk max size for zynq is 10MB set in u-boot - change according to your needs, example:
zynq_zed.h:
"sdboot=echo Copying Linux from SD to RAM... && " \
               "mmcinfo && " \
               "fatload mmc 0 0x3000000 ${kernel_image} && " \
               "fatload mmc 0 0x2A00000 ${devicetree_image} && " \
               "fatload mmc 0 0x2000000 ${ramdisk_image} && " \
               "bootm 0x3000000 0x2000000 0x2A00000\0" \

So, the max sizes:
compressed ramdisk    = 0x2A00000 - 0x2000000 = 0xA00000 = 10MB
devicetree = 0x3000000 - 0x2A00000 = 0x600000 = 6MB


Build everything all together

bitbake u-boot-ezynq linux-xlnx core-image-elphel393

Build toolchain (not necessary - needed only for building ezynq targets outside poky)

  • Step 1: build

bitbake meta-toolchain

  • Step 2: install - launch installer from <some-path>/poky/build/tmp/deploy/


Apply a patch from a recipe

meta-elphel393/
    recipes-kernel/
        linux/
            linux-xlnx_3.8.bb
            linux-xlnx.inc
            linux-xlnx/
                elphel393_defconfig_3.8.cfg
                elphel393.dts
                xilinx_nandps.patch

  • Goal: apply a patch to linux-xlnx files
  • Step 1:

bitbake linux-xlnx

  • Step 2: Go to where the linux-xlnx got cloned - find and edit the target file:

poky/build/tmp/work/elphel393-poky-linux-gnueabi/linux-xlnx/.../linux/

  • Step 3: In the mentioned above directory run:

git diff > somefile.patch

  • Step 4: Copy the patch file into recipes/kernel/linux/linux-xlnx/.
  • Step 5: Edit the recipe, here it's linux-xlnx.inc, add a line like the following:

Apply the patch when building for any MACHINE:

SRC_URI_append += "file://xilinx_nandps.patch"

or only a certain MACHINE="elphel393"

SRC_URI_append_elphel393 += "file://xilinx_nandps.patch"

  • Step 6(?):

bitbake linux-xlnx -c clean -f
bitbake linux-xlnx

Create *.bbappend for an existing package in meta-*

  • Define FILESEXTRAPATHS_prepend := "${THISDIR}/files:" for files that come with the bbappend - so the fetcher could find them
  • Try to add "_append" & "_prepend" to functions
  • If some do_function is incompatible just rewrite it


Switch to dora branch

cd poky; git checkout dora
cd meta-oe; git checkout dora
cd meta-elphel393; git checkout master

Branching in git

  • switch to a branch:
git checkout <name>
  • create a new local branch
git checkout -b <new-branch> <existing-branch>
  • delete a local branch
git branch -D <name>
  • create a new remote branch (from existing local)
git push origin <name>
  • delete a remote branch
git push origin :<name>

Disappeared errors

    • (Is there a better solution for kubuntu 13.04? in kubuntu 12.10 there is no such error - or is it just newer version?) To fix the ERROR="Could not inherit file classes/vala.bbclass" in bitbake copy vala.bbclass from oe-core? or delete the conflicting recipes (2?)?
    • (Is there a better solution for kubuntu 13.04? in kubuntu 12.10 there is no such error - or is it just newer version?) To fix the ERROR="Failed to parse krb5_1.11.3.bb" in bitbake delete the directory meta-oe/meta-oe/recipes-connectivity/krb5

RTC config example in DTS

http://www.denx.de/wiki/DULG/Appendix

Program bitstream from Linux

  • PL status (1=programmed, 0=not):
cat /sys/devices/amba.0/f8007000.ps7-dev-cfg/prog_done
  • Program (the driver understands both *.bit and *.bit.bin)
cat test.bit > /dev/xdevcfg

Create and set up an own external mirror in Yocto/OpenEmbedded

  • To the build/conf/local.conf add:
SOURCE_MIRROR_URL = "file:///data/sources/"
INHERIT += "own-mirrors" 
BB_GENERATE_MIRROR_TARBALLS = "1"
  • Rebuild the target
It didn't store anything in /data/sources/, but in the build/downloads/ instead - tar.gz + tar.gz's made from cloned git repositories.
  • Upload the archives to your mirror website
  • To the build/conf/local.conf add:
MIRRORS =+ "http://.*/.*     http://mirror.elphel.com/elphel393_mirror/ \n "
  • If no need - comment out the files in the build/conf/local.conf:
#SOURCE_MIRROR_URL = "file:///data/sources/"
#INHERIT += "own-mirrors" 
#BB_GENERATE_MIRROR_TARBALLS = "1"

For future consideration

from [meta-xilinx] Best kernel recipe to work against

On Wed, Jan 7, 2015 at 5:42 AM, Philip Balister <philip@balister.org> wrote:
> What's the officially supported best kernel to work against in meta-xilinx?
>
> linux-xlnx-3.14
> linux-yocto-3.17

So it does depend on your preference and requirements. There are still
some drivers missing from the mainline kernel, if you need those
drivers/peripherals then you will most likely need to use the
linux-xlnx kernel.

Shortlist of the main peripherals/drivers that are not yet in the
mainline/linux-yocto kernel:
 * USB (however there is now support upstream in 3.19)
 * PL devcfg
 * QSPI flash controller
 * NAND flash controller
(full list here: http://www.wiki.xilinx.com/Linux+Drivers)

Keep in mind though that the linux-xlnx kernels are short lived, so
you will need to continue updating to newer versions if you want
fixes, etc. And the recipes for the linux-xlnx kernels do not reflect
the actual releases of the linux-xlnx kernel particularly well (since
linux-xlnx releases against Vivado versions instead of linux kernel
versions).

For reference, with microblaze mainline/linux-yocto is the best
supported kernel.

Regards,
Nathan

Some links

1. u-boot environment variables: print all:

~: printenv

setenv examples:

~: setenv modeboot "run uenvboot"
~: setenv uenvboot "fatload mmc 0 0x3000000 uEnv.txt && env import -t 0x3000000 $filesize && run uenv_boot"

2. Unpack image into SD card ext2 partition:

sudo tar -xzf core-image-minimal-dev-microzed.tar.gz -C /media/rootfs/