2017-04-25 204 views
0

我正在尝试使用Yocto项目构建最小树莓派pi零图像。我对C不熟悉,但我想知道为什么在编译'ws2811.c'时我得到了这个(微不足道的)错误,我可以用raspbian OS在另一个raspberry pi 2上成功构建(整个库),没有任何错误。感谢每一个提示和帮助!Yocto Raspberry Pi - 安装过程中的错误rpi_ws281x库

库:

https://github.com/jgarff/rpi_ws281x 

我的食谱被卡住试图根建(库)的位置 '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 
} 

回答

0
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图像。这不会使代码正确,但至少错误会消失:)

+0

感谢您的回复@jku!不幸的是,这些解决方法(将uint32_t **更改为uintptr_t **)旨在将这些指针从32位更改为64位。配方成功构建,但生成**测试**文件(这是需要纠正使用此库)是64位。我认为这是scons配置文件的错误,但另一方面,我不能通过使用** EXTRA_OESCONS **这个参数添加到** - Wno-pointer-to-int-cast ** scons构建工具 - 只是像这里:[http://cgit.openembedded.org/meta-openembedded/tree/meta-oe/recipes-support/mongodb/mongodb_git.bb?h=master]。 – astor555

+0

除非你真的知道你在做什么,否则不要做无指针到整型投射。警告告诉你一个真正的问题,在正常情况下会破坏事情。 – jku

+0

完全同意你的意见!我的假设是否属实,Yocto或Scons没有使用适当的交叉编译器来构建这些库? – astor555