[ 物联网篇 ] 03 - Yocto Project (YP)构建 Alexa SDK

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/z2066411585/article/details/89159268

目标 : i.MX8M EVK board 编译出 Alexa SDK (AVS) image , 详细步骤可以参考Build Alexa SDK (AVS) image for i.MX8M EVK board (with Yocto Morty, Kernel4.9)

  • 下载源码
$ cd <yocto_dir>
$ repo init -u https://source.codeaurora.org/external/imxsupport/meta-avs-demos -b master -m imx-alexa-sdk-4.9.51-8mq_ga.xml
$ repo sync
  • 配置环境 MACHINE=imx8mqevk DISTRO=fsl-imx-xwayland source avs-setup-demo.sh -b <build_sdk_8M>

  • 编译 bitbake avs-image , 一段时间后编译qemu-native/2.7.0 的时候报错

 bitbake avs-image
WARNING: Host distribution "Ubuntu-18.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |###############################################################################################################################################################################| Time: 0:00:01
Loaded 3080 entries from dependency cache.
Parsing recipes: 100% |#############################################################################################################################################################################| Time: 0:00:53
Parsing of 2345 .bb files complete (1282 cached, 1063 parsed). 3080 targets, 492 skipped, 12 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.32.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-18.04"
TARGET_SYS        = "aarch64-poky-linux"
MACHINE           = "imx8mqevk"
DISTRO            = "fsl-imx-wayland"
DISTRO_VERSION    = "4.9.51-mx8-ga"
TUNE_FEATURES     = "aarch64"
TARGET_FPU        = ""
meta              
meta-poky         = "HEAD:8298428c032ec9bc5b514d0c194a16cf371475ea"
meta-oe           
meta-multimedia   = "master:b40116cf457b88a2db14b86fda9627fb34d56ae6"
meta-freescale    = "HEAD:05681fdf8298bb441c15135eae424c7601b07e98"
meta-freescale-3rdparty = "HEAD:e55167c3c2770c07a475342f99cc2a3a23fbfa0c"
meta-freescale-distro = "HEAD:cd5c7a2539f40004f74126e9fdf08254fd9a6390"
meta-bsp          
meta-sdk          = "HEAD:0649ff215e8f9b79ecd3b813d672547aa45c086b"
meta-browser      = "HEAD:678706cb43fb8576ff7b88bfb612993b8542724d"
meta-gnome        
meta-networking   
meta-python       
meta-filesystems  = "master:b40116cf457b88a2db14b86fda9627fb34d56ae6"
meta-qt5          = "HEAD:ff073f04109900fc07bf81e2f1df63c626caf342"
meta-avs-demos    = "HEAD:fe76db339872033dcc76beea28bfa2c9e9cfb3f4"

Initialising tasks: 100% |##########################################################################################################################################################################| Time: 0:00:56
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: qemu-native-2.7.0-r1 do_compile: oe_runmake failed
ERROR: qemu-native-2.7.0-r1 do_compile: Function failed: do_compile (log file is located at xxx/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/temp/log.do_compile.11705)
ERROR: Logfile of failure stored in: xxx/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/temp/log.do_compile.11705

  • 根据错误提示找到对应的日志
  CC    qga/channel-posix.o
  CC    qga/qapi-generated/qga-qapi-types.o
  CC    qga/qapi-generated/qga-qapi-visit.o
  CC    qga/qapi-generated/qga-qmp-marshal.o
  CC    qmp-introspect.o
  CC    qapi-types.o
  CC    qapi-visit.o
  CC    qapi-event.o
  CC    util/memfd.o
  CC    util/path.o
xxx/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/qemu-2.7.0/util/memfd.c:40:12: error: static declaration of ‘memfd_create’ follows non-static declaration
 static int memfd_create(const char *name, unsigned int flags)
            ^~~~~~~~~~~~

解决方案 1:

参考 stackoverflow 找到对应的答案:

Description: Building 2.8b2 and earlier fails on Ubuntu 18.04 LTS.

Workaround: It works on Ubuntu 16.04 LTS.

意思应该是Qemu 2.8b2以及更早版本在 Ubuntu 18.04 构建失败,但是在 Ubuntu 16.04 可以的。说的应该是对的,构建的时候本机为Ubuntu 18.04 , 最快捷的办法是在Docker 上构建就可以了。

解决方案 2:

方案2的思路就是如何在Ubuntu 18.04上编译qemu-native-2.7.0

最快速的办法是下载官网qemu-3.1.0的包,看看其中util/memfd.c怎么实现的。

也可以参考static declaration of memfd_create follows non-static declaration

  • qemu-native/2.7.0-r1/configure中的
 # check if memfd is supported
 memfd=no
 cat > $TMPC << EOF
-#include <sys/memfd.h>  //删除
+#include <sys/mman.h>    // 增加
 
 int main(void)
 {
diff --git a/util/memfd.c b/util/memfd.c
index 4571d1a..412e94a 100644 (file)
  • qemu-native/2.7.0-r1/memfd.c
 #include "qemu/memfd.h"
 
-#ifdef CONFIG_MEMFD
-#include <sys/memfd.h>   // 删除
-#elif defined CONFIG_LINUX  // 删除 
+#if defined CONFIG_LINUX && !defined CONFIG_MEMFD  //增加
 #include <sys/syscall.h>
 #include <asm/unistd.h>


e2fsprogs-native编译失败

../../git/debugfs/../misc/create_inode.c:291:13: warning: In the GNU C Library, "minor" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "minor", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "minor", you should undefine it after including <sys/types.h>.
   devminor = minor(st->st_rdev);
             ^~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                                                                                                                                                    
../../git/debugfs/../misc/create_inode.c: At top level:
../../git/debugfs/../misc/create_inode.c:395:18: error: conflicting types for ‘copy_file_range’
 static errcode_t copy_file_range(ext2_filsys fs, int fd, ext2_file_t e2_file,
                  ^~~~~~~~~~~~~~~
In file included from ../../git/debugfs/../misc/create_inode.c:19:0:
/usr/include/unistd.h:1110:9: note: previous declaration of ‘copy_file_range’ was here
 ssize_t copy_file_range (int __infd, __off64_t *__pinoff,
         ^~~~~~~~~~~~~~~
Makefile:412: recipe for target 'create_inode.o' failed
make[2]: *** [create_inode.o] Error 1

  • 解决方案

yocto_code/build/tmp/work/x86_64-linux/e2fsprogs-native/1.43-r1/git/misc/create_inode.c中的头文件注释掉

//#include <unistd.h>

总结

编译出错的原因主要是和Ubuntude的版本号有区别,一般普遍的SDK都可以在Ubuntu 16.04 上运行,可能Ubuntu 18.04 还没有完全匹配, 方便的额办法以后的SDK可以在Docker 中构建,可以避免环境的问题

展开阅读全文

没有更多推荐了,返回首页