1*4882a593Smuzhiyun.. SPDX-License-Identifier: CC-BY-SA-2.0-UK 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun***************** 4*4882a593SmuzhiyunObtaining the SDK 5*4882a593Smuzhiyun***************** 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunLocating Pre-Built SDK Installers 8*4882a593Smuzhiyun================================= 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunYou can use existing, pre-built toolchains by locating and running an 11*4882a593SmuzhiyunSDK installer script that ships with the Yocto Project. Using this 12*4882a593Smuzhiyunmethod, you select and download an architecture-specific SDK installer 13*4882a593Smuzhiyunand then run the script to hand-install the toolchain. 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunFollow these steps to locate and hand-install the toolchain: 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun1. *Go to the Installers Directory:* Go to 18*4882a593Smuzhiyun :yocto_dl:`/releases/yocto/yocto-&DISTRO;/toolchain/` 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun2. *Open the Folder for Your Build Host:* Open the folder that matches 21*4882a593Smuzhiyun your :term:`Build Host` (i.e. 22*4882a593Smuzhiyun ``i686`` for 32-bit machines or ``x86_64`` for 64-bit machines). 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun3. *Locate and Download the SDK Installer:* You need to find and 25*4882a593Smuzhiyun download the installer appropriate for your build host, target 26*4882a593Smuzhiyun hardware, and image type. 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun The installer files (``*.sh``) follow this naming convention:: 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun poky-glibc-host_system-core-image-type-arch-toolchain[-ext]-release.sh 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun Where: 33*4882a593Smuzhiyun host_system is a string representing your development system: 34*4882a593Smuzhiyun "i686" or "x86_64" 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun type is a string representing the image: 37*4882a593Smuzhiyun "sato" or "minimal" 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun arch is a string representing the target architecture: 40*4882a593Smuzhiyun "aarch64", "armv5e", "core2-64", "cortexa8hf-neon", "i586", "mips32r2", 41*4882a593Smuzhiyun "mips64", or "ppc7400" 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun release is the version of Yocto Project. 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun NOTE: 46*4882a593Smuzhiyun The standard SDK installer does not have the "-ext" string as 47*4882a593Smuzhiyun part of the filename. 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun The toolchains provided by the Yocto 51*4882a593Smuzhiyun Project are based off of the ``core-image-sato`` and 52*4882a593Smuzhiyun ``core-image-minimal`` images and contain libraries appropriate for 53*4882a593Smuzhiyun developing against those images. 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun For example, if your build host is a 64-bit x86 system and you need 56*4882a593Smuzhiyun an extended SDK for a 64-bit core2 target, go into the ``x86_64`` 57*4882a593Smuzhiyun folder and download the following installer:: 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun4. *Run the Installer:* Be sure you have execution privileges and run 62*4882a593Smuzhiyun the installer. Following is an example from the ``Downloads`` 63*4882a593Smuzhiyun directory:: 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun $ ~/Downloads/poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun During execution of the script, you choose the root location for the 68*4882a593Smuzhiyun toolchain. See the 69*4882a593Smuzhiyun ":ref:`sdk-manual/appendix-obtain:installed standard sdk directory structure`" 70*4882a593Smuzhiyun section and the 71*4882a593Smuzhiyun ":ref:`sdk-manual/appendix-obtain:installed extensible sdk directory structure`" 72*4882a593Smuzhiyun section for more information. 73*4882a593Smuzhiyun 74*4882a593SmuzhiyunBuilding an SDK Installer 75*4882a593Smuzhiyun========================= 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunAs an alternative to locating and downloading an SDK installer, you can 78*4882a593Smuzhiyunbuild the SDK installer. Follow these steps: 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun1. *Set Up the Build Environment:* Be sure you are set up to use BitBake 81*4882a593Smuzhiyun in a shell. See the ":ref:`dev-manual/start:preparing the build host`" section 82*4882a593Smuzhiyun in the Yocto Project Development Tasks Manual for information on how 83*4882a593Smuzhiyun to get a build host ready that is either a native Linux machine or a 84*4882a593Smuzhiyun machine that uses CROPS. 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun2. *Clone the ``poky`` Repository:* You need to have a local copy of the 87*4882a593Smuzhiyun Yocto Project :term:`Source Directory` 88*4882a593Smuzhiyun (i.e. a local 89*4882a593Smuzhiyun ``poky`` repository). See the ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`" and 90*4882a593Smuzhiyun possibly the ":ref:`dev-manual/start:checking out by branch in poky`" and 91*4882a593Smuzhiyun ":ref:`dev-manual/start:checking out by tag in poky`" sections 92*4882a593Smuzhiyun all in the Yocto Project Development Tasks Manual for information on 93*4882a593Smuzhiyun how to clone the ``poky`` repository and check out the appropriate 94*4882a593Smuzhiyun branch for your work. 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun3. *Initialize the Build Environment:* While in the root directory of 97*4882a593Smuzhiyun the Source Directory (i.e. ``poky``), run the 98*4882a593Smuzhiyun :ref:`structure-core-script` environment 99*4882a593Smuzhiyun setup script to define the OpenEmbedded build environment on your 100*4882a593Smuzhiyun build host. 101*4882a593Smuzhiyun :: 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun $ source oe-init-build-env 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun Among other things, the script 106*4882a593Smuzhiyun creates the :term:`Build Directory`, 107*4882a593Smuzhiyun which is 108*4882a593Smuzhiyun ``build`` in this case and is located in the Source Directory. After 109*4882a593Smuzhiyun the script runs, your current working directory is set to the 110*4882a593Smuzhiyun ``build`` directory. 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun4. *Make Sure You Are Building an Installer for the Correct Machine:* 113*4882a593Smuzhiyun Check to be sure that your 114*4882a593Smuzhiyun :term:`MACHINE` variable in the 115*4882a593Smuzhiyun ``local.conf`` file in your Build Directory matches the architecture 116*4882a593Smuzhiyun for which you are building. 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun5. *Make Sure Your SDK Machine is Correctly Set:* If you are building a 119*4882a593Smuzhiyun toolchain designed to run on an architecture that differs from your 120*4882a593Smuzhiyun current development host machine (i.e. the build host), be sure that 121*4882a593Smuzhiyun the :term:`SDKMACHINE` variable 122*4882a593Smuzhiyun in the ``local.conf`` file in your Build Directory is correctly set. 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun .. note:: 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun If you are building an SDK installer for the Extensible SDK, the 127*4882a593Smuzhiyun SDKMACHINE 128*4882a593Smuzhiyun value must be set for the architecture of the machine you are 129*4882a593Smuzhiyun using to build the installer. If 130*4882a593Smuzhiyun SDKMACHINE 131*4882a593Smuzhiyun is not set appropriately, the build fails and provides an error 132*4882a593Smuzhiyun message similar to the following:: 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun The extensible SDK can currently only be built for the same architecture as the machine being built on - SDK_ARCH is 135*4882a593Smuzhiyun set to i686 (likely via setting SDKMACHINE) which is different from the architecture of the build machine (x86_64). 136*4882a593Smuzhiyun Unable to continue. 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun6. *Build the SDK Installer:* To build the SDK installer for a standard 140*4882a593Smuzhiyun SDK and populate the SDK image, use the following command form. Be 141*4882a593Smuzhiyun sure to replace ``image`` with an image (e.g. "core-image-sato"):: 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun $ bitbake image -c populate_sdk 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun You can do the same for the extensible SDK using this command form:: 146*4882a593Smuzhiyun 147*4882a593Smuzhiyun $ bitbake image -c populate_sdk_ext 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun These commands produce an SDK installer that contains the sysroot 150*4882a593Smuzhiyun that matches your target root filesystem. 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun When the ``bitbake`` command completes, the SDK installer will be in 153*4882a593Smuzhiyun ``tmp/deploy/sdk`` in the Build Directory. 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun .. note:: 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun - By default, the previous BitBake command does not build static 158*4882a593Smuzhiyun binaries. If you want to use the toolchain to build these types 159*4882a593Smuzhiyun of libraries, you need to be sure your SDK has the appropriate 160*4882a593Smuzhiyun static development libraries. Use the 161*4882a593Smuzhiyun :term:`TOOLCHAIN_TARGET_TASK` 162*4882a593Smuzhiyun variable inside your ``local.conf`` file before building the 163*4882a593Smuzhiyun SDK installer. Doing so ensures that the eventual SDK 164*4882a593Smuzhiyun installation process installs the appropriate library packages 165*4882a593Smuzhiyun as part of the SDK. Following is an example using ``libc`` 166*4882a593Smuzhiyun static development libraries: TOOLCHAIN_TARGET_TASK:append = " 167*4882a593Smuzhiyun libc-staticdev" 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun7. *Run the Installer:* You can now run the SDK installer from 170*4882a593Smuzhiyun ``tmp/deploy/sdk`` in the Build Directory. Following is an example:: 171*4882a593Smuzhiyun 172*4882a593Smuzhiyun $ cd poky/build/tmp/deploy/sdk 173*4882a593Smuzhiyun $ ./poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh 174*4882a593Smuzhiyun 175*4882a593Smuzhiyun During execution of the script, you choose the root location for the 176*4882a593Smuzhiyun toolchain. See the 177*4882a593Smuzhiyun ":ref:`sdk-manual/appendix-obtain:installed standard sdk directory structure`" 178*4882a593Smuzhiyun section and the 179*4882a593Smuzhiyun ":ref:`sdk-manual/appendix-obtain:installed extensible sdk directory structure`" 180*4882a593Smuzhiyun section for more information. 181*4882a593Smuzhiyun 182*4882a593SmuzhiyunExtracting the Root Filesystem 183*4882a593Smuzhiyun============================== 184*4882a593Smuzhiyun 185*4882a593SmuzhiyunAfter installing the toolchain, for some use cases you might need to 186*4882a593Smuzhiyunseparately extract a root filesystem: 187*4882a593Smuzhiyun 188*4882a593Smuzhiyun- You want to boot the image using NFS. 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun- You want to use the root filesystem as the target sysroot. 191*4882a593Smuzhiyun 192*4882a593Smuzhiyun- You want to develop your target application using the root filesystem 193*4882a593Smuzhiyun as the target sysroot. 194*4882a593Smuzhiyun 195*4882a593SmuzhiyunFollow these steps to extract the root filesystem: 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun1. *Locate and Download the Tarball for the Pre-Built Root Filesystem 198*4882a593Smuzhiyun Image File:* You need to find and download the root filesystem image 199*4882a593Smuzhiyun file that is appropriate for your target system. These files are kept 200*4882a593Smuzhiyun in machine-specific folders in the 201*4882a593Smuzhiyun :yocto_dl:`Index of Releases </releases/yocto/yocto-&DISTRO;/machines/>` 202*4882a593Smuzhiyun in the "machines" directory. 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun The machine-specific folders of the "machines" directory contain 205*4882a593Smuzhiyun tarballs (``*.tar.bz2``) for supported machines. These directories 206*4882a593Smuzhiyun also contain flattened root filesystem image files (``*.ext4``), 207*4882a593Smuzhiyun which you can use with QEMU directly. 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun The pre-built root filesystem image files follow these naming 210*4882a593Smuzhiyun conventions:: 211*4882a593Smuzhiyun 212*4882a593Smuzhiyun core-image-profile-arch.tar.bz2 213*4882a593Smuzhiyun 214*4882a593Smuzhiyun Where: 215*4882a593Smuzhiyun profile is the filesystem image's profile: 216*4882a593Smuzhiyun lsb, lsb-dev, lsb-sdk, minimal, minimal-dev, minimal-initramfs, 217*4882a593Smuzhiyun sato, sato-dev, sato-sdk, sato-sdk-ptest. For information on 218*4882a593Smuzhiyun these types of image profiles, see the "Images" chapter in 219*4882a593Smuzhiyun the Yocto Project Reference Manual. 220*4882a593Smuzhiyun 221*4882a593Smuzhiyun arch is a string representing the target architecture: 222*4882a593Smuzhiyun beaglebone-yocto, beaglebone-yocto-lsb, edgerouter, edgerouter-lsb, 223*4882a593Smuzhiyun genericx86, genericx86-64, genericx86-64-lsb, genericx86-lsb and qemu*. 224*4882a593Smuzhiyun 225*4882a593Smuzhiyun The root filesystems 226*4882a593Smuzhiyun provided by the Yocto Project are based off of the 227*4882a593Smuzhiyun ``core-image-sato`` and ``core-image-minimal`` images. 228*4882a593Smuzhiyun 229*4882a593Smuzhiyun For example, if you plan on using a BeagleBone device as your target 230*4882a593Smuzhiyun hardware and your image is a ``core-image-sato-sdk`` image, you can 231*4882a593Smuzhiyun download the following file:: 232*4882a593Smuzhiyun 233*4882a593Smuzhiyun core-image-sato-sdk-beaglebone-yocto.tar.bz2 234*4882a593Smuzhiyun 235*4882a593Smuzhiyun2. *Initialize the Cross-Development Environment:* You must ``source`` 236*4882a593Smuzhiyun the cross-development environment setup script to establish necessary 237*4882a593Smuzhiyun environment variables. 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun This script is located in the top-level directory in which you 240*4882a593Smuzhiyun installed the toolchain (e.g. ``poky_sdk``). 241*4882a593Smuzhiyun 242*4882a593Smuzhiyun Following is an example based on the toolchain installed in the 243*4882a593Smuzhiyun ":ref:`sdk-manual/appendix-obtain:locating pre-built sdk installers`" section:: 244*4882a593Smuzhiyun 245*4882a593Smuzhiyun $ source poky_sdk/environment-setup-core2-64-poky-linux 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun3. *Extract the Root Filesystem:* Use the ``runqemu-extract-sdk`` 248*4882a593Smuzhiyun command and provide the root filesystem image. 249*4882a593Smuzhiyun 250*4882a593Smuzhiyun Following is an example command that extracts the root filesystem 251*4882a593Smuzhiyun from a previously built root filesystem image that was downloaded 252*4882a593Smuzhiyun from the :yocto_dl:`Index of Releases </releases/yocto/yocto-&DISTRO;/machines/>`. 253*4882a593Smuzhiyun This command extracts the root filesystem into the ``core2-64-sato`` 254*4882a593Smuzhiyun directory:: 255*4882a593Smuzhiyun 256*4882a593Smuzhiyun $ runqemu-extract-sdk ~/Downloads/core-image-sato-sdk-beaglebone-yocto.tar.bz2 ~/beaglebone-sato 257*4882a593Smuzhiyun 258*4882a593Smuzhiyun You could now point to the target sysroot at ``beaglebone-sato``. 259*4882a593Smuzhiyun 260*4882a593SmuzhiyunInstalled Standard SDK Directory Structure 261*4882a593Smuzhiyun========================================== 262*4882a593Smuzhiyun 263*4882a593SmuzhiyunThe following figure shows the resulting directory structure after you 264*4882a593Smuzhiyuninstall the Standard SDK by running the ``*.sh`` SDK installation 265*4882a593Smuzhiyunscript: 266*4882a593Smuzhiyun 267*4882a593Smuzhiyun.. image:: figures/sdk-installed-standard-sdk-directory.png 268*4882a593Smuzhiyun :scale: 80% 269*4882a593Smuzhiyun :align: center 270*4882a593Smuzhiyun 271*4882a593SmuzhiyunThe installed SDK consists of an environment setup script for the SDK, a 272*4882a593Smuzhiyunconfiguration file for the target, a version file for the target, and 273*4882a593Smuzhiyunthe root filesystem (``sysroots``) needed to develop objects for the 274*4882a593Smuzhiyuntarget system. 275*4882a593Smuzhiyun 276*4882a593SmuzhiyunWithin the figure, italicized text is used to indicate replaceable 277*4882a593Smuzhiyunportions of the file or directory name. For example, install_dir/version 278*4882a593Smuzhiyunis the directory where the SDK is installed. By default, this directory 279*4882a593Smuzhiyunis ``/opt/poky/``. And, version represents the specific snapshot of the 280*4882a593SmuzhiyunSDK (e.g. &DISTRO;). Furthermore, target represents the target architecture 281*4882a593Smuzhiyun(e.g. ``i586``) and host represents the development system's 282*4882a593Smuzhiyunarchitecture (e.g. ``x86_64``). Thus, the complete names of the two 283*4882a593Smuzhiyundirectories within the ``sysroots`` could be ``i586-poky-linux`` and 284*4882a593Smuzhiyun``x86_64-pokysdk-linux`` for the target and host, respectively. 285*4882a593Smuzhiyun 286*4882a593SmuzhiyunInstalled Extensible SDK Directory Structure 287*4882a593Smuzhiyun============================================ 288*4882a593Smuzhiyun 289*4882a593SmuzhiyunThe following figure shows the resulting directory structure after you 290*4882a593Smuzhiyuninstall the Extensible SDK by running the ``*.sh`` SDK installation 291*4882a593Smuzhiyunscript: 292*4882a593Smuzhiyun 293*4882a593Smuzhiyun.. image:: figures/sdk-installed-extensible-sdk-directory.png 294*4882a593Smuzhiyun :scale: 80% 295*4882a593Smuzhiyun :align: center 296*4882a593Smuzhiyun 297*4882a593SmuzhiyunThe installed directory structure for the extensible SDK is quite 298*4882a593Smuzhiyundifferent than the installed structure for the standard SDK. The 299*4882a593Smuzhiyunextensible SDK does not separate host and target parts in the same 300*4882a593Smuzhiyunmanner as does the standard SDK. The extensible SDK uses an embedded 301*4882a593Smuzhiyuncopy of the OpenEmbedded build system, which has its own sysroots. 302*4882a593Smuzhiyun 303*4882a593SmuzhiyunOf note in the directory structure are an environment setup script for 304*4882a593Smuzhiyunthe SDK, a configuration file for the target, a version file for the 305*4882a593Smuzhiyuntarget, and log files for the OpenEmbedded build system preparation 306*4882a593Smuzhiyunscript run by the installer and BitBake. 307*4882a593Smuzhiyun 308*4882a593SmuzhiyunWithin the figure, italicized text is used to indicate replaceable 309*4882a593Smuzhiyunportions of the file or directory name. For example, install_dir is the 310*4882a593Smuzhiyundirectory where the SDK is installed, which is ``poky_sdk`` by default, 311*4882a593Smuzhiyunand target represents the target architecture (e.g. ``i586``). 312