0

I am running Ubuntu 16.04 with Xilinx Petalinux 2018.03 SDK. After a number of successful compilations I am now facing this error

$ petalinux-build
[INFO] building project
[INFO] sourcing bitbake
ERROR: Failed to source bitbake
ERROR: Failed to build project

How can I solved this issue?

Mickael T
  • 895
  • 2
  • 8
  • 19

2 Answers2

2

Another reason to get the errors "ERROR: Failed to source bitbake" as well as "ERROR: Failed to build project" is a possible upgrade of Python on the build machine. The Petalinux SDK requires python v2 (>= 2.7.3) for the 2018.3 edition.

You can check under [YOUR_PROJECT]/build/build.log and you might see a log similar to this one below:

[INFO] building project
[INFO] sourcing bitbake
SDK environment now set up; additionally you may now run devtool to perform development tasks.
Run devtool --help for further details.
OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3.
Please set up python v2 as your default 'python' interpreter.
ERROR: Failed to source bitbake
ERROR: Failed to build project

To remedy this issue remove the symbolic link under /usr/bin and make sure to create a new one that is pointing to Python 2.7:

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python
Mickael T
  • 895
  • 2
  • 8
  • 19
  • I also had this issue, however, I used an virtual environment to solve my problem. I detailed my answer in this Xilinx Community Post: https://support.xilinx.com/s/question/0D52E00006iHv3gSAC/petalinux-20172-failed-to-source-bitbake. – Vandrey Jan 26 '22 at 13:23
1

First you need to investigate the error a little further, do this:

source /opt/pkg/petalinux/2018.3/settings.sh

It will return something similar to this below:

PetaLinux environment set to '/opt/pkg/petalinux/2018.3'
INFO: Checking free disk space
INFO: Checking installed tools
INFO: Checking installed development libraries
INFO: Checking network and other services

Source the environment setup:

source /opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/environment-setup-aarch64-xilinx-linux

followed by:

devtool --help

In my case I can see more about the actual error:

NOTE: Starting bitbake server...
ERROR: Unable to start bitbake server
ERROR: Last 10 lines of server log for this session (/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/bitbake-cookerdaemon.log):
Traceback (most recent call last):
  File "/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/layers/core/bitbake/lib/bb/daemonize.py", line 77, in createDaemon
    function()
  File "/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/layers/core/bitbake/lib/bb/server/process.py", line 433, in _startServer
    self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset)
  File "/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/layers/core/bitbake/lib/bb/cooker.py", line 178, in __init__
    self.configwatcher = pyinotify.WatchManager()
  File "/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/layers/core/bitbake/lib/pyinotify.py", line 1764, in __init__
    raise OSError(err % self._inotify_wrapper.str_errno())
OSError: Cannot initialize new instance of inotify, Errno=Too many open files (EMFILE)

ERROR: Unable to start bitbake server
ERROR: Last 10 lines of server log for this session (/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/bitbake-cookerdaemon.log):
Traceback (most recent call last):
  File "/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/layers/core/bitbake/lib/bb/daemonize.py", line 77, in createDaemon
    function()
  File "/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/layers/core/bitbake/lib/bb/server/process.py", line 433, in _startServer
    self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset)
  File "/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/layers/core/bitbake/lib/bb/cooker.py", line 178, in __init__
    self.configwatcher = pyinotify.WatchManager()
  File "/opt/pkg/petalinux/2018.3/components/yocto/source/aarch64/layers/core/bitbake/lib/pyinotify.py", line 1764, in __init__
    raise OSError(err % self._inotify_wrapper.str_errno())
OSError: Cannot initialize new instance of inotify, **Errno=Too many open files (EMFILE)**

This is pointing to the /proc/sys/fs/inotify/max_user_instances that need to be increased. In my case I went from 128 to 256 by doing this:

sudo su 
echo 256 > /proc/sys/fs/inotify/max_user_instances

You need to become root with "su" and change the mac_user_instances.

Mickael T
  • 895
  • 2
  • 8
  • 19