YOCTO使用技巧

1. 增加编译线程
vi build-fb/conf/local.conf
BB_NUMBER_THREADS = "32" /* 修改BitBake可以使用的线程 */
PARALLEL_MAKE = "-j 32" /* 修改make可以使用的线程 */

2. 下载代码包
bitbake fsl-image-qt5-validation-imx -c fetchall

3. 使用图形化界面查看软件依赖关系
bitbake --ui=depexp -g bluez5

4. 选择编译适合自己的交叉编译器
将自己选择好的写入vi build-fb/conf/local.conf中:

5. 使用包管理器
vi build-fb/conf/local.conf
PACKAGE_CLASSES ?= "package_rpm"

增加以上选项,编译后就可以生成rpm包了:
build-fb/tmp/deploy/rpm/imx6qsabresd/

配置文件服务器:
wxli@ubuntu:/bt/wxli/temp/fsl/linux/fsl-release-bsp/build-fb/tmp/deploy/rpm/imx6qsabresd$ python -m SimpleHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...
192.168.0.51 - - [23/Mar/2018 13:24:24] "GET / HTTP/1.1" 200 -
192.168.0.51 - - [23/Mar/2018 13:24:24] code 404, message File not found
192.168.0.51 - - [23/Mar/2018 13:24:24] "GET /favicon.ico HTTP/1.1" 404 -


查看包的status:
smart stats

使用的smart工具添加channel:
sudo smart channel --add imx6qsabresd type=rpm-md baseurl= http://192.168.0.53:8000/imx6qsabresd

更新状态:
sudo smart update

查看包的status:
wxli@ubuntu:/bt/wxli/temp/fsl/linux/fsl-release-bsp/build-fb/tmp/deploy/rpm$ smart stats
Loading cache...
Updating cache... ################################################################################################################### [100%]

Installed Packages: 1294
Total Packages: 56499
Total Provides: 62101
Total Requires: 40759
Total Upgrades: 56499
Total Conflicts: 11789

6. 查找包名
bitbake -s | grep XXX

7. yocto添加自己的应用程序
a. 样例演示
1)创建样例 brcm-88335
wxli@ubuntu:/bt/wxli/temp/fsl/linux/fsl-release-bsp/sourrces$ yocto-layer create brcm-88335
Please enter the layer priority you'd like to use for the layer: [default: 6] # 优先级
Would you like to have an example recipe created? (y/n) [default: n] y # 是否包含一个样例
Please enter the name you'd like to use for your example recipe: [default: example] brcm-88335 # 样例名字
Would you like to have an example bbappend file created? (y/n) [default: n] y # 是否创建样例的bbappend文件
Please enter the name you'd like to use for your bbappend file: [default: example] brcm-88335 # 样例的bbappend名字
Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to): [default: 0.1]

New layer created in meta-brcm-88335.

Don't forget to add it to your BBLAYERS (for details see meta-brcm-88335/README).
wxli@ubuntu:/bt/wxli/temp/fsl/linux/fsl-release-bsp/build-fb/tmp/work/cortexa9hf-neon-poky-linux-gnueabi$

2) 执行成功后生成yocto layer路径如下:
sources/meta-brcm-88335
sources/meta-brcm-88335/recipes-example/example/brcm-88335-0.1

vi conf/bblayers.conf
+ BBLAYERS += " ${BSPDIR}/sources/meta-brcm-88335 "

3)将新建的层添加到工程中
vi ./fsl-setup-release.sh
META_FSL_BSP_RELEASE="${CWD}/sources/meta-fsl-bsp-release/imx/meta-bsp"
echo "##Freescale Yocto Project Release layer" >> $BUILD_DIR/conf/bblayers.conf
echo "BBLAYERS += \" \${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-bsp \"" >> $BUILD_DIR/conf/bblayers.conf
echo "BBLAYERS += \" \${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-sdk \"" >> $BUILD_DIR/conf/bblayers.conf

echo "BBLAYERS += \" \${BSPDIR}/sources/meta-browser \"" >> $BUILD_DIR/conf/bblayers.conf
echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-gnome \"" >> $BUILD_DIR/conf/bblayers.conf
echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-networking \"" >> $BUILD_DIR/conf/bblayers.conf
echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-python \"" >> $BUILD_DIR/conf/bblayers.conf
echo "BBLAYERS += \" \${BSPDIR}/sources/meta-openembedded/meta-filesystems \"" >> $BUILD_DIR/conf/bblayers.conf
+ echo "BBLAYERS += \" \${BSPDIR}/sources/meta-brcm-88335 \"" >> $BUILD_DIR/conf/bblayers.conf

echo "BBLAYERS += \" \${BSPDIR}/sources/meta-qt5 \"" >> $BUILD_DIR/conf/bblayers.conf

4)编译新建样例
DISTRO=fsl-imx-fb MACHINE=imx6qsabresd source fsl-setup-release.sh -b build-fb

bitbake brcm-88335
或者
bitbake -b ../sources/meta-brcm-88335/recipes-brcm/brcm/brcm-88335_0.1.bb -v

5) 编译成功后中间文件目录
build-fb/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/brcm-88335

b.实例演示
1)创建 brcm-88335
wxli@ubuntu:/bt/wxli/temp/fsl/linux/fsl-release-bsp/sources$ yocto-layer create brcm-88335
Please enter the layer priority you'd like to use for the layer: [default: 6]
Would you like to have an example recipe created? (y/n) [default: n] n
Would you like to have an example bbappend file created? (y/n) [default: n] n

New layer created in meta-brcm-88335.

Don't forget to add it to your BBLAYERS (for details see meta-brcm-88335/README).

2)创建bb文件
vi sources/meta-brcm-88335/brcm-88335_0.1.bb
DESCRIPTION = "Hello World and Zlib test"
DEPENDS = "zlib"
SECTION = "libs"
LICENSE = "MIT"
# PV = "3"
# PR = "r0"

SRC_URI = " \
file://brcm_patchram_plus.c \
file://Makefile \
"

LIC_FILES_CHKSUM = "file://brcm_patchram_plus.c;md5=627e9612337e5ef6027a87a79c491446"
S = "${WORKDIR}"
do_compile () {
make
}

do_install () {
install -d ${D}${bindir}/
install -m 0755 ${S}/brcm_patchram_plus ${D}${bindir}/

}

FILES_${PN} = "${bindir}/brcm_patchram_plus"

INSANE_SKIP_${PN} = "ldflags"
#For dev packages only
INSANE_SKIP_${PN}-dev = "ldflags"

3)创建源码目录brcm-88335-0.1,源文件brcm_patchram_plus.c, Makefile


4) Makefile
vi sources/meta-brcm-88335/brcm-88335-0.1/Makefile
TARGET=brcm_patchram_plus
LDFLAGS= -lz

all: $(TARGET)
helloYocto: brcm_patchram_plus.o
$(CC) $(CFLAGS) -o $@ $^

#zlibtest: zlibtest.o
# $(CC) $(CFLAGS1) -o $@ $^ $(LDFLAGS)

clean:
rm -f $(OBJS) $(TARGET)

5) 修改bblayers.conf,增加bitbake编译选项,支持编译brcm-88335_0.1.bb
vi build-fb/conf/bblayers.conf
+ BBLAYERS += " ${BSPDIR}/sources/meta-brcm-88335 "

6)编译
DISTRO=fsl-imx-fb MACHINE=imx6qsabresd source fsl-setup-release.sh -b build-fb

bitbake brcm-88335
或者
bitbake -b ../sources/meta-brcm-88335/recipes-brcm/brcm/brcm-88335_0.1.bb -v



















  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值