好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Yocto

https://HdhCmsTestyoctoproject.org

Yocto offical web

System envn.

Git 1.8.3.1 or greater

tar 1.27 or greater

Python 3.4.0 or greater.

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib      build-essential chrpath socat cpio python python3 python3-pip python3-pexpect      xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev      xterm  

The first demo.

download poky-sumo-19.0.3.tar.bz2 from web and extract it. The default machine is x86.

The first thing is to init the env. by run below script

source oe-init-build-env

command to build: bitbake core-image-minimal command to run qemu: runqemu qemux86

  

image name description core-image-minimal A small image just capable of allowing a device to boot. core-image-base A console-only image that fully supports the target device hardware. core-image-sato Image with sato, a mobile environment and visual style for mobile devices.  The image supports X11 with a Sato theme, Pimlico applications and contains terminal, editor and file manager. fsl-image-test Builds contents core-image-base plus Freescale test applications and multimedia components. fsl-image-gui Builds contents of core-image-sato with Freescale test applications and multimedia with hardware accelerated X11

 

The built images are located in

cd tmp/deploy/images 

#Using a existing layer

1. Clone a layer from git 

git clone -b sumo git://git.yoctoproject.org/meta-freescale   2. add the layer to yocto (it must be in build folder)  bitbake-layers add-layer meta-freescale
    #List local layers   bitbake-layers show-layer   

#to build the firmware for imx6ullevk edit build/conf/local.conf , change the machine as MACHINE = "imx6ullevk" bitbake core-image-minimal

bitbake -c clean core-image-minimal

#to build the application developement environment bitbake -c do_populate_sdk_ext core-image-minimal

#create a new layer  

on the build folder

bitbake-layers create-layer meta-stfir-ul

bitbake-layers add-layer meta-stfir-ul bitbake-layers show-layers

#to find the layer which cotains Linux kernel bitbake-layers show-recipes | grep Linux -A 10 | grep meta-freescale -B 5

#check the layer yocto-check-layer meta-ul

#know which Linux version and name is used bitbake -e Virtual /kernel | grep "^PV" bitbake -e Virtual /kernel | grep "^PN"

PN is the package name PV is the package version

bitbake -e u-boot | grep "^PN"

-e means environment

Where is from Virtual /kernel?

PREFERRED_PROVIDER

Determines which recipe should be given preference when multiple recipes provide the same item. You should always suffix the variable with the name of the provided item, and you should set it to the PN of the recipe to which you want to give precedence. Some examples:

     PREFERRED_PROVIDER_ Virtual /kernel ?= " Linux -yocto"
     PREFERRED_PROVIDER_ Virtual /xserver = "xserver-xf86"
     PREFERRED_PROVIDER_ Virtual /libgl ?= "mesa"                    

#the bblayers.conf must in meta-ul for searching the dependence metas.

 

#Customize kernel setting bitbake -c menuconfig Virtual /kernel or bitbake Linux -imx -c menuconfig

bitbake -c savedefconfig Virtual /kernel the defconfig file will be saved in build/tmp/work/fpa1000-poky- Linux -gnueabi/ Linux -imx/4.9.88-r0/build/ you can copy the file to the layer for finally customizing Linux when compilation.

#to list all commands in virutal/kernel bitbake -c listtasks Virtual /kernel bitbake -c listtasks Virtual /bootloader

#to clear the state to initial in case the menuconfig is wrong bitbake -c cleansstate Virtual /kernel

#to show all the bbappends bitbake-layers show-appends

#update the kernel configuration fragment

recommend to update the kernel configuration fragment. in your layer, example recipes-kernel\ Linux \ file: PN_PV.bbappend ( Linux -imx_4.9.88.bbappend) FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"

COMPATIBLE_MACHINE = "(fpa1000)"

SRC_URI += "file://can_config"

a folder name : Linux -imx-4.9.88 has file can_config, which is to disable the CAN device CONFIG_CAN is not set CONFIG_CAN_FLEXCAN is not set CONFIG_CAN_M_CAN is not set

how to generate a configuration fragment bitbake Linux -imx -c menuconfig change what you want, save it when exit, run below command will generate the config.frame which is the changes bitbake Linux -imx -c diffconfig compile the kernel bitbake Linux -imx -c compile -f deploy bitbake Linux -imx -c deploy install and package bitbake Linux -imx

---The summay

To apply kernel config, there are two methods, 1. copy whole file defconfig bitbake Linux -imx -c menuconfig #bitbake Linux -imx -c savedefconfig copy the generated defconfig to your bbapend folder cp ./tmp/work/fpa1000-poky- Linux -gnueabi/ Linux -imx/4.9.88-r0/build/.config meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/defconfig in the bbapend file SRC_URI += " \ file://defconfig \ file://git/arch/arm/boot/dts/fpa1000.dts \ " 2. using config frame, it is better to use patch file, but now I use the whole file The config framement must be *.cfg. copy the *.cfg to the destination folder ( Linux -imx-4.9.88/poky), and change *.bbappend

