Poky manual
From ElphelWiki
Contents
Description
- Building embedded Linux image for Zynq ARMv7 platform - Elphel 10393 board
About
- Yocto Poky revision = 2.0
- Host OS = Kubuntu 14.04.3 LTS x64
Required packages
- Found in Yocto Project mega-manual
Output files
Found in the poky's deploy directory:
- files for rootfs in NAND Flash: poky/build/tmp/deploy/images/elphel393/nand/
- files for rootfs on MMC (micro SD card): poky/build/tmp/deploy/images/elphel393/mmc/
These names are listed as they appear in the u-boot configuration header file - actual output files have different names:
- boot.bin - u-boot as the first stage bootloader = Secondary Program Loader that boots u-boot-dtb.img
- u-boot-dtb.img - full size u-boot with a stripped device tree (cat u-boot.img some_stripped_devicetree.dtb > u-boot-dtb.img)
- devicetree.dtb - device tree with listed interfaces, zynq registers, interrupts and drivers
- uImage - kernel, drivers
- rootfs.ubifs or rootfs.tar.gz - rootfs
Boot options
Boot from micro SD card
- The micro SD card/adapter must be modified for this boot mode (to keep CD pin high) - only then the camera will boot.
- EXT4 partition mounted as /.
Instructions
PC:
- After all of the targets are built use files from .../poky/build/tmp/deploy/images/elphel393/mmc/
- Format to have 2 partitions: FAT32 and EXT4 (use gparted), the order of partitions is important or change bootargs in the device tree.
- FAT32: copy the following files:
- boot.bin
- u-boot-dtb.img
- devicetree.dtb
- uImage
- EXT4: mounted to some <mountpoint>
- unpack the rootfs.tar.gz, console:
tar -C <mountpoint> -xzpf rootfs.tar.gz
Camera:
- Insert, power on
Boot from NAND flash
- The default boot option - power on.
- A UBIFS image of rootfs is written to /dev/mtd4 (ubi0:elphel393 in bootargs in the device tree)
Reflash factory image (update software/firmware or corrupt flash partition)
- Use files from .../poky/build/tmp/deploy/images/elphel393/nand/
- Copy all of the image files to a micro SD card (or boot first from the card then copy over network)
- Boot from micro SD card.
- Reflash what is needed:
- Reflash SPL (boot.bin, /dev/mtd0)
cd <path-to-image-files> # boot.bin # mtd0 is 1MB (8 eraseblocks,128K = 1 block, there are 64 pages of 2048 per block) # erase only first 2 blocks, other block are reserved for copies flash_unlock /dev/mtd0 flash_erase /dev/mtd0 0 2 nandwrite -n /dev/mtd0 -p boot.bin
- Reflash u-boot (u-boot-dtb.img, /dev/mtd1)
cd <path-to-image-files> # u-boot-dtb.img # mtd1 is 4M (32 eraseblocks,128K = 1 block, there are 64 pages of 2048 per block) # erase only the 1st 8 blocks as image is <1M, leave unused area for backup copies flash_unlock /dev/mtd1 flash_erase /dev/mtd1 0 8 nandwrite -n /dev/mtd1 -p u-boot-dtb.img
- Reflash devicetree (devicetree.dtb, /dev/mtd2)
cd <path-to-image-files> # u-boot-dtb.img # mtd2 is 1M (8 eraseblocks,128K = 1 block, there are 64 pages of 2048 per block) flash_unlock /dev/mtd2 flash_erase /dev/mtd2 0 8 nandwrite -n /dev/mtd2 -p devicetree.dtb
- Reflash kernel (uImage, /dev/mtd3)
cd <path-to-image-files> # uImage # mtd3 is 16M (128 eraseblocks,128K = 1 block, there are 64 pages of 2048 per block) flash_unlock /dev/mtd3 flash_erase /dev/mtd3 0 128 nandwrite -n /dev/mtd3 -p uImage
- For rootfs there are 2 options:
- update - recommended, rootfs.ubifs
- reflash - radical, rootfs.ubi
- For rootfs there are 2 options:
Update:
# NOT TESTED ubiattach /dev/ubi_ctrl -m 4 #ubimkvol /dev/ubi0 -N elphel393-rootfs -s 256MiB ubiupdatevol /dev/ubi0_0 rootfs.ubifs # read: http://www.linux-mtd.infradead.org/faq/ubifs.html # read: http://free-electrons.com/blog/creating-flashing-ubi-ubifs-images/ # read: http://www.linux-mtd.infradead.org/doc/ubi.html#L_volupdate
Reflash:
cd <path-to-image-files> flash_unlock /dev/mtd4 flash_erase /dev/mtd4 0 2048 ubiformat /dev/mtd4 -f rootfs.ubi -s 2048 -O 2048
Note: Considering to store the u-boot, device tree and kernel on UBUFS partitions in future.
Setup
- Step 1: Copy the following lines to some_script.sh, modify and run:
#Part 1 git clone -b master git://git.yoctoproject.org/poky.git poky cd poky; git checkout 3d2c0f5902cacf9d8544bf263b51ef0dd1a7218c git clone -b master https://github.com/Elphel/meta-ezynq.git meta-ezynq cd meta-ezynq; git checkout b8b1cd8e6dae7cadb51e987f966a4ffbcd6c6543; cd .. git clone -b master https://github.com/Elphel/meta-elphel393.git meta-elphel393 cd meta-elphel393; git checkout c5237f99d94217bff8c9180bed93ee673c9590a1; cd .. git clone -b master https://github.com/Xilinx/meta-xilinx.git meta-xilinx cd meta-xilinx; git checkout cc146d6c170f100eb2f445047969893faa7a6a55; cd .. git clone -b master git://git.openembedded.org/meta-openembedded meta-openembedded cd meta-openembedded; git checkout 73854a05565b30a5ca146ac53959c679b27815aa; cd .. #Part 2 : init environment and auto-fill Yocto's conf-files CONF_NOTES="meta/conf/conf-notes.txt" if [ -f $CONF_NOTES ]; then rm $CONF_NOTES fi echo "Common \"elphel393\" targets are:" >> $CONF_NOTES echo " u-boot" >> $CONF_NOTES echo " device-tree" >> $CONF_NOTES echo " linux-xlnx" >> $CONF_NOTES echo " core-image-elphel393" >> $CONF_NOTES 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-ezynq \\" >> $BBLAYERS_CONF echo " $CURRENT_PATH/meta-elphel393 \\" >> $BBLAYERS_CONF echo " $CURRENT_PATH/meta-xilinx \\" >> $BBLAYERS_CONF echo " $CURRENT_PATH/meta-openembedded/meta-oe \\" >> $BBLAYERS_CONF echo " $CURRENT_PATH/meta-openembedded/meta-python \\" >> $BBLAYERS_CONF echo " $CURRENT_PATH/meta-openembedded/meta-networking \\" >> $BBLAYERS_CONF echo " $CURRENT_PATH/meta-openembedded/meta-webserver \\" >> $BBLAYERS_CONF echo " \"" >> $BBLAYERS_CONF LOCAL_CONF="conf/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 device-tree linux-xlnx core-image-elphel393
Build bootloader
bitbake u-boot-ezynq or bitbake u-boot or bitbake virtual/bootloader
Output
- poky/build/tmp/deploy/images/<machine>/boot.bin
- poky/build/tmp/deploy/images/<machine>/u-boot-dtb.img
Notes
- Since Poky 1.5.1 switched from u-boot-xlnx to u-boot - some of the u-boot-xlnx reached the upstream
- Since Poky 1.5.1 u-boot introduced Kconfig and currently (as of 2016/01/22) is still migrating from autoconf - keeping both build methods working together.
- Current u-boot uses the board's device tree blob to make a stripped version for itself - uncompiled device tree files are present in the u-boot sources
Compile devicetree
bitbake device-tree
Output
- poky/build/tmp/deploy/images/<machine>/devicetree.dtb
Build kernel
bitbake linux-xlnx or bitbake virtual/kernel
Output
- poky/build/tmp/deploy/images/<machine>/uImage (kernel)
Notes
- Kernel version is 4.0, linux-xlnx
- Device Tree Blob is compiled separately in linux-xlnx
- Uncompiled device tree files are present in the linux sources provided by linux-xlnx
Build ramdisk.image.gz
bitbake core-image-elphel393
Output
- poky/build/tmp/deploy/images/<machine>/uramdisk.image.gz (the file has *.u-boot extension after it's built)
Notes
- [FIXED] lighttpd-1.4.39, mod-cgi
compile warning:
implicit declaration of function 'chunkqueue_written'
results in lighttpd failing to start if mod-cgi is enabled:
Starting Lighttpd Web Server: 2016-01-26 18:42:17: (/data/GIT_fresh/poky/build/tmp/work/cortexa9-vfp-neon-poky-linux-gnueabi/lighttpd/1.4.36-r0/lighttpd-1.4.36/src/plugin.c.169) dlopen() failed for: /usr/lib/mod_cgi.so /usr/lib/mod_cgi.so: undefined symbol: chunkqueue_w 2016-01-26 18:42:17: (/data/GIT_fresh/poky/build/tmp/work/cortexa9-vfp-neon-poky-linux-gnueabi/lighttpd/1.4.36-r0/lighttpd-1.4.36/src/server.c.679) loading plugins finally failed lighttpd.
Note: why 1.4.36?!!
solution: exclude the 0001-mod_cgi-buffers-data-without-bound.patch from the file list that comes with the poky/meta/recipes-extended/lighttpd_1.4.39.bb