What is SDK in Yocto Project?

SDK ( Software Development Kit ) is a complete package which provides an environment, library and tools. you can cross-compile and build the application for your target device using SDK on the host machine.

Yocto Project SDK contains the following components

Cross Development Toolchain - it includes a cross-compiler, cross-linker, debugger and other tools.

Roots file system - SDK provides two root file systems, one for the development host and another for the target board which contains a complete root file system.

Environment setup -SDK provides an environment setup script for your host machine for cross-development.


How to generate SDK using Yocto Project

Follow the below steps to generate the SDK.

  1. Clone poky and required BSP layer like (meta-raspberrypi or meta-ti)
  2. Source the build environment using the below command and add BSP layer path in conf/bblayer.conf file.
    # set build environment
    $ source oe-init-build-env
  3. Set machine variable in conf/local.conf
    # Provide machine name in build/conf/local.conf , Example - beaglebone
    MACHINE ?= "beaglebone-yocto"
  4. Run the below command to generate SDK.
    # bitbake command for SDK generation
    $ bitbake -c populate_sdk core-image-minimal

It will generate SDK at build/tmp/deploy/sdk directory.


SDK installation and Uses

You can install the generated SDK on the host machine and build the application for your target device.

  1. Run a generated script from build/tmp/deploy/sdk directory to install SDK.
    $ cd tmp/deploy/sdk/
    $ ./poky-glibc-x86_64-core-image-minimal-cortexa8hf-neon-beaglebone-yocto-toolchain-4.1.sh

  2. Provide a path to install SDK on the host.

    Path to install SDK and follow the instructions during installation. 
    Host path example - /home/tutorialadda/sdk_install

  3. SDK environment setup on the host machine.

    Go to SDK installed directory and source environment to set up the cross-toolchain environment on the host machine.

    # SDK installed directory
    $ cd /home/tutorialadda/sdk_install
    $ ls
    # Source environment
    $ source environment-setup-cortexa8hf-neon-poky-linux-gnueabi
  4. Compile and build the Application

    Verify cross-toolchain setup using the below command.

    $ echo $CC
    arm-poky-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/tutorialadda/sdk_install/sysroots/cortexa8hf-neon-poky-linux-gnueabi

    Now create a sample hello world program and compile using $CC variable.

    //hello world sample program
    int main(){
    	printf("hello world\n");
    	return 0;
    # Compile program using $CC
    $ $CC hello.c -o hello
    # Check output binary using file command
    $ file hello
    hello: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=1c982c71ef56f0d049d3a0b3a31608f15df456fa, for GNU/Linux 3.2.0, with debug_info, not stripped

    As you see generated binary for ARM 32-bit target. so deploy and run this binary on target.

Add comment

Security code