yocto系列讲解 (实战篇) 70 - meta-iotedge移植笔记

By: fu linux
E-mail: fulinux@sina.com
Blog: https://blog.csdn.net/fulinus
喜欢的盆友欢迎点赞和订阅!
你的喜欢就是我写作的动力!

返回总目录 Yocto开发讲解系列 - 总目录

版本要求

目前 meta-iotedge 较新的版本是 dunfell , 对于的Yocto中也是 dunfell 版本,所以这两个版本相互适配,Yocto版本过低的话编译meta-iotedge可能有很大的难度。
下面记录我在 Yocto gatesgarth 版本编译微软的 iotedge 的过程:

添加依赖层的方法

meta-iotedge依赖这些层:

meta-openembedded{meta-oe meta-python meta-filesystems}
meta-virtualization
meta-rust
  • 1
  • 2
  • 3

我们可以使用类似下面的命令添加:

bitbake-layers layerindex-fetch xxx
  • 1

或者手动下载,有些项目地址参考:
https://layers.openembedded.org/layerindex/branch/master/layers/

poky 目录下手动下载:

git clone git://github.com/meta-rust/meta-rust.git -b gatesgarth
git clone git://git.yoctoproject.org/meta-virtualization -b gatesgarth
git clone git://github.com/openembedded/openembedded-core.git -b gatesgarth
git clone https://github.com/Azure/meta-iotedge.git -b dunfell #目前没有gatesgarth分支
  • 1
  • 2
  • 3
  • 4

meta- rust 改动

meta-rust]$ git log
bf6705f Convert to new override syntax (#357) (Martin 'JaMa' Jansa, 4 months ago) 
1b59fd4 rust-common.inc: Use == operator instead of 'is' (Khem Raj, 5 months ago) #回退到这个提交点,因为使用了新语法,比如"XXXX:append"
meta-rust]$ git reset --hard HEAD^  #或者使用commit id值
meta-rust]$ git diff
diff --git a/conf/distro/include/rust_security_flags.inc #这个文件的语法也要改回来b/conf/distro/include/rust_security_flags.inc
index 590bef1..7e6377e 100644
--- a/conf/distro/include/rust_security_flags.inc
+++ b/conf/distro/include/rust_security_flags.inc
@@ -1,7 +1,7 @@
 # Build errors with PIE options enabled
-SECURITY_CFLAGS:pn-rust-native = "${SECURITY_NO_PIE_CFLAGS}"
-SECURITY_CFLAGS:pn-rust-cross-${TARGET_ARCH} = "${SECURITY_NO_PIE_CFLAGS}"
-SECURITY_CFLAGS:pn-rust = "${SECURITY_NO_PIE_CFLAGS}"
-SECURITY_CFLAGS:pn-rust-llvm = "${SECURITY_NO_PIE_CFLAGS}"
+SECURITY_CFLAGS_pn-rust-native = "${SECURITY_NO_PIE_CFLAGS}"
+SECURITY_CFLAGS_pn-rust-cross-${TARGET_ARCH} = "${SECURITY_NO_PIE_CFLAGS}"
+SECURITY_CFLAGS_pn-rust = "${SECURITY_NO_PIE_CFLAGS}"
+SECURITY_CFLAGS_pn-rust-llvm = "${SECURITY_NO_PIE_CFLAGS}"
 
-SECURITY_LDFLAGS:pn-rust-cross-arm = " -lssp_nonshared -lssp"
+SECURITY_LDFLAGS_pn-rust-cross-arm = " -lssp_nonshared -lssp"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

meta-iotedge改动

meta-iotedge]$ git br
* dunfell
  master
  sumo
meta-iotedge]$ git diff
diff --git a/conf/layer.conf b/conf/layer.conf
index 02b0396..e7bdb37 100644
--- a/conf/layer.conf
+++ b/conf/layer.conf
@@ -10,5 +10,5 @@ BBFILE_PATTERN_meta-iotedge = "^${LAYERDIR}/"
 BBFILE_PRIORITY_meta-iotedge = "10"
 
 LAYERDEPENDS_meta-iotedge = "core rust-layer virtualization-layer"
