raspberry-pi3yoctosconsmeta-raspberrypi

Yocto recipe problem with scons and ws281x on Raspberry Pi 3B+


I've got a problem creating a yocto (thud) recipe for the rpi_ws281x python module. The machine itself is a raspberrypi3.

While building the recipe I get the following error:

NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: python-rpi-ws281x-1.0-r0 do_compile: Function failed: do_compile (log file is located at /home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/temp/log.do_compile.48175)
ERROR: Logfile of failure stored in: /home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/temp/log.do_compile.48175
Log data follows:
| DEBUG: Executing shell function do_compile
| scons: Reading SConscript files ...
| scons: done reading SConscript files.
| scons: Building targets ...
| Version version.h
| CC      main.o
| CC      mailbox.o
| CC      ws2811.o
| CC      pwm.o
| CC      pcm.o
| CC      dma.o
| CC      rpihw.o
| AR      libws2811.a
| RANLIB  libws2811.a
| LINK    test
| scons: done building targets.
| running install
| running bdist_egg
| running egg_info
| creating rpi_ws281x.egg-info
| writing rpi_ws281x.egg-info/PKG-INFO
| writing top-level names to rpi_ws281x.egg-info/top_level.txt
| writing dependency_links to rpi_ws281x.egg-info/dependency_links.txt
| writing manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
| reading manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
| writing manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
| installing library code to build/bdist.linux-x86_64/egg
| running install_lib
| running build_py
| creating build
| creating build/lib.linux-x86_64-2.7
| copying neopixel.py -> build/lib.linux-x86_64-2.7
| running build_ext
| building '_rpi_ws281x' extension
| swigging rpi_ws281x.i to rpi_ws281x_wrap.c
| swig -python -o rpi_ws281x_wrap.c rpi_ws281x.i
| creating build/temp.linux-x86_64-2.7
| arm-ab-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/recipe-sysroot -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0=/usr/src/debug/python-rpi-ws281x/1.0-r0 -fdebug-prefix-map=/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/recipe-sysroot= -fdebug-prefix-map=/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/recipe-sysroot-native= -fPIC -I/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/recipe-sysroot/usr/include/python2.7 -c rpi_ws281x_wrap.c -o build/temp.linux-x86_64-2.7/rpi_ws281x_wrap.o
| arm-ab-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/recipe-sysroot -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0=/usr/src/debug/python-rpi-ws281x/1.0-r0 -fdebug-prefix-map=/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/recipe-sysroot= -fdebug-prefix-map=/home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/recipe-sysroot-native= build/temp.linux-x86_64-2.7/rpi_ws281x_wrap.o -L../. -lws2811 -lrt -o build/lib.linux-x86_64-2.7/_rpi_ws281x.so
| /home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/recipe-sysroot-native/usr/bin/arm-ab-linux-gnueabi/../../libexec/arm-ab-linux-gnueabi/gcc/arm-ab-linux-gnueabi/8.2.0/ld: .././libws2811.a: error adding symbols: file format not recognized
| collect2: error: ld returned 1 exit status
| error: command 'arm-ab-linux-gnueabi-gcc' failed with exit status 1
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_compile (log file is located at /home/user/git/poky-ab/build/tmp/work/cortexa7t2hf-neon-vfpv4-ab-linux-gnueabi/python-rpi-ws281x/1.0-r0/temp/log.do_compile.48175)
ERROR: Task (/home/user/git/poky-ab/meta-3rdparty/recipes-ws281x/python-rpi-ws281x.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 1125 tasks of which 1118 didn't need to be rerun and 1 failed.
NOTE: Writing buildhistory

Summary: 1 task failed:
  /home/user/git/poky-ab/meta-3rdparty/recipes-ws281x/python-rpi-ws281x.bb:do_compile
Summary: There was 1 ERROR message shown, returning a non-zero exit code.

The recipe itself looks like this:

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

SRC_URI = "git://github.com/jgarff/rpi_ws281x.git;protocol=https"
SRC_URI[md5sum] = "b903b8342864ae8422039d4a7479ba4c"

SRCREV = "ba3b5bdad55dc7754567a68c4364b1e772735f47"

#DEPENDS += "python-setuptools-native swig-native python-scons-native"
DEPENDS += "swig-native python-scons"
RDEPENDS_${PN} = "python"

S = "${WORKDIR}/git"

inherit scons setuptools 

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

What I'm wondering about is that scons creates some binary code for linux-x86_64. Is there any possibility that I can convice scons to use the exported Environment of Yocto?

Thanks in advance,

homer836


Solution

  • Now it works. I fixed the SContruct, created a patch and used the following recipe.

    SConstruct:

    #
    # SConstruct
    #
    # Copyright (c) 2014 Jeremy Garff <jer @ jers.net>
    #
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without modification, are permitted
    # provided that the following conditions are met:
    #
    #     1.  Redistributions of source code must retain the above copyright notice, this list of
    #         conditions and the following disclaimer.
    #     2.  Redistributions in binary form must reproduce the above copyright notice, this list
    #         of conditions and the following disclaimer in the documentation and/or other materials
    #         provided with the distribution.
    #     3.  Neither the name of the owner nor the names of its contributors may be used to endorse
    #         or promote products derived from this software without specific prior written permission.
    # 
    # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
    # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    #
    
    
    import os
    
    
    opts = Variables()
    opts.Add(BoolVariable('V',
                          'Verbose build',
                          True))
    
    opts.Add('TOOLCHAIN',
             'Set toolchain for cross compilation (e.g. arm-linux-gnueabihf)',
             '')
    
    platforms = [ 
        [
            'userspace',            # Target Name
            [ 'linux', 'version' ], # Scons tool (linux, avr, etc.)
            {                       # Special environment setup
                'LINKFLAGS' : [
                    "-lrt",
                ],
            },
        ], 
    ]
    
    cc_environment = os.environ['CC']
    split_cc_environment_variable = cc_environment.split()
    cc_bin = split_cc_environment_variable[0]
    cc_parameters = split_cc_environment_variable[1:]
    
    ld_env = os.environ['LD']
    split_ld_env_variable = ld_env.split()
    ld_bin = split_ld_env_variable[0]
    ld_params = split_ld_env_variable[1:]
    
    clean_envs = {}
    for platform, tool, flags in platforms:
        env = Environment(
               options = opts,
               tools = tool,
               toolpath = ['.'],
               ENV = {'PATH' : os.environ['PATH']},
           CC = cc_bin,
               LD = ld_bin,
               AR = os.environ['AR'],
               RANLIB = os.environ['RANLIB'],
               CCFLAGS = cc_parameters,
               LINKFLAGS = ld_params,
            LIBS = [],
        )
    
        env.MergeFlags(flags)
        clean_envs[platform] = env
    
    Help(opts.GenerateHelpText(clean_envs))
    
    
    Export(['clean_envs'])
    SConscript('SConscript');
    

    Recipe:

    LICENSE = "BSD"
    LIC_FILES_CHKSUM = "file://LICENSE;md5=9dcf340793a1d73c5211edc8238767dc"
    
    SRC_URI = "git://github.com/jgarff/rpi_ws281x.git;protocol=https \
               file://0001-Patch-for-Yocto.patch"
    
    SRC_URI[md5sum] = "b903b8342864ae8422039d4a7479ba4c"
    
    SRCREV = "ba3b5bdad55dc7754567a68c4364b1e772735f47"
    
    DEPENDS += "swig-native python-scons"
    RDEPENDS_${PN} = "python"
    
    S = "${WORKDIR}/git"
    
    inherit scons setuptools 
    
    EXTRA_OESCONS += " CONFIG_ENVIRONMENT_IMPORT=True -mfl"
    
    do_compile_prepend() {
    
    export
    
        cd ${S}/
        scons
        cd ${S}/python/
        ${PYTHON} setup.py build
        ${PYTHON} setup.py install
    }
    
    do_install() {
        install -d ${D}${libdir}/python2.7
        cp ${S}/python/build/lib.linux-x86_64-2.7/* ${D}${libdir}/python2.7/
    }
    
    FILES_${PN} += "${libdir}/python2.7/"