一. 准备工作
1. 先查看yocto的系统依赖 :
https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html
sudo apt-get install build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd
2. 关键版本信息
注意目标的分支,我选择的是walnasacar,关键的库的版本信息如下:https://wiki.yoctoproject.org/wiki/Recipe_Versions
| Release | linux-yocto (kernel) | gcc | binutils | glibc | python3 |
|---|---|---|---|---|---|
| walnascar (5.2) | 6.12.x | 14.2 | 2.44 | 2.41 | 3.13.x |
| scarthgap (5.0) | 6.6.x | 13.2 | 2.42 | 2.39 | 3.12.x |
| kirkstone (4.0) | 5.10.x / 5.15.x | 11.4 | 2.38 | 2.35 | 3.10.x |
| dunfell (3.1) | 5.4.x | 9.5 | 2.34 | 2.31 | 3.8.x |
3. 下载poky
git clone https://git.yoctoproject.org/poky -b walnascar
下载比较慢,可以使用镜像仓库,或者走代理加速 -- (注意clone用的http地址才会走git的http.proxy);
git config --global http.proxy http://127.0.0.1:xx
git config --global https.proxy http://127.0.0.1:xx
# 如果遇到ssl报错可以设置
git config --global http.sslVerify false
4. 配置编译
-
进入编译环境
(我的目标只是编译nativesdk)
cd poky
source oe-init-build-env
回显如下:
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-full-cmdline
core-image-sato
core-image-weston
meta-toolchain
meta-ide-support
You can also run generated qemu images with a command like 'runqemu qemux86-64'.
Other commonly useful commands are:
- 'devtool' and 'recipetool' handle common recipe tasks
- 'bitbake-layers' handles common layer tasks
- 'oe-pkgdata-util' handles common target package tasks
You had no /root/work_code/debian13_toolchain/poky/.vscode configuration.
These configuration files have therefore been created for you.
-
meta-ide-support和meta-toolchain的区别是什么?
----- 因为我是需要编译一个目标平台的工具链SDK,我们可以看到两个接近的目标定义,其中meta-ide-support 是把Yocto构建环境本身变成你的“SDK”;而meta-toolchain 是生成一个独立的SDK包供你或他人使用。那么meta-toolchain应该是我想要的目标;
-
meta-toolchain和populate_sdk的联系是什么?
------ meta-toolchain的目标是提供一个最小化的、用于交叉编译的基础工具链(编译器、链接器、基础库头文件)。populate_sdk目标是生成一个与指定目标镜像完全匹配的、功能完整的SDK,包含工具链、目标系统的所有库和头文件,以及环境脚本。那么meta-toolchain应该依旧是我想要的目标,目标系统的sysroot我用其他方法生成;
-
yocto esdk和sdk的区别?
---- 标准SDK:如果你的应用程序需要目标系统里没有的库(如 libjson-c),你需要自行交叉编译该库、处理依赖,并手动配置SDK的 sysroot,过程繁琐。
---- eSDK:你只需运行 devtool add libjson-c (或指向源码),devtool 会自动创建配方、解析依赖、调用内置的BitBake进行构建,并将编译好的库和头文件自动部署并更新到eSDK的 sysroot 中。之后你的应用程序就能直接找到这个库了。
-
增加下官方的镜像源,也可以配置本地或者内网的加速源
修改conf/local.conf
MIRRORS += "\
git://.*/.* https://downloads.yoctoproject.org/mirror/sources/ \n \
https://.*/.* https://downloads.yoctoproject.org/mirror/sources/ \
"
EMIRRORS += "\
git://sourceware.org/git/glibc.git https://downloads.yoctoproject.org/mirror/sources/ \n \
git://sourceware.org/git/binutils-gdb.git https://downloads.yoctoproject.org/mirror/sources/ \
"
-
精简需要编译打包的内容
-
查看初始状态
-
在正式编译之前先看下meta-toolchain到底依赖哪些软件包,也就是会编译哪些东西
bitbake -g meta-toolchain
生成了pn-buildlist和task-depends.dot
sudo apt install graphviz
dot -Tpng task-depends.dot -o depends.png
这个时候的pn-buildlist内容如下(计337个):
acl
acl-native
attr
attr-native
autoconf-archive-native
autoconf-native
automake-native
base-files
base-passwd
bash
bash-completion
bc
bc-native
binutils
binutils-cross-canadian-x86-64
binutils-cross-x86_64
binutils-crosssdk-x86_64-pokysdk-linux
bison-native
btrfs-tools
bzip2
bzip2-native
ca-certificates
chrpath-native
cmake-native
coreutils
createrepo-c-native
cross-localedef-native
curl
curl-native
cwautomacros-native
debianutils-native
depmodwrapper-cross
diffutils
dnf-native
docbook-xml-dtd4-native
docbook-xsl-stylesheets-native
dwarfsrcfiles-native
e2fsprogs
e2fsprogs-native
elfutils
elfutils-native
expat
expat-native
file
file-native
findutils
flex-native
gawk
gcc
gcc-cross-canadian-x86-64
gcc-cross-x86_64
gcc-crosssdk-x86_64-pokysdk-linux
gcc-runtime
gcc-source-14.3.0
gdb-cross-canadian-x86-64
gdbm
gdbm-native
gettext-minimal-native
gettext-native
git-native
glib-2.0-native
glibc
glibc-locale
gmp
gmp-native
gnu-config-native
gnutls
gnutls-native
gobject-introspection-native
gperf-native
gpgme-native
grep
gtk-doc-native
help2man-native
iproute2
iptables
json-c
json-c-native
kern-tools-native
kmod
kmod-native
libarchive
libarchive-native
libassuan-native
libbsd-native
libcap
libcap-native
libcap-ng
libcap-ng-native
libcheck-native
libcomps-native
libdnf-native
libedit
libedit-native
libffi
libffi-native
libgcc
libgcc-initial
libgcrypt
libgcrypt-native
libgpg-error
libgpg-error-native
libidn2
libidn2-native
libmd-native
libmicrohttpd
libmicrohttpd-native
libmnl
libmodulemd-native
libmpc
libmpc-native
libpcre2
libpcre2-native
librepo-native
libseccomp
libsolv-native
libtasn1
libtasn1-native
libtool-cross
libtool-native
libunistring
libunistring-native
libxcrypt
libxml2-native
libxslt-native
libyaml-native
linux-libc-headers
linux-yocto
lua-native
lzlib
lzlib-native
m4-native
make
make-native
makedepend-native
meson-native
meta-environment-qemux86-64
meta-toolchain
mpfr
mpfr-native
nativesdk-acl
nativesdk-attr
nativesdk-autoconf
nativesdk-automake
nativesdk-bash
nativesdk-bash-completion
nativesdk-bison
nativesdk-bzip2
nativesdk-ca-certificates
nativesdk-cmake
nativesdk-curl
nativesdk-debugedit
nativesdk-diffutils
nativesdk-dtc
nativesdk-elfutils
nativesdk-expat
nativesdk-file
nat

最低0.47元/天 解锁文章
787

被折叠的 条评论
为什么被折叠?



