lukaszgard
lukaszgard

Reputation: 1011

Yocto Raspberry Pi - error during installation rpi_ws281x library

I'm trying building minimal raspberry pi zero image using Yocto Project. I'm not familiar with C but I'm wondering why I get this (trivial) error during compilation 'ws2811.c' that I may successfully build (whole library) on my another raspberry pi 2 with raspbian OS without any errors. Thanks for every hints and help!

Repository:

https://github.com/jgarff/rpi_ws281x

My recipe was stuck trying to build in root (repository) location 'scons':

sudo scons

Bitbake compile recipe task output:

| 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)

And this how look like my recipe:

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
}

Upvotes: 0

Views: 527

Answers (1)

Jussi Kukkonen
Jussi Kukkonen

Reputation: 14617

dma_cb->dest_ad = (uint32_t)&((pwm_t *)PWM_PERIPH_PHYS)->fif1;

This seems to do exactly what the error says: casts a pointer to a 32 bit integer. That isn't safe when pointers are 64 bit.

You could silence the warning with an extra cast (first to a large enough integer) or by making sure you use -Wno-pointer-to-int-cast. But this would almost certainly be a bad idea: instead addresses should be stored as pointers, not 32 bit integers.

As to why the compile succeeds elsewhere: I assume raspbian is a 32bit OS (at least on pi2) so the pointers happen to be the right size by luck.

This of course leads to one more work-around: you could build a 32 bit yocto image. That doesn't make the code correct but at least the error would go away :)

Upvotes: 0

Related Questions