SRC_URI += "file://disable_can.cfg" SRC_URI += "file://git/arch/arm/boot/dts/fpa1000.dts" SRC_URI += "file://disable_media.cfg" SRC_URI += "file://disable_ATA.cfg" SRC_URI += "file://disable_network.cfg"

Note: The search file path is very import. According to the debug information below, it will search the paths ins sequencly. It will patch the file in case find the file. Special for the same file name. for example, defconfig, it is same name in meta-freescale and meta-ul, it always failure when I put the file in Linux -imx-4.9.88/. it is success when I put the file in Linux -imx-4.9.88/poky/ checking the log.do_fetch at temp. DEBUG: Searching for defconfig in paths: /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/poky /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/poky /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/poky /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/poky /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/fpa1000 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/fpa1000 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/fpa1000 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/fpa1000 /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/mx6ull /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/mx6ull /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/mx6ull /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/mx6ull /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/imxepdc /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/imxepdc /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/imxepdc /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/imxepdc /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/imxpxp /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/imxpxp /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/imxpxp /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/imxpxp /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/mx6 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/mx6 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/mx6 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/mx6 /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/imx /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/imx /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/imx /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/imx /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/armv7ve /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/armv7ve /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/armv7ve /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/armv7ve /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/arm /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/arm /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/arm /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/arm /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/ /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/ /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/ /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/ DEBUG: Searching for git/arch/arm/boot/dts/fpa1000.dts in paths: /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/poky /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/poky /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/poky /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/poky /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/fpa1000 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/fpa1000 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/fpa1000 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/fpa1000 /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/mx6ull /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/mx6ull /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/mx6ull /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/mx6ull /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/imxepdc /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/imxepdc /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/imxepdc /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/imxepdc /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/imxpxp /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/imxpxp /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/imxpxp /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/imxpxp /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/mx6 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/mx6 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/mx6 /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/mx6 /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/imx /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/imx /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/imx /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/imx /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/armv7ve /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/armv7ve /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/armv7ve /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/armv7ve /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/arm /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/arm /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/arm /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/arm /home/zjb/yocto/poky-sumo-19.0.3/meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/ /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx-4.9.88/ /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux / Linux -imx/ /home/zjb/yocto/poky-sumo-19.0.3/meta-freescale/recipes-kernel/ Linux /files/

 

#customize u-boot #the command will show the all commands for u-boot bitbake u-boot-imx -c listtasks #below command will create a terminate and switch to u-boot git folder, in git folder you can use menuconfig oldconfig related to customize u-boot. bitbake u-boot-imx -c devshell

you can use build only recipe e.g. bitbake Linux -imx or bitbake u-boot-imx

The build log file can be found at build/tmp/... using commmand below to find the exactly folder bitbake -e Linux -imx | grep ^T=

to find the source folder bitbake -e Linux -imx | grep ^S= bitbake -e u-boot-imx | grep ^S=

#device tree

The device tree is loacted in : home/zjb/yocto/poky-sumo-19.0.3/build/tmp/work/fpa1000-poky- Linux -gnueabi/ Linux -imx/4.9.88-r0/git/arch/arm/boot/dts only compile the dts bitbake Linux -imx -c devshell make dtbs

#add image to build CORE_IMAGE_EXTRA_INSTALL += " <packagename>" or IMAGE_INSTALL_append = " lighttpd wget"

#how to use local mirror to build in your layer.conf file

build with network, normally the all tar files are achieved in downloads folder: bitbake core-image-minimal

