linux-kernellinux-device-driverembedded-linuxyoctoqemu

yocto project runqemu: command not found


I am setting up my yocto project, for that I have followed these below steps:

  1. download the Poky Source code (ubuntu: /yocto/source)

    $ git clone git://git.yoctoproject.org/poky
    
  2. Checkout the latest branch/release (zeus)

    $ git checkout zeus
    
  3. Step 3: Prepare the build environment (ubuntu: /yocto/source/poky)

    $ source oe-init-build-env ../../build
    

    The above script will move in a build folder and create two files in conf folder (local.conf, bblayers.conf) inside conf folder

  4. Building Linux Distribution (unbuntu: /yocto/build)

    $ bitbake core-image-minimal
    
  5. Checking the runqemu (ubuntu: /yocto/source/poky/scripts)

    $ ls runqemu   // and it is there
    
  6. Run generated image in qemu (ubuntu: /yocto/build)

    $ runqemu qemux86-64 core-image-minimal
    

other window open for qemu and image runs well.

Problem

After using the first time when I close the terminal, and use it again by running runqemu qemux86-64 core-image-minimal in /yocto/build the error pops up

runqemu: command not found

and if I write bitbake in poky directory the same error pops up

bitbake: command not found.

NOTE: I have repeat this whole process 3 times to check if the installation is not correct but i have done everything fine from my side.

yocto project hierarchy:

enter image description here


Solution

  • If you close your poky environment terminal you always MUST re-source the environment.

    The poky's oe-init-build-env setups up all commands for you, for instance:

    runqemu* commands which are present in poky/scripts.

    The script also export bitbake* commands from poky/bitbake/bin.

    The line responsible for that is in:

    # Make sure our paths are at the beginning of $PATH
    for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do
        # Remove any existences of $newpath from $PATH
        PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
    
        # Add $newpath to $PATH
        PATH="$newpath:$PATH"
    done
    

    So, always if you open new terminal:

    source /yocto/source/poky/oe-init-build-env /yoctu/build
    

    EDIT

    If you already have a build folder, make sure to provide the right path for that folder to the oe-init-build-env script.

    If you provide new path to non-existing folder, than the script will create another build for you.

    EDIT2

    To source poky environment according to your path:

    cd ~/Documents/yocto/source/poky
    source oe-init-build-env build
                               ^
                               |
    (because build is in same folder as the script)
    
    source /home/$USER/Documents/yocto/source/poky/oe-init-build-env /home/$USER/Documents/yocto/source/poky/build 
    

    THE RULE

    source <path/to/oe-init-build-env> <path/to/build/folder>
    

    If <path/to/build/folder> exists then, poky will source the existing build environment.

    If <path/to/build/folder> does not exist, poky will create new build under the same name and path.