-LAYERSERIES_COMPAT_meta-iotedge = "dunfell"
+LAYERSERIES_COMPAT_meta-iotedge = "dunfell gatesgarth" #加一个gatesgarth支持
 
diff --git a/recipes-core/iotedge-cli/iotedge-cli.inc b/recipes-core/iotedge-cli/iotedge-cli.inc
index ce85f3a..a51e1d0 100644
--- a/recipes-core/iotedge-cli/iotedge-cli.inc
+++ b/recipes-core/iotedge-cli/iotedge-cli.inc
@@ -7,6 +7,6 @@ export LIBIOTHSM_NOBUILD="On"
 do_install () {
     # Binaries
     install -d  "${D}${bindir}"
-    install -m 755 "${WORKDIR}/iotedge-${PV}/target/${CARGO_TARGET_SUBDIR}/iotedge" ${D}${bindir}/iotedge
+    install -m 755 "${WORKDIR}/build/target/${CARGO_TARGET_SUBDIR}/iotedge" ${D}${bindir}/iotedge
 }
 
diff --git a/recipes-core/iotedge-daemon/iotedge-daemon.inc b/recipes-core/iotedge-daemon/iotedge-daemon.inc
index 29f2655..d743239 100644
--- a/recipes-core/iotedge-daemon/iotedge-daemon.inc
+++ b/recipes-core/iotedge-daemon/iotedge-daemon.inc
@@ -18,7 +18,7 @@ INITSCRIPT_PARAMS_${PN} = "defaults"
 do_install () {
     # Binaries
     install -d  "${D}${bindir}"
-    install -m 755 "${WORKDIR}/iotedge-${PV}/target/${CARGO_TARGET_SUBDIR}/iotedged" ${D}${bindir}/iotedged
+    install -m 755 "${WORKDIR}/build/target/${CARGO_TARGET_SUBDIR}/iotedged" ${D}${bindir}/iotedged
 
     # Config file
     install -d "${D}${sysconfdir}/iotedge"
diff --git a/recipes-devtools/cargo/cargo_1.41.0.bbappend b/recipes-devtools/cargo/cargo_1.41.0.bbappend
deleted file mode 100644
index e152789..0000000
--- a/recipes-devtools/cargo/cargo_1.41.0.bbappend
+++ /dev/null
@@ -1,2 +0,0 @@
-unset LIBGIT2_SYS_USE_PKG_CONFIG
-
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49

添加依赖layer层到配置文件中

可以使用这个命令添加:

build]$ bitbake-layers add-layer ../meta-openembedded/meta-oe
NOTE: Starting bitbake server...
build]$ bitbake-layers add-layer ../meta-openembedded/meta-python
NOTE: Starting bitbake server...
build]$ bitbake-layers add-layer ../meta-openembedded/meta-networking
NOTE: Starting bitbake server...
build]$ bitbake-layers add-layer ../meta-openembedded/meta-filesystems
NOTE: Starting bitbake server...
build]$ bitbake-layers add-layer ../meta-rust
NOTE: Starting bitbake server...
build]$ bitbake-layers add-layer ../meta-virtualization
NOTE: Starting bitbake server...
build]$ bitbake-layers add-layer ../meta-iotedge
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

最后 poky/build/conf/bblayers.conf 文件的内容如下:

  /home/peeta/poky/meta-openembedded/meta-oe \
  /home/peeta/poky/meta-openembedded/meta-python \
  /home/peeta/poky/meta-openembedded/meta-networking \
  /home/peeta/poky/meta-openembedded/meta-filesystems \
  /home/peeta/poky/meta-rust \
  /home/peeta/poky/meta-virtualization \
  /home/peeta/poky/meta-iotedge \
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

添加安装内容

build/conf/local.conf 添加了

IMAGE_INSTALL_append = " iotedge-cli iotedge-daemon libiothsm-std"
DISTRO_FEATURES_append = " virtualization"
  • 1
  • 2

然后开始编译

build]$ bitbake core-image-sato
  • 1

运行结果展示

在这里插入图片描述
但是我本身对这个iotedge不是很熟悉,以后有机会内容再做扩展哈~