copy: copy build/downloads/* to /home/zjb/SourceMirror/

change to "No network" in layer.conf

SOURCE_MIRROR_URL ?= "file:///home/zjb/SourceMirror/" INHERIT += "own-mirrors" BB_NO_NETWORK = "1"

#override the files because the internet is not avaliable

example lighthttpd, the original bb file URI as below SRC_URI = "http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-${PV}.tar.xz \ file://index.html.lighttpd \ file://lighttpd.conf \ file://lighttpd \ file://lighttpd.service \ file://0001-Use-pkg-config-for-pcre-dependency-instead-of-config.patch \ "

as we don‘t have interrnet access, recreate bbappend in your meta layer FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"

COMPATIBLE_MACHINE = "(fpa1000)"

SRC_URI = "file://lighttpd-1.4.48.tar.gz \ file://index.html.lighttpd \ file://lighttpd.conf \ file://lighttpd \ file://lighttpd.service \ file://0001-Use-pkg-config-for-pcre-dependency-instead-of-config.patch \ " you can see, we only replace the main URL as local file address. add copy the download lighttpd-1.4.48.tar.gz in your /lighttpd-1.4.48/ folder

#how to know which packages are installed the manifest are located in tmp/delploy/images/<imagename>/<imagename.manifest

#customize busybox bitbake -c menuconfig busybox, quit and save what your changes bitbake -c diffconfig, system will generate the config fragment.

 

#only build a specific bb file.

bitbake -b xx.bb to only build a specific bb file.

#using self customized device tree. copy a device tree from original to the folder, e.g. fpa1000.dts meta-ul/recipes-kernel/ Linux / Linux -imx-4.9.88/git/arch/arm/boot/dts/

and then in the machine conf, e.g. fpa1000.conf, change the device config. #KERNEL_DEVICETREE = "imx6ull-14x14-evk.dtb imx6ull-14x14-evk-btwifi.dtb" KERNEL_DEVICETREE = "fpa1000.dtb"

 

#The image in sd-card of one board does not work, use below method to burn the image from nxp offical web 1. connect the micro sd card to Linux 2. fdisk -l to find out which device name, it is /dev/sdc in my system or lsblk 3. bunzip2 -dk -f fsl-image-validation-imx-x11-imx6ull14x14evk.sdcard.bz2 4. sudo dd if=fsl-image-validation-imx-x11-imx6ull14x14evk.sdcard of=/dev/sdc bs=1M conv=fsync

#using below command to find out which output format bitbake core-image-minimal -e | grep ^IMAGE_FSTYPES

#using wic.gz image gunzip core-image-minimal-fpa1000-20190621060255.rootfs.wiz.gz sudo dd if=core-image-minimal-fpa1000-20190621060255.rootfs.wiz of=/dev/sdb bs=1M iflag=fullblock oflag=direct conv=fsync

using self-build image, need to change the fdt_file in uboot to fpa1000.dtb

#how to change the u-boot using self-device 1. fpa1000.conf UBOOT_CONFIG = "sd" #UBOOT_CONFIG[sd] = "mx6ull_14x14_evk_config,sdcard" #UBOOT_CONFIG[mfgtool] = "mx6ull_14x14_evk_config" UBOOT_CONFIG[sd] = "fpa1000_config,sdcard" UBOOT_CONFIG[mfgtool] = "fpa1000_config"

2. in ul/recipes-bsp/u-boot 1). u-boot-imx_2017.03.bbappend SRC_URI += "file://git/configs/fpa1000_defconfig" SRC_URI += "file://git/arch/arm/dts/fpa1000.dts" SRC_URI += "file://git/arch/arm/dts/Makefile"

2). fpa1000_defconfig is copy from u-boot/git/configs/mx6ul_14x14_evk_defconfig with change 3). fpa1000.dts is copy from u-boot/git/arch/arm/imx6ul-14x14-evk.dts without change 4). Makefile is copy from u-boot/git/arch/arm/makefile with change

 

#u-boot source code the u-boot source code is not in work/tmp folder, using bitbake u-boot-imx -c unpack

#u-boot enviroment string is defined in mx6ullevk.h /home/zjb/yocto/poky-sumo-19.0.3/build/tmp/work/fpa1000-poky- Linux -gnueabi/u-boot-imx/2017.03-r0/git/include/configs

#find command find . -name ‘defconfig‘

#grep a text in files grep -rnw . -e ‘findfdt‘

#how to use patch The folder structure of generating patch is very important, because the patch command want to know where to apply. for example, we want to apply the patch for file ./include/configs/mx6ullevk.h 1. generate the patch setup two folders with same structure as file ./include/configs/mx6ullevk.h (or used the origin source code) ./modify/configs/mx6ullevk.h diff -Nupr --no-dereference ./include/ ./modify/ >mx6ullevk.h.patch

2. in bbapend file. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:" SRC_URI += "file://mx6ullevk.h.patch"

and put the generate mx6ullevk.h.patch to the folder ${PN}-${PV}

#how to change default fdt_file in u-boot enviornment The variable is stored in the u-boot source code /include/configs/mx6ullevk.h using patch to change it.

#enable cgi for lighttpd 1. in lighttpd.conf server.modules = ( # "mod_rewrite", # "mod_redirect", "mod_alias", "mod_access", # "mod_cml", # "mod_trigger_b4_dl", # "mod_auth", # "mod_status", # "mod_setenv", # "mod_fastcgi", # "mod_proxy", # "mod_simple_vhost", # "mod_evhost", # "mod_userdir", "mod_cgi", "mod_compress", # "mod_ssi", # "mod_usertrack", # "mod_expire", # "mod_secdownload", # "mod_rrdtool", # "mod_webdav", "mod_accesslog" )

cgi.assign = ( ".cgi" => "" )

alias.url += ("/cgi-bin" => "/www/pages/cgi-bin")

## # which extensions should not be handle via static-file transfer # # .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi" )

2. in lighttpd_%.bbapend RDEPENDS_${PN} += "lighttpd-module-cgi \ lighttpd-module-alias \ lighttpd-module-compress"

#to view which module is compile build/deploy/

in board cat /proc/config.gz |gunzip

#where to find the log information tmp/work/your Linux folder/version/temp

查看更多关于Yocto的详细内容...

  阅读:25次