bitbake常用命令

分享一些yocto常用命令

http://wiki.kaeilos.com/index.php/Bitbake_options

bitbake

Build package (including creating package)

1
$ bitbake -c cleansstate <pkgname>

Cleans up all the tasks state with regard to the given This =ption is frequently used during the development of new recipes

1
$ bitbake -e <pkgname>

Displays the internal state of variables used by BitBake =E6��示bb有哪些任务

1
$ bitbake <pkgname> -c listtasks

Tasks available for a package/recipe

1
$ bitbake <pkgname> -c rebuild -f

Clean and build again a package

1
$ bitbake <pkgname> -c fetch -f 强制下载代码

Download again the source program 交互模式

1
$ bitbake <pkgname> -c devshell

Expand a gnome xterm ready to raise commands

1
$ bitbake <pkgname> -c clean/compile 编译或者清理单个包

Clean or compile package.

1
$ bitbake package-index

Make package index files for feeds

1
$ bitbake <target_image>

Build image contains task-base packages

1
$ bitbake <target_image> -c buildall -f

Build pending packages for \code{target_image}

1
$ bitbake <target_image> -c rootfs -f

Populate rootfs again for \code{target_image}

1
$ bitbake -e <pkgname> | grep ^S=

Finds the source code. 输出包代码的位置

1
$ bitbake -e <target> | grep ^WORKDIR=

Finds bitbakes’s working directory.

1
$ bitbake -e <image-target> | grep ^IMAGE_FSTYPES=

Finds the image types being build

1
$ bitbake -h

Prints out the following help page

Show package dependencies

1
$bitbake -g <pkg> && cat pn-depends.dot | grep -v -e '-native' | grep -v =igraph | grep -v -e '-image' | awk '{print $1}' | sort | uniq

bitbake-layers

usage: bitbake-layers [arguments]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Available commands:
help
display general help or help on a specified command
show-recipes =E6��看所有的recipes名字
list available recipes, showing the layer they are provided by
show-cross-depends
figure out the dependency between recipes that crosses a layer =oundary.
show-appends
list bbappend files and recipe files they apply to
flatten
flattens layer configuration into a separate output directory.
show-layers
show current configured layers
show-overlayed
list overlayed recipes (where the same recipe exists in another =ayer)

bitbake-layers show-layers 察看层

bitbake-layers show-overlayed

bitbake agl-demo-platform-crosssdk 编译SDK

bitbake virtual/kernel -c menuconfig 图形化配置内核

Linux添加swap交换分区(虚拟内存)

确认是否有swap

可以执行free -m 命令查看,如果有swap一行且total项下不为零的话就是存在swap,就不适合再进行添加swap。

添加swap

以下以添加2GB SWAP为例。
(SWAP一般设置为内存的2倍,并非完全以此为标准,只适合4GB以下内存,count后面的数为要设置的swap大小xxMB)

1
2
3
4
5
$ dd if=/dev/zero of=/var/swapfile bs=1M count=2048 # 生成文件块
$ /sbin/mkswap /var/swapfile
$ /sbin/swapon /var/swapfile # 激活swap文件
$ /sbin/swapon -s # 查看一下swap是否正确:
$ chmod 0600 /var/swapfile # 修改文件权限

添加开机自动挂载设置

1
2
$ vi /etc/fstab
$ echo "/var/swapfile swap swap defaults 0 0" >>/etc/fstab

SWAP删除方法:

1
2
$ /sbin/swapoff /var/swapfile # 无效swap
$ rm -f /var/swapfile # 删掉添加的自动挂载swap的设置

删除开机自动挂载设置

1
vi /etc/fstab

Use ubuntu in docker

Search Docker images

1
$ docker search ubuntu

Download Ubuntu docker images

1
$ docker run --name Ubuntu -dt ubuntu

Run bash in Ubuntu docker

1
$ docker exec -it Ubuntu bash

Leave Ubuntu docker

1
$ exit

Start Docker

1
$ docker stop Ubuntu

Stop Docker

1
$ docker stop Ubuntu

How to install docker on Ubuntu 16.04

Install using the repository

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

Install specific version

List the available versions in the repo, then select and install.

1
2
$ apt-cache madison docker-ce
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

Test with hello-world

1
$ sudo docker run hello-world

Use docker without root

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
cat /etc/group | grep docker # 查找 docker 组,确认其是否存在
groups # 列出自己的用户组,确认自己在不在 docker 组中

# 如果 docker 组不存在,则添加之:
sudo groupadd docker

# 将当前用户添加到 docker 组
sudo gpasswd -a ${USER} docker

# 重启服务
sudo service docker restart

# 切换一下用户组(刷新缓存)
newgrp - docker;
newgrp - `groups ${USER} | cut -d' ' -f1`; # TODO:必须逐行执行,不知道为什么,批量执行时第二条不会生效
# 或者,注销并重新登录
pkill X

How to install node on Ubuntu

Node.js v11.x:

1
2
$ curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
$ sudo apt-get install -y nodejs

Node.js v10.x:

1
2
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
$ sudo apt-get install -y nodejs