blob: ad531cbf24d153a799de7b05a1b8d7df88eabae6 [file] [log] [blame]
Andrew Geisslerf0343792020-11-18 10:42:21 -06001.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002
3*****************
4Obtaining the SDK
5*****************
6
Patrick Williams92b42cb2022-09-03 06:53:57 -05007Working with the SDK components directly in a Yocto build
8=========================================================
9
10Please refer to section
11":ref:`sdk-manual/extensible:Setting up the Extensible SDK environment directly in a Yocto build`"
12
13Note that to use this feature effectively either a powerful build
14machine, or a well-functioning sstate cache infrastructure is required:
15otherwise significant time could be spent waiting for components to be built
16by BitBake from source code.
17
18Working with standalone SDK Installers
19======================================
20
Andrew Geisslerc9f78652020-09-18 14:11:35 -050021Locating Pre-Built SDK Installers
Patrick Williams92b42cb2022-09-03 06:53:57 -050022---------------------------------
Andrew Geisslerc9f78652020-09-18 14:11:35 -050023
24You can use existing, pre-built toolchains by locating and running an
25SDK installer script that ships with the Yocto Project. Using this
26method, you select and download an architecture-specific SDK installer
27and then run the script to hand-install the toolchain.
28
29Follow these steps to locate and hand-install the toolchain:
30
Andrew Geissler517393d2023-01-13 08:55:19 -060031#. *Go to the Installers Directory:* Go to
Andrew Geissler09209ee2020-12-13 08:44:15 -060032 :yocto_dl:`/releases/yocto/yocto-&DISTRO;/toolchain/`
Andrew Geisslerc9f78652020-09-18 14:11:35 -050033
Andrew Geissler517393d2023-01-13 08:55:19 -060034#. *Open the Folder for Your Build Host:* Open the folder that matches
Andrew Geisslerc9f78652020-09-18 14:11:35 -050035 your :term:`Build Host` (i.e.
36 ``i686`` for 32-bit machines or ``x86_64`` for 64-bit machines).
37
Andrew Geissler517393d2023-01-13 08:55:19 -060038#. *Locate and Download the SDK Installer:* You need to find and
Andrew Geisslerc9f78652020-09-18 14:11:35 -050039 download the installer appropriate for your build host, target
40 hardware, and image type.
41
Patrick Williamsac13d5f2023-11-24 18:59:46 -060042 The installer files (``*.sh``) follow this naming convention:
43 ``poky-glibc-host_system-core-image-type-arch-toolchain[-ext]-release.sh``:
Andrew Geisslerc9f78652020-09-18 14:11:35 -050044
Patrick Williamsac13d5f2023-11-24 18:59:46 -060045 - ``host_system``: string representing your development system: ``i686`` or ``x86_64``
Andrew Geisslerc9f78652020-09-18 14:11:35 -050046
Patrick Williamsac13d5f2023-11-24 18:59:46 -060047 - ``type``: string representing the image: ``sato`` or ``minimal``
Andrew Geisslerc9f78652020-09-18 14:11:35 -050048
Patrick Williamsac13d5f2023-11-24 18:59:46 -060049 - ``arch``: string representing the target architecture such as ``cortexa57-qemuarm64``
Andrew Geisslerc9f78652020-09-18 14:11:35 -050050
Patrick Williamsac13d5f2023-11-24 18:59:46 -060051 - ``release``: version of the Yocto Project.
Andrew Geisslerc9f78652020-09-18 14:11:35 -050052
Patrick Williamsac13d5f2023-11-24 18:59:46 -060053 .. note::
54 The standard SDK installer does not have the ``-ext`` string as
55 part of the filename.
Andrew Geisslerc9f78652020-09-18 14:11:35 -050056
57 The toolchains provided by the Yocto
58 Project are based off of the ``core-image-sato`` and
59 ``core-image-minimal`` images and contain libraries appropriate for
60 developing against those images.
61
62 For example, if your build host is a 64-bit x86 system and you need
Patrick Williamsac13d5f2023-11-24 18:59:46 -060063 an extended SDK for a 64-bit core2 QEMU target, go into the ``x86_64``
Andrew Geisslerc926e172021-05-07 16:11:35 -050064 folder and download the following installer::
Andrew Geisslerc9f78652020-09-18 14:11:35 -050065
Patrick Williamsac13d5f2023-11-24 18:59:46 -060066 poky-glibc-x86_64-core-image-sato-core2-64-qemux86-64-toolchain-&DISTRO;.sh
Andrew Geisslerc9f78652020-09-18 14:11:35 -050067
Andrew Geissler517393d2023-01-13 08:55:19 -060068#. *Run the Installer:* Be sure you have execution privileges and run
Andrew Geisslerc9f78652020-09-18 14:11:35 -050069 the installer. Following is an example from the ``Downloads``
Andrew Geisslerc926e172021-05-07 16:11:35 -050070 directory::
Andrew Geisslerc9f78652020-09-18 14:11:35 -050071
Patrick Williamsac13d5f2023-11-24 18:59:46 -060072 $ ~/Downloads/poky-glibc-x86_64-core-image-sato-core2-64-qemux86-64-toolchain-&DISTRO;.sh
Andrew Geisslerc9f78652020-09-18 14:11:35 -050073
74 During execution of the script, you choose the root location for the
Andrew Geissler3b8a17c2021-04-15 15:55:55 -050075 toolchain. See the
76 ":ref:`sdk-manual/appendix-obtain:installed standard sdk directory structure`"
77 section and the
78 ":ref:`sdk-manual/appendix-obtain:installed extensible sdk directory structure`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -050079 section for more information.
80
81Building an SDK Installer
Patrick Williams92b42cb2022-09-03 06:53:57 -050082-------------------------
Andrew Geisslerc9f78652020-09-18 14:11:35 -050083
84As an alternative to locating and downloading an SDK installer, you can
85build the SDK installer. Follow these steps:
86
Andrew Geissler517393d2023-01-13 08:55:19 -060087#. *Set Up the Build Environment:* Be sure you are set up to use BitBake
Andrew Geissler09209ee2020-12-13 08:44:15 -060088 in a shell. See the ":ref:`dev-manual/start:preparing the build host`" section
Andrew Geisslerc9f78652020-09-18 14:11:35 -050089 in the Yocto Project Development Tasks Manual for information on how
90 to get a build host ready that is either a native Linux machine or a
91 machine that uses CROPS.
92
Andrew Geissler517393d2023-01-13 08:55:19 -060093#. *Clone the ``poky`` Repository:* You need to have a local copy of the
Andrew Geisslerc9f78652020-09-18 14:11:35 -050094 Yocto Project :term:`Source Directory`
95 (i.e. a local
Andrew Geissler09209ee2020-12-13 08:44:15 -060096 ``poky`` repository). See the ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`" and
97 possibly the ":ref:`dev-manual/start:checking out by branch in poky`" and
98 ":ref:`dev-manual/start:checking out by tag in poky`" sections
Andrew Geisslerc9f78652020-09-18 14:11:35 -050099 all in the Yocto Project Development Tasks Manual for information on
100 how to clone the ``poky`` repository and check out the appropriate
101 branch for your work.
102
Andrew Geissler517393d2023-01-13 08:55:19 -0600103#. *Initialize the Build Environment:* While in the root directory of
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500104 the Source Directory (i.e. ``poky``), run the
105 :ref:`structure-core-script` environment
106 setup script to define the OpenEmbedded build environment on your
Andrew Geissler517393d2023-01-13 08:55:19 -0600107 build host::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500108
109 $ source oe-init-build-env
110
Patrick Williams2390b1b2022-11-03 13:47:49 -0500111 Among other things, the script creates the :term:`Build Directory`, which
112 is ``build`` in this case and is located in the Source Directory. After
113 the script runs, your current working directory is set to the ``build``
114 directory.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500115
Andrew Geissler517393d2023-01-13 08:55:19 -0600116#. *Make Sure You Are Building an Installer for the Correct Machine:*
Patrick Williams2390b1b2022-11-03 13:47:49 -0500117 Check to be sure that your :term:`MACHINE` variable in the ``local.conf``
118 file in your :term:`Build Directory` matches the architecture
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500119 for which you are building.
120
Andrew Geissler517393d2023-01-13 08:55:19 -0600121#. *Make Sure Your SDK Machine is Correctly Set:* If you are building a
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500122 toolchain designed to run on an architecture that differs from your
123 current development host machine (i.e. the build host), be sure that
Patrick Williams2390b1b2022-11-03 13:47:49 -0500124 the :term:`SDKMACHINE` variable in the ``local.conf`` file in your
125 :term:`Build Directory` is correctly set.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500126
127 .. note::
128
129 If you are building an SDK installer for the Extensible SDK, the
Patrick Williams2390b1b2022-11-03 13:47:49 -0500130 :term:`SDKMACHINE` value must be set for the architecture of the
131 machine you are using to build the installer. If :term:`SDKMACHINE`
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500132 is not set appropriately, the build fails and provides an error
Andrew Geisslerc926e172021-05-07 16:11:35 -0500133 message similar to the following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500134
Patrick Williams2390b1b2022-11-03 13:47:49 -0500135 The extensible SDK can currently only be built for the same
Patrick Williams2a254922023-08-11 09:48:11 -0500136 architecture as the machine being built on - SDK_ARCH
137 is set to i686 (likely via setting SDKMACHINE) which is
138 different from the architecture of the build machine (x86_64).
139 Unable to continue.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500140
141
Andrew Geissler517393d2023-01-13 08:55:19 -0600142#. *Build the SDK Installer:* To build the SDK installer for a standard
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500143 SDK and populate the SDK image, use the following command form. Be
Andrew Geisslerc926e172021-05-07 16:11:35 -0500144 sure to replace ``image`` with an image (e.g. "core-image-sato")::
145
146 $ bitbake image -c populate_sdk
147
148 You can do the same for the extensible SDK using this command form::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500149
150 $ bitbake image -c populate_sdk_ext
151
152 These commands produce an SDK installer that contains the sysroot
153 that matches your target root filesystem.
154
155 When the ``bitbake`` command completes, the SDK installer will be in
Patrick Williams2390b1b2022-11-03 13:47:49 -0500156 ``tmp/deploy/sdk`` in the :term:`Build Directory`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500157
158 .. note::
159
160 - By default, the previous BitBake command does not build static
161 binaries. If you want to use the toolchain to build these types
162 of libraries, you need to be sure your SDK has the appropriate
163 static development libraries. Use the
164 :term:`TOOLCHAIN_TARGET_TASK`
165 variable inside your ``local.conf`` file before building the
166 SDK installer. Doing so ensures that the eventual SDK
167 installation process installs the appropriate library packages
168 as part of the SDK. Following is an example using ``libc``
Patrick Williams0ca19cc2021-08-16 14:03:13 -0500169 static development libraries: TOOLCHAIN_TARGET_TASK:append = "
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500170 libc-staticdev"
171
Andrew Geissler517393d2023-01-13 08:55:19 -0600172#. *Run the Installer:* You can now run the SDK installer from
Patrick Williams2390b1b2022-11-03 13:47:49 -0500173 ``tmp/deploy/sdk`` in the :term:`Build Directory`. Following is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500174
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500175 $ cd poky/build/tmp/deploy/sdk
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600176 $ ./poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500177
178 During execution of the script, you choose the root location for the
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500179 toolchain. See the
180 ":ref:`sdk-manual/appendix-obtain:installed standard sdk directory structure`"
181 section and the
182 ":ref:`sdk-manual/appendix-obtain:installed extensible sdk directory structure`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500183 section for more information.
184
185Extracting the Root Filesystem
186==============================
187
188After installing the toolchain, for some use cases you might need to
189separately extract a root filesystem:
190
191- You want to boot the image using NFS.
192
193- You want to use the root filesystem as the target sysroot.
194
195- You want to develop your target application using the root filesystem
196 as the target sysroot.
197
198Follow these steps to extract the root filesystem:
199
Andrew Geissler517393d2023-01-13 08:55:19 -0600200#. *Locate and Download the Tarball for the Pre-Built Root Filesystem
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500201 Image File:* You need to find and download the root filesystem image
202 file that is appropriate for your target system. These files are kept
203 in machine-specific folders in the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600204 :yocto_dl:`Index of Releases </releases/yocto/yocto-&DISTRO;/machines/>`
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500205 in the "machines" directory.
206
207 The machine-specific folders of the "machines" directory contain
208 tarballs (``*.tar.bz2``) for supported machines. These directories
209 also contain flattened root filesystem image files (``*.ext4``),
210 which you can use with QEMU directly.
211
Patrick Williamsac13d5f2023-11-24 18:59:46 -0600212 The pre-built root filesystem image files follow the
213 ``core-image-profile-machine.tar.bz2`` naming convention:
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500214
Patrick Williamsac13d5f2023-11-24 18:59:46 -0600215 - ``profile``: filesystem image's profile, such as ``minimal``,
216 ``minimal-dev`` or ``sato``. For information on these types of image
217 profiles, see the "Images" chapter in the Yocto Project Reference Manual.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500218
Patrick Williamsac13d5f2023-11-24 18:59:46 -0600219 - ``machine``: same string as the name of the parent download directory.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500220
221 The root filesystems
222 provided by the Yocto Project are based off of the
223 ``core-image-sato`` and ``core-image-minimal`` images.
224
225 For example, if you plan on using a BeagleBone device as your target
226 hardware and your image is a ``core-image-sato-sdk`` image, you can
Andrew Geisslerc926e172021-05-07 16:11:35 -0500227 download the following file::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500228
229 core-image-sato-sdk-beaglebone-yocto.tar.bz2
230
Andrew Geissler517393d2023-01-13 08:55:19 -0600231#. *Initialize the Cross-Development Environment:* You must ``source``
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500232 the cross-development environment setup script to establish necessary
233 environment variables.
234
235 This script is located in the top-level directory in which you
236 installed the toolchain (e.g. ``poky_sdk``).
237
238 Following is an example based on the toolchain installed in the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500239 ":ref:`sdk-manual/appendix-obtain:locating pre-built sdk installers`" section::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500240
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500241 $ source poky_sdk/environment-setup-core2-64-poky-linux
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500242
Andrew Geissler517393d2023-01-13 08:55:19 -0600243#. *Extract the Root Filesystem:* Use the ``runqemu-extract-sdk``
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500244 command and provide the root filesystem image.
245
246 Following is an example command that extracts the root filesystem
247 from a previously built root filesystem image that was downloaded
Andrew Geissler09209ee2020-12-13 08:44:15 -0600248 from the :yocto_dl:`Index of Releases </releases/yocto/yocto-&DISTRO;/machines/>`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500249 This command extracts the root filesystem into the ``core2-64-sato``
Andrew Geisslerc926e172021-05-07 16:11:35 -0500250 directory::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500251
252 $ runqemu-extract-sdk ~/Downloads/core-image-sato-sdk-beaglebone-yocto.tar.bz2 ~/beaglebone-sato
253
Andrew Geisslerc926e172021-05-07 16:11:35 -0500254 You could now point to the target sysroot at ``beaglebone-sato``.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500255
256Installed Standard SDK Directory Structure
257==========================================
258
259The following figure shows the resulting directory structure after you
260install the Standard SDK by running the ``*.sh`` SDK installation
261script:
262
263.. image:: figures/sdk-installed-standard-sdk-directory.png
Andrew Geisslerd5838332022-05-27 11:33:10 -0500264 :scale: 100%
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500265
266The installed SDK consists of an environment setup script for the SDK, a
267configuration file for the target, a version file for the target, and
268the root filesystem (``sysroots``) needed to develop objects for the
269target system.
270
271Within the figure, italicized text is used to indicate replaceable
272portions of the file or directory name. For example, install_dir/version
273is the directory where the SDK is installed. By default, this directory
274is ``/opt/poky/``. And, version represents the specific snapshot of the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600275SDK (e.g. &DISTRO;). Furthermore, target represents the target architecture
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500276(e.g. ``i586``) and host represents the development system's
277architecture (e.g. ``x86_64``). Thus, the complete names of the two
278directories within the ``sysroots`` could be ``i586-poky-linux`` and
279``x86_64-pokysdk-linux`` for the target and host, respectively.
280
281Installed Extensible SDK Directory Structure
282============================================
283
284The following figure shows the resulting directory structure after you
285install the Extensible SDK by running the ``*.sh`` SDK installation
286script:
287
288.. image:: figures/sdk-installed-extensible-sdk-directory.png
289 :scale: 80%
290 :align: center
291
292The installed directory structure for the extensible SDK is quite
293different than the installed structure for the standard SDK. The
294extensible SDK does not separate host and target parts in the same
295manner as does the standard SDK. The extensible SDK uses an embedded
296copy of the OpenEmbedded build system, which has its own sysroots.
297
298Of note in the directory structure are an environment setup script for
299the SDK, a configuration file for the target, a version file for the
300target, and log files for the OpenEmbedded build system preparation
301script run by the installer and BitBake.
302
303Within the figure, italicized text is used to indicate replaceable
304portions of the file or directory name. For example, install_dir is the
305directory where the SDK is installed, which is ``poky_sdk`` by default,
306and target represents the target architecture (e.g. ``i586``).