【问题标题】:Yocto Raspberry Pi - error during installation rpi_ws281x libraryYocto Raspberry Pi - 安装 rpi_ws281x 库时出错
【发布时间】:2023-03-21 10:27:01
【问题描述】:

我正在尝试使用 Yocto Project 构建最小的树莓派零映像。我对 C 不熟悉,但我想知道为什么在编译“ws2811.c”期间会出现这个(微不足道的)错误,我可以在另一个带有 raspbian OS 的 raspberry pi 2 上成功构建(整个库)而没有任何错误。感谢您的每一个提示和帮助!

存储库:

https://github.com/jgarff/rpi_ws281x

我的配方在尝试构建根(存储库)位置“scons”时卡住了:

sudo scons

Bitbake 编译配方任务输出:

| DEBUG: Executing python function externalsrc_compile_prefunc
| NOTE: python-ws2812: compiling from external source tree /home/astor/Documents/poky/rpi-build/workspace/sources/python-ws2812
| DEBUG: Python function externalsrc_compile_prefunc finished
| DEBUG: Executing shell function do_compile
| scons: Reading SConscript files ...
| scons: done reading SConscript files.
| scons: Building targets ...
| CC      ws2811.o
| ws2811.c: In function 'setup_pwm':
| ws2811.c:289:23: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
|      dma_cb->dest_ad = (uint32_t)&((pwm_t *)PWM_PERIPH_PHYS)->fif1;
|                        ^
| cc1: all warnings being treated as errors
| scons: *** [ws2811.o] Error 1
| scons: building terminated because of errors.
| WARNING: /home/astor/Documents/poky/rpi-build/tmp/work/arm1176jzfshf-vfp-poky-linux-gnueabi/python-ws2812/1.0+git999-r0/temp/run.do_compile.11838:1 exit 2 from 'scons'
| ERROR: Function failed: do_compile (log file is located at /home/astor/Documents/poky/rpi-build/tmp/work/arm1176jzfshf-vfp-poky-linux-gnueabi/python-ws2812/1.0+git999-r0/temp/log.do_compile.11838)

这看起来像我的食谱:

LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://LICENSE;md5=9dcf340793a1d73c5211edc8238767dc"

SRC_URI = "git://github.com/richardghirst/rpi_ws281x.git;protocol=https"

PV = "1.0+git${SRCPV}"
SRCREV = "39afaac5f2b8b307d7d7b5f2f790fbb6759bda5e"

S = "${WORKDIR}/git"

DEPENDS = "swig-native"

inherit scons setuptools 

do_compile_prepend() {
    cd ${S}/
    scons
    ${PYTHON} ${S}/python/setup.py install
}

【问题讨论】:

    标签: raspberry-pi yocto bitbake


    【解决方案1】:
    dma_cb->dest_ad = (uint32_t)&((pwm_t *)PWM_PERIPH_PHYS)->fif1;
    

    这似乎完全符合错误所说的:将指针转换为 32 位整数。当指针是 64 位时,这是不安全的。

    您可以通过额外的强制转换(首先转换为足够大的整数)或确保使用-Wno-pointer-to-int-cast 来消除警告。但这几乎肯定是个坏主意:地址应该存储为指针,而不是 32 位整数。

    至于编译在其他地方成功的原因:我假设 raspbian 是一个 32 位操作系统(至少在 pi2 上),所以指针恰好是正确的大小。

    这当然会导致另一种解决方法:您可以构建一个 32 位的 yocto 映像。这不会使代码正确,但至少错误会消失:)

    【讨论】:

    • 感谢您的回复@jku!不幸的是,这些变通方法(将 uint32_t 更改为 uintptr_t)旨在将这些指针从 32 位更改为 64 位。配方已成功构建,但生成的 test 文件(需要更正使用此库)是 64 位的。我认为这个 scons 配置文件有问题,但另一方面,我无法通过使用 EXTRA_OESCONS 将此参数添加到 -Wno-pointer-to-int-cast scons 构建工具 - 就像这里:[cgit.openembedded.org/meta-openembedded/tree/meta-oe/….
    • 除非你真的知道你在做什么,否则不要做 no-pointer-to-int-cast cast。警告告诉你一个真正的问题,在正常情况下会破坏事情。
    • 完全同意您的意见!我的假设是否属实,Yocto 或 Scons 没有使用适当的交叉编译器来构建这些库?
    • 很抱歉我不能在这里完全关注你。我没有看到任何可能是交叉编译问题的东西,但是我真的不明白你对“测试文件”的意思......
    • 很抱歉没有详细介绍这个 test 文件,以及它是如何生成的,这个文件是由根存储库中使用的 scons 命令构建的。请检查存储库自述文件中的“运行:”部分 [github.com/jgarff/rpi_ws281x]
    猜你喜欢
    • 1970-01-01
    • 2018-11-01
    • 2021-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-12
    • 1970-01-01
    • 2016-08-07
    相关资源
    最近更新 更多