diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
| commit | 8c22ff0d8b70d9b12f0487ef696a7e915b9e3173 (patch) | |
| tree | efdc32587159d0050a69009bdf2330a531727d95 /documentation/sdk-manual | |
| parent | d412d2747595c1cc4a5e3ca975e3adc31b2f7891 (diff) | |
| download | poky-8c22ff0d8b70d9b12f0487ef696a7e915b9e3173.tar.gz | |
The poky repository master branch is no longer being updated.
You can either:
a) switch to individual clones of bitbake, openembedded-core, meta-yocto and yocto-docs
b) use the new bitbake-setup
You can find information about either approach in our documentation:
https://docs.yoctoproject.org/
Note that "poky" the distro setting is still available in meta-yocto as
before and we continue to use and maintain that.
Long live Poky!
Some further information on the background of this change can be found
in: https://lists.openembedded.org/g/openembedded-architecture/message/2179
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/sdk-manual')
| -rw-r--r-- | documentation/sdk-manual/appendix-customizing-standard.rst | 34 | ||||
| -rw-r--r-- | documentation/sdk-manual/appendix-customizing.rst | 358 | ||||
| -rw-r--r-- | documentation/sdk-manual/appendix-obtain.rst | 306 | ||||
| -rw-r--r-- | documentation/sdk-manual/extensible.rst | 362 | ||||
| -rw-r--r-- | documentation/sdk-manual/figures/sdk-autotools-flow.png | bin | 50443 -> 0 bytes | |||
| -rw-r--r-- | documentation/sdk-manual/figures/sdk-environment.png | bin | 42098 -> 0 bytes | |||
| -rw-r--r-- | documentation/sdk-manual/figures/sdk-installed-extensible-sdk-directory.png | bin | 66753 -> 0 bytes | |||
| -rw-r--r-- | documentation/sdk-manual/figures/sdk-installed-standard-sdk-directory.png | bin | 39099 -> 0 bytes | |||
| -rw-r--r-- | documentation/sdk-manual/figures/sdk-makefile-flow.png | bin | 47197 -> 0 bytes | |||
| -rw-r--r-- | documentation/sdk-manual/figures/sdk-title.png | bin | 31039 -> 0 bytes | |||
| -rw-r--r-- | documentation/sdk-manual/index.rst | 21 | ||||
| -rw-r--r-- | documentation/sdk-manual/intro.rst | 208 | ||||
| -rw-r--r-- | documentation/sdk-manual/using.rst | 147 | ||||
| -rw-r--r-- | documentation/sdk-manual/working-projects.rst | 404 |
14 files changed, 0 insertions, 1840 deletions
diff --git a/documentation/sdk-manual/appendix-customizing-standard.rst b/documentation/sdk-manual/appendix-customizing-standard.rst deleted file mode 100644 index c619c15e46..0000000000 --- a/documentation/sdk-manual/appendix-customizing-standard.rst +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | **************************** | ||
| 4 | Customizing the Standard SDK | ||
| 5 | **************************** | ||
| 6 | |||
| 7 | This appendix presents customizations you can apply to the standard SDK. | ||
| 8 | |||
| 9 | Adding Individual Packages to the Standard SDK | ||
| 10 | ============================================== | ||
| 11 | |||
| 12 | When you build a standard SDK using the ``bitbake -c populate_sdk``, a | ||
| 13 | default set of packages is included in the resulting SDK. The | ||
| 14 | :term:`TOOLCHAIN_HOST_TASK` | ||
| 15 | and | ||
| 16 | :term:`TOOLCHAIN_TARGET_TASK` | ||
| 17 | variables control the set of packages adding to the SDK. | ||
| 18 | |||
| 19 | If you want to add individual packages to the toolchain that runs on the | ||
| 20 | host, simply add those packages to the :term:`TOOLCHAIN_HOST_TASK` variable. | ||
| 21 | Similarly, if you want to add packages to the default set that is part | ||
| 22 | of the toolchain that runs on the target, add the packages to the | ||
| 23 | :term:`TOOLCHAIN_TARGET_TASK` variable. | ||
| 24 | |||
| 25 | Adding API Documentation to the Standard SDK | ||
| 26 | ============================================ | ||
| 27 | |||
| 28 | You can include API documentation as well as any other documentation | ||
| 29 | provided by recipes with the standard SDK by adding "api-documentation" | ||
| 30 | to the | ||
| 31 | :term:`DISTRO_FEATURES` | ||
| 32 | variable: DISTRO_FEATURES:append = " api-documentation" Setting this | ||
| 33 | variable as shown here causes the OpenEmbedded build system to build the | ||
| 34 | documentation and then include it in the standard SDK. | ||
diff --git a/documentation/sdk-manual/appendix-customizing.rst b/documentation/sdk-manual/appendix-customizing.rst deleted file mode 100644 index e08630dce0..0000000000 --- a/documentation/sdk-manual/appendix-customizing.rst +++ /dev/null | |||
| @@ -1,358 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | *************************************************** | ||
| 4 | Customizing the Extensible SDK standalone installer | ||
| 5 | *************************************************** | ||
| 6 | |||
| 7 | This appendix describes customizations you can apply to the extensible | ||
| 8 | SDK when using in the standalone installer version. | ||
| 9 | |||
| 10 | .. note:: | ||
| 11 | |||
| 12 | It is also possible to use the Extensible SDK functionality directly in a | ||
| 13 | Yocto build, avoiding separate installer artefacts. Please refer to | ||
| 14 | ":ref:`sdk-manual/extensible:Installing the Extensible SDK`" | ||
| 15 | |||
| 16 | Configuring the Extensible SDK | ||
| 17 | ============================== | ||
| 18 | |||
| 19 | The extensible SDK primarily consists of a pre-configured copy of the | ||
| 20 | OpenEmbedded build system from which it was produced. Thus, the SDK's | ||
| 21 | configuration is derived using that build system and the filters shown | ||
| 22 | in the following list. When these filters are present, the OpenEmbedded | ||
| 23 | build system applies them against ``local.conf`` and ``auto.conf``: | ||
| 24 | |||
| 25 | - Variables whose values start with "/" are excluded since the | ||
| 26 | assumption is that those values are paths that are likely to be | ||
| 27 | specific to the :term:`Build Host`. | ||
| 28 | |||
| 29 | - Variables listed in | ||
| 30 | :term:`ESDK_LOCALCONF_REMOVE` | ||
| 31 | are excluded. These variables are not allowed through from the | ||
| 32 | OpenEmbedded build system configuration into the extensible SDK | ||
| 33 | configuration. Typically, these variables are specific to the machine | ||
| 34 | on which the build system is running and could be problematic as part | ||
| 35 | of the extensible SDK configuration. | ||
| 36 | |||
| 37 | For a list of the variables excluded by default, see the | ||
| 38 | :term:`ESDK_LOCALCONF_REMOVE` | ||
| 39 | in the glossary of the Yocto Project Reference Manual. | ||
| 40 | |||
| 41 | - Variables listed in | ||
| 42 | :term:`ESDK_LOCALCONF_ALLOW` | ||
| 43 | are included. Including a variable in the value of | ||
| 44 | :term:`ESDK_LOCALCONF_ALLOW` overrides either of the previous two | ||
| 45 | filters. The default value is blank. | ||
| 46 | |||
| 47 | - Classes inherited globally with :term:`INHERIT` that are listed in | ||
| 48 | :term:`ESDK_CLASS_INHERIT_DISABLE` are disabled. Using | ||
| 49 | :term:`ESDK_CLASS_INHERIT_DISABLE` to disable these classes is the typical | ||
| 50 | method to disable classes that are problematic or unnecessary in the SDK | ||
| 51 | context. The default value disables the :ref:`ref-classes-buildhistory` | ||
| 52 | class. | ||
| 53 | |||
| 54 | Additionally, the contents of ``conf/sdk-extra.conf``, when present, are | ||
| 55 | appended to the end of ``conf/local.conf`` within the produced SDK, | ||
| 56 | without any filtering. The ``sdk-extra.conf`` file is particularly | ||
| 57 | useful if you want to set a variable value just for the SDK and not the | ||
| 58 | OpenEmbedded build system used to create the SDK. | ||
| 59 | |||
| 60 | Adjusting the Extensible SDK to Suit Your Build Host's Setup | ||
| 61 | ============================================================ | ||
| 62 | |||
| 63 | In most cases, the extensible SDK defaults should work with your :term:`Build | ||
| 64 | Host`'s setup. However, there are cases when you might consider making | ||
| 65 | adjustments: | ||
| 66 | |||
| 67 | - If your SDK configuration inherits additional classes using the | ||
| 68 | :term:`INHERIT` variable and you | ||
| 69 | do not need or want those classes enabled in the SDK, you can | ||
| 70 | disable them by adding them to the :term:`ESDK_CLASS_INHERIT_DISABLE` | ||
| 71 | variable as described in the previous section. | ||
| 72 | |||
| 73 | .. note:: | ||
| 74 | |||
| 75 | The default value of :term:`ESDK_CLASS_INHERIT_DISABLE` | ||
| 76 | is set using the "?=" operator. Consequently, you will need to | ||
| 77 | either define the entire list by using the "=" operator, or you | ||
| 78 | will need to append a value using either ":append" or the "+=" | ||
| 79 | operator. You can learn more about these operators in the | ||
| 80 | ":ref:`bitbake-user-manual/bitbake-user-manual-metadata:basic syntax`" | ||
| 81 | section of the BitBake User Manual. | ||
| 82 | |||
| 83 | - If you have classes or recipes that add additional tasks to the | ||
| 84 | standard build flow (i.e. the tasks execute as the recipe builds as | ||
| 85 | opposed to being called explicitly), then you need to do one of the | ||
| 86 | following: | ||
| 87 | |||
| 88 | - After ensuring the tasks are :ref:`shared | ||
| 89 | state <overview-manual/concepts:shared state cache>` tasks (i.e. the | ||
| 90 | output of the task is saved to and can be restored from the shared | ||
| 91 | state cache) or ensuring the tasks are able to be produced quickly | ||
| 92 | from a task that is a shared state task, add the task name to the | ||
| 93 | value of | ||
| 94 | :term:`SDK_RECRDEP_TASKS`. | ||
| 95 | |||
| 96 | - Disable the tasks if they are added by a class and you do not need | ||
| 97 | the functionality the class provides in the extensible SDK. To | ||
| 98 | disable the tasks, add the class to the :term:`ESDK_CLASS_INHERIT_DISABLE` | ||
| 99 | variable as described in the previous section. | ||
| 100 | |||
| 101 | - Generally, you want to have a shared state mirror set up so users of | ||
| 102 | the SDK can add additional items to the SDK after installation | ||
| 103 | without needing to build the items from source. See the | ||
| 104 | ":ref:`sdk-manual/appendix-customizing:providing additional installable extensible sdk content`" | ||
| 105 | section for information. | ||
| 106 | |||
| 107 | - If you want users of the SDK to be able to easily update the SDK, you | ||
| 108 | need to set the | ||
| 109 | :term:`SDK_UPDATE_URL` | ||
| 110 | variable. For more information, see the | ||
| 111 | ":ref:`sdk-manual/appendix-customizing:providing updates to the extensible sdk after installation`" | ||
| 112 | section. | ||
| 113 | |||
| 114 | - If you have adjusted the list of files and directories that appear in | ||
| 115 | :term:`COREBASE` (other than | ||
| 116 | layers that are enabled through ``bblayers.conf``), then you must | ||
| 117 | list these files in | ||
| 118 | :term:`COREBASE_FILES` so | ||
| 119 | that the files are copied into the SDK. | ||
| 120 | |||
| 121 | - If your OpenEmbedded build system setup uses a different environment | ||
| 122 | setup script other than | ||
| 123 | :ref:`structure-core-script`, then you must | ||
| 124 | set | ||
| 125 | :term:`OE_INIT_ENV_SCRIPT` | ||
| 126 | to point to the environment setup script you use. | ||
| 127 | |||
| 128 | .. note:: | ||
| 129 | |||
| 130 | You must also reflect this change in the value used for the | ||
| 131 | :term:`COREBASE_FILES` variable as previously described. | ||
| 132 | |||
| 133 | Changing the Extensible SDK Installer Title | ||
| 134 | =========================================== | ||
| 135 | |||
| 136 | You can change the displayed title for the SDK installer by setting the | ||
| 137 | :term:`SDK_TITLE` variable and then | ||
| 138 | rebuilding the SDK installer. For information on how to build an SDK | ||
| 139 | installer, see the ":ref:`sdk-manual/appendix-obtain:building an sdk installer`" | ||
| 140 | section. | ||
| 141 | |||
| 142 | By default, this title is derived from | ||
| 143 | :term:`DISTRO_NAME` when it is | ||
| 144 | set. If the :term:`DISTRO_NAME` variable is not set, the title is derived | ||
| 145 | from the :term:`DISTRO` variable. | ||
| 146 | |||
| 147 | The | ||
| 148 | :ref:`populate_sdk_base <ref-classes-populate-sdk-*>` | ||
| 149 | class defines the default value of the :term:`SDK_TITLE` variable as | ||
| 150 | follows:: | ||
| 151 | |||
| 152 | SDK_TITLE ??= "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} SDK" | ||
| 153 | |||
| 154 | While there are several ways of changing this variable, an efficient method is | ||
| 155 | to set the variable in your distribution's configuration file. Doing so | ||
| 156 | creates an SDK installer title that applies across your distribution. As | ||
| 157 | an example, assume you have your own layer for your distribution named | ||
| 158 | "meta-mydistro" and you are using the same type of file hierarchy as | ||
| 159 | does the default "poky" distribution. If so, you could update the | ||
| 160 | :term:`SDK_TITLE` variable in the | ||
| 161 | ``~/meta-mydistro/conf/distro/mydistro.conf`` file using the following | ||
| 162 | form:: | ||
| 163 | |||
| 164 | SDK_TITLE = "your_title" | ||
| 165 | |||
| 166 | Providing Updates to the Extensible SDK After Installation | ||
| 167 | ========================================================== | ||
| 168 | |||
| 169 | When you make changes to your configuration or to the metadata and if | ||
| 170 | you want those changes to be reflected in installed SDKs, you need to | ||
| 171 | perform additional steps. These steps make it possible for anyone using | ||
| 172 | the installed SDKs to update the installed SDKs by using the | ||
| 173 | ``devtool sdk-update`` command: | ||
| 174 | |||
| 175 | #. Create a directory that can be shared over HTTP or HTTPS. You can do | ||
| 176 | this by setting up a web server such as an :wikipedia:`Apache HTTP Server | ||
| 177 | <Apache_HTTP_Server>` or :wikipedia:`Nginx <Nginx>` server in the cloud | ||
| 178 | to host the directory. This directory must contain the published SDK. | ||
| 179 | |||
| 180 | #. Set the | ||
| 181 | :term:`SDK_UPDATE_URL` | ||
| 182 | variable to point to the corresponding HTTP or HTTPS URL. Setting | ||
| 183 | this variable causes any SDK built to default to that URL and thus, | ||
| 184 | the user does not have to pass the URL to the ``devtool sdk-update`` | ||
| 185 | command as described in the | ||
| 186 | ":ref:`sdk-manual/extensible:applying updates to an installed extensible sdk`" | ||
| 187 | section. | ||
| 188 | |||
| 189 | #. Build the extensible SDK normally (i.e., use the | ||
| 190 | ``bitbake -c populate_sdk_ext`` imagename command). | ||
| 191 | |||
| 192 | #. Publish the SDK using the following command:: | ||
| 193 | |||
| 194 | $ oe-publish-sdk some_path/sdk-installer.sh path_to_shared_http_directory | ||
| 195 | |||
| 196 | You must | ||
| 197 | repeat this step each time you rebuild the SDK with changes that you | ||
| 198 | want to make available through the update mechanism. | ||
| 199 | |||
| 200 | Completing the above steps allows users of the existing installed SDKs | ||
| 201 | to simply run ``devtool sdk-update`` to retrieve and apply the latest | ||
| 202 | updates. See the | ||
| 203 | ":ref:`sdk-manual/extensible:applying updates to an installed extensible sdk`" | ||
| 204 | section for further information. | ||
| 205 | |||
| 206 | Changing the Default SDK Installation Directory | ||
| 207 | =============================================== | ||
| 208 | |||
| 209 | When you build the installer for the Extensible SDK, the default | ||
| 210 | installation directory for the SDK is based on the | ||
| 211 | :term:`DISTRO` and | ||
| 212 | :term:`SDKEXTPATH` variables from | ||
| 213 | within the | ||
| 214 | :ref:`populate_sdk_base <ref-classes-populate-sdk-*>` | ||
| 215 | class as follows:: | ||
| 216 | |||
| 217 | SDKEXTPATH ??= "~/${@d.getVar('DISTRO')}_sdk" | ||
| 218 | |||
| 219 | You can | ||
| 220 | change this default installation directory by specifically setting the | ||
| 221 | :term:`SDKEXTPATH` variable. | ||
| 222 | |||
| 223 | While there are several ways of setting this variable, | ||
| 224 | the method that makes the most sense is to set the variable in your | ||
| 225 | distribution's configuration file. Doing so creates an SDK installer | ||
| 226 | default directory that applies across your distribution. As an example, | ||
| 227 | assume you have your own layer for your distribution named | ||
| 228 | "meta-mydistro" and you are using the same type of file hierarchy as | ||
| 229 | does the default "poky" distribution. If so, you could update the | ||
| 230 | :term:`SDKEXTPATH` variable in the | ||
| 231 | ``~/meta-mydistro/conf/distro/mydistro.conf`` file using the following | ||
| 232 | form:: | ||
| 233 | |||
| 234 | SDKEXTPATH = "some_path_for_your_installed_sdk" | ||
| 235 | |||
| 236 | After building your installer, running it prompts the user for | ||
| 237 | acceptance of the some_path_for_your_installed_sdk directory as the | ||
| 238 | default location to install the Extensible SDK. | ||
| 239 | |||
| 240 | Providing Additional Installable Extensible SDK Content | ||
| 241 | ======================================================= | ||
| 242 | |||
| 243 | If you want the users of an extensible SDK you build to be able to add | ||
| 244 | items to the SDK without requiring the users to build the items from | ||
| 245 | source, you need to do a number of things: | ||
| 246 | |||
| 247 | #. Ensure the additional items you want the user to be able to install | ||
| 248 | are already built: | ||
| 249 | |||
| 250 | - Build the items explicitly. You could use one or more "meta" | ||
| 251 | recipes that depend on lists of other recipes. | ||
| 252 | |||
| 253 | - Build the "world" target and set | ||
| 254 | ``EXCLUDE_FROM_WORLD:pn-``\ recipename for the recipes you do not | ||
| 255 | want built. See the | ||
| 256 | :term:`EXCLUDE_FROM_WORLD` | ||
| 257 | variable for additional information. | ||
| 258 | |||
| 259 | #. Expose the ``sstate-cache`` directory produced by the build. | ||
| 260 | Typically, you expose this directory by making it available through | ||
| 261 | an :wikipedia:`Apache HTTP Server <Apache_HTTP_Server>` or | ||
| 262 | :wikipedia:`Nginx <Nginx>` server. | ||
| 263 | |||
| 264 | #. Set the appropriate configuration so that the produced SDK knows how | ||
| 265 | to find the configuration. The variable you need to set is | ||
| 266 | :term:`SSTATE_MIRRORS`:: | ||
| 267 | |||
| 268 | SSTATE_MIRRORS = "file://.* https://example.com/some_path/sstate-cache/PATH" | ||
| 269 | |||
| 270 | You can set the :term:`SSTATE_MIRRORS` variable in two different places: | ||
| 271 | |||
| 272 | - If the mirror value you are setting is appropriate to be set for | ||
| 273 | both the OpenEmbedded build system that is actually building the | ||
| 274 | SDK and the SDK itself (i.e. the mirror is accessible in both | ||
| 275 | places or it will fail quickly on the OpenEmbedded build system | ||
| 276 | side, and its contents will not interfere with the build), then | ||
| 277 | you can set the variable in your ``local.conf`` or custom distro | ||
| 278 | configuration file. You can then pass the variable to the SDK by | ||
| 279 | adding the following:: | ||
| 280 | |||
| 281 | ESDK_LOCALCONF_ALLOW = "SSTATE_MIRRORS" | ||
| 282 | |||
| 283 | - Alternatively, if you just want to set the :term:`SSTATE_MIRRORS` | ||
| 284 | variable's value for the SDK alone, create a ``conf/sdk-extra.conf`` | ||
| 285 | file either in your :term:`Build Directory` or within any | ||
| 286 | layer and put your :term:`SSTATE_MIRRORS` setting within that file. | ||
| 287 | |||
| 288 | .. note:: | ||
| 289 | |||
| 290 | This second option is the safest option should you have any | ||
| 291 | doubts as to which method to use when setting | ||
| 292 | :term:`SSTATE_MIRRORS` | ||
| 293 | |||
| 294 | Minimizing the Size of the Extensible SDK Installer Download | ||
| 295 | ============================================================ | ||
| 296 | |||
| 297 | By default, the extensible SDK bundles the shared state artifacts for | ||
| 298 | everything needed to reconstruct the image for which the SDK was built. | ||
| 299 | This bundling can lead to an SDK installer file that is a Gigabyte or | ||
| 300 | more in size. If the size of this file causes a problem, you can build | ||
| 301 | an SDK that has just enough in it to install and provide access to the | ||
| 302 | ``devtool command`` by setting the following in your configuration:: | ||
| 303 | |||
| 304 | SDK_EXT_TYPE = "minimal" | ||
| 305 | |||
| 306 | Setting | ||
| 307 | :term:`SDK_EXT_TYPE` to | ||
| 308 | "minimal" produces an SDK installer that is around 35 Mbytes in size, | ||
| 309 | which downloads and installs quickly. You need to realize, though, that | ||
| 310 | the minimal installer does not install any libraries or tools out of the | ||
| 311 | box. These libraries and tools must be installed either "on the fly" or | ||
| 312 | through actions you perform using ``devtool`` or explicitly with the | ||
| 313 | ``devtool sdk-install`` command. | ||
| 314 | |||
| 315 | In most cases, when building a minimal SDK you need to also enable | ||
| 316 | bringing in the information on a wider range of packages produced by the | ||
| 317 | system. Requiring this wider range of information is particularly true | ||
| 318 | so that ``devtool add`` is able to effectively map dependencies it | ||
| 319 | discovers in a source tree to the appropriate recipes. Additionally, the | ||
| 320 | information enables the ``devtool search`` command to return useful | ||
| 321 | results. | ||
| 322 | |||
| 323 | To facilitate this wider range of information, you would need to set the | ||
| 324 | following:: | ||
| 325 | |||
| 326 | SDK_INCLUDE_PKGDATA = "1" | ||
| 327 | |||
| 328 | See the :term:`SDK_INCLUDE_PKGDATA` variable for additional information. | ||
| 329 | |||
| 330 | Setting the :term:`SDK_INCLUDE_PKGDATA` variable as shown causes the "world" | ||
| 331 | target to be built so that information for all of the recipes included | ||
| 332 | within it are available. Having these recipes available increases build | ||
| 333 | time significantly and increases the size of the SDK installer by 30-80 | ||
| 334 | Mbytes depending on how many recipes are included in your configuration. | ||
| 335 | |||
| 336 | You can use ``EXCLUDE_FROM_WORLD:pn-``\ recipename for recipes you want | ||
| 337 | to exclude. However, it is assumed that you would need to be building | ||
| 338 | the "world" target if you want to provide additional items to the SDK. | ||
| 339 | Consequently, building for "world" should not represent undue overhead | ||
| 340 | in most cases. | ||
| 341 | |||
| 342 | .. note:: | ||
| 343 | |||
| 344 | If you set | ||
| 345 | SDK_EXT_TYPE | ||
| 346 | to "minimal", then providing a shared state mirror is mandatory so | ||
| 347 | that items can be installed as needed. See the | ||
| 348 | :ref:`sdk-manual/appendix-customizing:providing additional installable extensible sdk content` | ||
| 349 | section for more information. | ||
| 350 | |||
| 351 | You can explicitly control whether or not to include the toolchain when | ||
| 352 | you build an SDK by setting the | ||
| 353 | :term:`SDK_INCLUDE_TOOLCHAIN` | ||
| 354 | variable to "1". In particular, it is useful to include the toolchain | ||
| 355 | when you have set :term:`SDK_EXT_TYPE` to "minimal", which by default, | ||
| 356 | excludes the toolchain. Also, it is helpful if you are building a small | ||
| 357 | SDK for use with an IDE or some other tool where you do not want to take | ||
| 358 | extra steps to install a toolchain. | ||
diff --git a/documentation/sdk-manual/appendix-obtain.rst b/documentation/sdk-manual/appendix-obtain.rst deleted file mode 100644 index a42cbc31bb..0000000000 --- a/documentation/sdk-manual/appendix-obtain.rst +++ /dev/null | |||
| @@ -1,306 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ***************** | ||
| 4 | Obtaining the SDK | ||
| 5 | ***************** | ||
| 6 | |||
| 7 | Working with the SDK components directly in a Yocto build | ||
| 8 | ========================================================= | ||
| 9 | |||
| 10 | Please refer to section | ||
| 11 | ":ref:`sdk-manual/extensible:Setting up the Extensible SDK environment directly in a Yocto build`" | ||
| 12 | |||
| 13 | Note that to use this feature effectively either a powerful build | ||
| 14 | machine, or a well-functioning sstate cache infrastructure is required: | ||
| 15 | otherwise significant time could be spent waiting for components to be built | ||
| 16 | by BitBake from source code. | ||
| 17 | |||
| 18 | Working with standalone SDK Installers | ||
| 19 | ====================================== | ||
| 20 | |||
| 21 | Locating Pre-Built SDK Installers | ||
| 22 | --------------------------------- | ||
| 23 | |||
| 24 | You can use existing, pre-built toolchains by locating and running an | ||
| 25 | SDK installer script that ships with the Yocto Project. Using this | ||
| 26 | method, you select and download an architecture-specific SDK installer | ||
| 27 | and then run the script to hand-install the toolchain. | ||
| 28 | |||
| 29 | Follow these steps to locate and hand-install the toolchain: | ||
| 30 | |||
| 31 | #. *Go to the Installers Directory:* Go to | ||
| 32 | :yocto_dl:`/releases/yocto/&DISTRO_REL_LATEST_TAG;/toolchain/` | ||
| 33 | |||
| 34 | #. *Open the Folder for Your Build Host:* Open the folder that matches | ||
| 35 | your :term:`Build Host` (i.e. | ||
| 36 | ``i686`` for 32-bit machines or ``x86_64`` for 64-bit machines). | ||
| 37 | |||
| 38 | #. *Locate and Download the SDK Installer:* You need to find and | ||
| 39 | download the installer appropriate for your build host, target | ||
| 40 | hardware, and image type. | ||
| 41 | |||
| 42 | The installer files (``*.sh``) follow this naming convention: | ||
| 43 | ``poky-glibc-host_system-core-image-type-arch-toolchain[-ext]-release.sh``: | ||
| 44 | |||
| 45 | - ``host_system``: string representing your development system: ``i686`` or ``x86_64`` | ||
| 46 | |||
| 47 | - ``type``: string representing the image: ``sato`` or ``minimal`` | ||
| 48 | |||
| 49 | - ``arch``: string representing the target architecture such as ``cortexa57-qemuarm64`` | ||
| 50 | |||
| 51 | - ``release``: version of the Yocto Project. | ||
| 52 | |||
| 53 | .. note:: | ||
| 54 | The standard SDK installer does not have the ``-ext`` string as | ||
| 55 | part of the filename. | ||
| 56 | |||
| 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 | ||
| 63 | an extended SDK for a 64-bit core2 QEMU target, go into the ``x86_64`` | ||
| 64 | folder and download the following installer:: | ||
| 65 | |||
| 66 | poky-glibc-x86_64-core-image-sato-core2-64-qemux86-64-toolchain-&DISTRO;.sh | ||
| 67 | |||
| 68 | #. *Run the Installer:* Be sure you have execution privileges and run | ||
| 69 | the installer. Here is an example from the ``Downloads`` | ||
| 70 | directory:: | ||
| 71 | |||
| 72 | $ ~/Downloads/poky-glibc-x86_64-core-image-sato-core2-64-qemux86-64-toolchain-&DISTRO;.sh | ||
| 73 | |||
| 74 | During execution of the script, you choose the root location for the | ||
| 75 | 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`" | ||
| 79 | section for more information. | ||
| 80 | |||
| 81 | Building an SDK Installer | ||
| 82 | ------------------------- | ||
| 83 | |||
| 84 | As an alternative to locating and downloading an SDK installer, you can | ||
| 85 | build the SDK installer. Follow these steps: | ||
| 86 | |||
| 87 | #. *Set Up the Build Environment:* Be sure you are set up to use BitBake | ||
| 88 | in a shell. See the ":ref:`dev-manual/start:preparing the build host`" section | ||
| 89 | 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 | |||
| 93 | #. *Clone the ``poky`` Repository:* You need to have a local copy of the | ||
| 94 | Yocto Project :term:`Source Directory` | ||
| 95 | (i.e. a local | ||
| 96 | ``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 | ||
| 99 | 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 | |||
| 103 | #. *Initialize the Build Environment:* While in the root directory of | ||
| 104 | 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 | ||
| 107 | build host:: | ||
| 108 | |||
| 109 | $ source oe-init-build-env | ||
| 110 | |||
| 111 | 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. | ||
| 115 | |||
| 116 | #. *Make Sure You Are Building an Installer for the Correct Machine:* | ||
| 117 | Check to be sure that your :term:`MACHINE` variable in the ``local.conf`` | ||
| 118 | file in your :term:`Build Directory` matches the architecture | ||
| 119 | for which you are building. | ||
| 120 | |||
| 121 | #. *Make Sure Your SDK Machine is Correctly Set:* If you are building a | ||
| 122 | toolchain designed to run on an architecture that differs from your | ||
| 123 | current development host machine (i.e. the build host), be sure that | ||
| 124 | the :term:`SDKMACHINE` variable in the ``local.conf`` file in your | ||
| 125 | :term:`Build Directory` is correctly set. | ||
| 126 | |||
| 127 | .. note:: | ||
| 128 | |||
| 129 | If you are building an SDK installer for the Extensible SDK, the | ||
| 130 | :term:`SDKMACHINE` value must be set for the architecture of the | ||
| 131 | machine you are using to build the installer. If :term:`SDKMACHINE` | ||
| 132 | is not set appropriately, the build fails and provides an error | ||
| 133 | message similar to the following:: | ||
| 134 | |||
| 135 | The extensible SDK can currently only be built for the same | ||
| 136 | 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. | ||
| 140 | |||
| 141 | |||
| 142 | #. *Build the SDK Installer:* To build the SDK installer for a standard | ||
| 143 | SDK and populate the SDK image, use the following command form. Be | ||
| 144 | 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:: | ||
| 149 | |||
| 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 | ||
| 156 | ``tmp/deploy/sdk`` in the :term:`Build Directory`. | ||
| 157 | |||
| 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. Here is an example using ``libc`` | ||
| 169 | static development libraries: TOOLCHAIN_TARGET_TASK:append = " | ||
| 170 | libc-staticdev" | ||
| 171 | |||
| 172 | #. *Run the Installer:* You can now run the SDK installer from | ||
| 173 | ``tmp/deploy/sdk`` in the :term:`Build Directory`. Here is an example:: | ||
| 174 | |||
| 175 | $ cd poky/build/tmp/deploy/sdk | ||
| 176 | $ ./poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh | ||
| 177 | |||
| 178 | During execution of the script, you choose the root location for the | ||
| 179 | 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`" | ||
| 183 | section for more information. | ||
| 184 | |||
| 185 | Extracting the Root Filesystem | ||
| 186 | ============================== | ||
| 187 | |||
| 188 | After installing the toolchain, for some use cases you might need to | ||
| 189 | separately 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 | |||
| 198 | Follow these steps to extract the root filesystem: | ||
| 199 | |||
| 200 | #. *Locate and Download the Tarball for the Pre-Built Root Filesystem | ||
| 201 | 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 | ||
| 204 | :yocto_dl:`Index of Releases </releases/yocto/&DISTRO_REL_LATEST_TAG;/machines/>` | ||
| 205 | 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 | |||
| 212 | The pre-built root filesystem image files follow the | ||
| 213 | ``core-image-profile-machine.tar.bz2`` naming convention: | ||
| 214 | |||
| 215 | - ``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. | ||
| 218 | |||
| 219 | - ``machine``: same string as the name of the parent download directory. | ||
| 220 | |||
| 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 | ||
| 227 | download the following file:: | ||
| 228 | |||
| 229 | core-image-sato-sdk-beaglebone-yocto.tar.bz2 | ||
| 230 | |||
| 231 | #. *Initialize the Cross-Development Environment:* You must ``source`` | ||
| 232 | 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 | Here is an example based on the toolchain installed in the | ||
| 239 | ":ref:`sdk-manual/appendix-obtain:locating pre-built sdk installers`" section:: | ||
| 240 | |||
| 241 | $ source poky_sdk/environment-setup-core2-64-poky-linux | ||
| 242 | |||
| 243 | #. *Extract the Root Filesystem:* Use the ``runqemu-extract-sdk`` | ||
| 244 | command and provide the root filesystem image. | ||
| 245 | |||
| 246 | Here is an example command that extracts the root filesystem | ||
| 247 | from a previously built root filesystem image that was downloaded | ||
| 248 | from the :yocto_dl:`Index of Releases </releases/yocto/&DISTRO_REL_LATEST_TAG;/machines/>`. | ||
| 249 | This command extracts the root filesystem into the ``core2-64-sato`` | ||
| 250 | directory:: | ||
| 251 | |||
| 252 | $ runqemu-extract-sdk ~/Downloads/core-image-sato-sdk-beaglebone-yocto.tar.bz2 ~/beaglebone-sato | ||
| 253 | |||
| 254 | You could now point to the target sysroot at ``beaglebone-sato``. | ||
| 255 | |||
| 256 | Installed Standard SDK Directory Structure | ||
| 257 | ========================================== | ||
| 258 | |||
| 259 | The following figure shows the resulting directory structure after you | ||
| 260 | install the Standard SDK by running the ``*.sh`` SDK installation | ||
| 261 | script: | ||
| 262 | |||
| 263 | .. image:: figures/sdk-installed-standard-sdk-directory.png | ||
| 264 | :scale: 100% | ||
| 265 | |||
| 266 | The installed SDK consists of an environment setup script for the SDK, a | ||
| 267 | configuration file for the target, a version file for the target, and | ||
| 268 | the root filesystem (``sysroots``) needed to develop objects for the | ||
| 269 | target system. | ||
| 270 | |||
| 271 | Within the figure, italicized text is used to indicate replaceable | ||
| 272 | portions of the file or directory name. For example, install_dir/version | ||
| 273 | is the directory where the SDK is installed. By default, this directory | ||
| 274 | is ``/opt/poky/``. And, version represents the specific snapshot of the | ||
| 275 | SDK (e.g. &DISTRO;). Furthermore, target represents the target architecture | ||
| 276 | (e.g. ``i586``) and host represents the development system's | ||
| 277 | architecture (e.g. ``x86_64``). Thus, the complete names of the two | ||
| 278 | directories within the ``sysroots`` could be ``i586-poky-linux`` and | ||
| 279 | ``x86_64-pokysdk-linux`` for the target and host, respectively. | ||
| 280 | |||
| 281 | Installed Extensible SDK Directory Structure | ||
| 282 | ============================================ | ||
| 283 | |||
| 284 | The following figure shows the resulting directory structure after you | ||
| 285 | install the Extensible SDK by running the ``*.sh`` SDK installation | ||
| 286 | script: | ||
| 287 | |||
| 288 | .. image:: figures/sdk-installed-extensible-sdk-directory.png | ||
| 289 | :scale: 80% | ||
| 290 | :align: center | ||
| 291 | |||
| 292 | The installed directory structure for the extensible SDK is quite | ||
| 293 | different than the installed structure for the standard SDK. The | ||
| 294 | extensible SDK does not separate host and target parts in the same | ||
| 295 | manner as does the standard SDK. The extensible SDK uses an embedded | ||
| 296 | copy of the OpenEmbedded build system, which has its own sysroots. | ||
| 297 | |||
| 298 | Of note in the directory structure are an environment setup script for | ||
| 299 | the SDK, a configuration file for the target, a version file for the | ||
| 300 | target, and log files for the OpenEmbedded build system preparation | ||
| 301 | script run by the installer and BitBake. | ||
| 302 | |||
| 303 | Within the figure, italicized text is used to indicate replaceable | ||
| 304 | portions of the file or directory name. For example, install_dir is the | ||
| 305 | directory where the SDK is installed, which is ``poky_sdk`` by default, | ||
| 306 | and target represents the target architecture (e.g. ``i586``). | ||
diff --git a/documentation/sdk-manual/extensible.rst b/documentation/sdk-manual/extensible.rst deleted file mode 100644 index e5e9e4a03b..0000000000 --- a/documentation/sdk-manual/extensible.rst +++ /dev/null | |||
| @@ -1,362 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ************************ | ||
| 4 | Using the Extensible SDK | ||
| 5 | ************************ | ||
| 6 | |||
| 7 | This chapter describes the extensible SDK and how to install it. | ||
| 8 | Information covers the pieces of the SDK, how to install it, and | ||
| 9 | presents a look at using the ``devtool`` functionality. The extensible | ||
| 10 | SDK makes it easy to add new applications and libraries to an image, | ||
| 11 | modify the source for an existing component, test changes on the target | ||
| 12 | hardware, and ease integration into the rest of the | ||
| 13 | :term:`OpenEmbedded Build System`. | ||
| 14 | |||
| 15 | .. note:: | ||
| 16 | |||
| 17 | For a side-by-side comparison of main features supported for an | ||
| 18 | extensible SDK as compared to a standard SDK, see the | ||
| 19 | :ref:`sdk-manual/intro:introduction` section. | ||
| 20 | |||
| 21 | In addition to the functionality available through ``devtool``, you can | ||
| 22 | alternatively make use of the toolchain directly, for example from | ||
| 23 | Makefile and Autotools. See the | ||
| 24 | ":ref:`sdk-manual/working-projects:using the sdk toolchain directly`" chapter | ||
| 25 | for more information. | ||
| 26 | |||
| 27 | Why use the Extensible SDK and What is in It? | ||
| 28 | ============================================= | ||
| 29 | |||
| 30 | The extensible SDK provides a cross-development toolchain and libraries | ||
| 31 | tailored to the contents of a specific image. You would use the | ||
| 32 | Extensible SDK if you want a toolchain experience supplemented with the | ||
| 33 | powerful set of ``devtool`` commands tailored for the Yocto Project | ||
| 34 | environment. | ||
| 35 | |||
| 36 | The installed extensible SDK consists of several files and directories. | ||
| 37 | Basically, it contains an SDK environment setup script, some | ||
| 38 | configuration files, an internal build system, and the ``devtool`` | ||
| 39 | functionality. | ||
| 40 | |||
| 41 | Installing the Extensible SDK | ||
| 42 | ============================= | ||
| 43 | |||
| 44 | Two ways to install the Extensible SDK | ||
| 45 | -------------------------------------- | ||
| 46 | |||
| 47 | Extensible SDK can be installed in two different ways, and both have | ||
| 48 | their own pros and cons: | ||
| 49 | |||
| 50 | #. *Setting up the Extensible SDK environment directly in a Yocto build*. This | ||
| 51 | avoids having to produce, test, distribute and maintain separate SDK | ||
| 52 | installer archives, which can get very large. There is only one environment | ||
| 53 | for the regular Yocto build and the SDK and less code paths where things can | ||
| 54 | go not according to plan. It's easier to update the SDK: it simply means | ||
| 55 | updating the Yocto layers with git fetch or layer management tooling. The | ||
| 56 | SDK extensibility is better than in the second option: just run ``bitbake`` | ||
| 57 | again to add more things to the sysroot, or add layers if even more things | ||
| 58 | are required. | ||
| 59 | |||
| 60 | #. *Setting up the Extensible SDK from a standalone installer*. This has the | ||
| 61 | benefit of having a single, self-contained archive that includes all the | ||
| 62 | needed binary artifacts. So nothing needs to be rebuilt, and there is no | ||
| 63 | need to provide a well-functioning binary artefact cache over the network | ||
| 64 | for developers with underpowered laptops. | ||
| 65 | |||
| 66 | .. _setting_up_ext_sdk_in_build: | ||
| 67 | |||
| 68 | Setting up the Extensible SDK environment directly in a Yocto build | ||
| 69 | ------------------------------------------------------------------- | ||
| 70 | |||
| 71 | #. Set up all the needed layers and a Yocto :term:`Build Directory`, e.g. a regular Yocto | ||
| 72 | build where ``bitbake`` can be executed. | ||
| 73 | |||
| 74 | #. Run:: | ||
| 75 | |||
| 76 | $ bitbake meta-ide-support | ||
| 77 | $ bitbake -c populate_sysroot gtk+3 | ||
| 78 | # or any other target or native item that the application developer would need | ||
| 79 | $ bitbake build-sysroots -c build_native_sysroot && bitbake build-sysroots -c build_target_sysroot | ||
| 80 | |||
| 81 | Setting up the Extensible SDK from a standalone installer | ||
| 82 | --------------------------------------------------------- | ||
| 83 | |||
| 84 | The first thing you need to do is install the SDK on your :term:`Build | ||
| 85 | Host` by running the ``*.sh`` installation script. | ||
| 86 | |||
| 87 | You can download a tarball installer, which includes the pre-built | ||
| 88 | toolchain, the ``runqemu`` script, the internal build system, | ||
| 89 | ``devtool``, and support files from the appropriate | ||
| 90 | :yocto_dl:`toolchain </releases/yocto/&DISTRO_REL_LATEST_TAG;/toolchain/>` directory within the Index of | ||
| 91 | Releases. Toolchains are available for several 32-bit and 64-bit | ||
| 92 | architectures with the ``x86_64`` directories, respectively. The | ||
| 93 | toolchains the Yocto Project provides are based off the | ||
| 94 | ``core-image-sato`` and ``core-image-minimal`` images and contain | ||
| 95 | libraries appropriate for developing against that image. | ||
| 96 | |||
| 97 | The names of the tarball installer scripts are such that a string | ||
| 98 | representing the host system appears first in the filename and then is | ||
| 99 | immediately followed by a string representing the target architecture. | ||
| 100 | An extensible SDK has the string "-ext" as part of the name. Following | ||
| 101 | is the general form:: | ||
| 102 | |||
| 103 | poky-glibc-host_system-image_type-arch-toolchain-ext-release_version.sh | ||
| 104 | |||
| 105 | Where: | ||
| 106 | host_system is a string representing your development system: | ||
| 107 | |||
| 108 | i686 or x86_64. | ||
| 109 | |||
| 110 | image_type is the image for which the SDK was built: | ||
| 111 | |||
| 112 | core-image-sato or core-image-minimal | ||
| 113 | |||
| 114 | arch is a string representing the tuned target architecture: | ||
| 115 | |||
| 116 | aarch64, armv5e, core2-64, i586, mips32r2, mips64, ppc7400, or cortexa8hf-neon | ||
| 117 | |||
| 118 | release_version is a string representing the release number of the Yocto Project: | ||
| 119 | |||
| 120 | &DISTRO;, &DISTRO;+snapshot | ||
| 121 | |||
| 122 | For example, the following SDK installer is for a 64-bit | ||
| 123 | development host system and a i586-tuned target architecture based off | ||
| 124 | the SDK for ``core-image-sato`` and using the current &DISTRO; snapshot:: | ||
| 125 | |||
| 126 | poky-glibc-x86_64-core-image-sato-i586-toolchain-ext-&DISTRO;.sh | ||
| 127 | |||
| 128 | .. note:: | ||
| 129 | |||
| 130 | As an alternative to downloading an SDK, you can build the SDK | ||
| 131 | installer. For information on building the installer, see the | ||
| 132 | :ref:`sdk-manual/appendix-obtain:building an sdk installer` | ||
| 133 | section. | ||
| 134 | |||
| 135 | The SDK and toolchains are self-contained and by default are installed | ||
| 136 | into the ``poky_sdk`` folder in your home directory. You can choose to | ||
| 137 | install the extensible SDK in any location when you run the installer. | ||
| 138 | However, because files need to be written under that directory during | ||
| 139 | the normal course of operation, the location you choose for installation | ||
| 140 | must be writable for whichever users need to use the SDK. | ||
| 141 | |||
| 142 | The following command shows how to run the installer given a toolchain | ||
| 143 | tarball for a 64-bit x86 development host system and a 64-bit x86 target | ||
| 144 | architecture. The example assumes the SDK installer is located in | ||
| 145 | ``~/Downloads/`` and has execution rights:: | ||
| 146 | |||
| 147 | $ ./Downloads/poky-glibc-x86_64-core-image-minimal-core2-64-toolchain-ext-2.5.sh | ||
| 148 | Poky (Yocto Project Reference Distro) Extensible SDK installer version 2.5 | ||
| 149 | ========================================================================== | ||
| 150 | Enter target directory for SDK (default: poky_sdk): | ||
| 151 | You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed [Y/n]? Y | ||
| 152 | Extracting SDK..............done | ||
| 153 | Setting it up... | ||
| 154 | Extracting buildtools... | ||
| 155 | Preparing build system... | ||
| 156 | Parsing recipes: 100% |##################################################################| Time: 0:00:52 | ||
| 157 | Initialising tasks: 100% |###############################################################| Time: 0:00:00 | ||
| 158 | Checking sstate mirror object availability: 100% |#######################################| Time: 0:00:00 | ||
| 159 | Loading cache: 100% |####################################################################| Time: 0:00:00 | ||
| 160 | Initialising tasks: 100% |###############################################################| Time: 0:00:00 | ||
| 161 | done | ||
| 162 | SDK has been successfully set up and is ready to be used. | ||
| 163 | Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. | ||
| 164 | $ . /home/scottrif/poky_sdk/environment-setup-core2-64-poky-linux | ||
| 165 | |||
| 166 | .. note:: | ||
| 167 | |||
| 168 | If you do not have write permissions for the directory into which you | ||
| 169 | are installing the SDK, the installer notifies you and exits. For | ||
| 170 | that case, set up the proper permissions in the directory and run the | ||
| 171 | installer again. | ||
| 172 | |||
| 173 | .. _running_the_ext_sdk_env: | ||
| 174 | |||
| 175 | Running the Extensible SDK Environment Setup Script | ||
| 176 | =================================================== | ||
| 177 | |||
| 178 | Once you have the SDK installed, you must run the SDK environment setup | ||
| 179 | script before you can actually use the SDK. | ||
| 180 | |||
| 181 | When using an SDK directly in a Yocto build, you will find the script in | ||
| 182 | ``tmp/deploy/images/qemux86-64/`` in your :term:`Build Directory`. | ||
| 183 | |||
| 184 | When using a standalone SDK installer, this setup script resides in | ||
| 185 | the directory you chose when you installed the SDK, which is either the | ||
| 186 | default ``poky_sdk`` directory or the directory you chose during | ||
| 187 | installation. | ||
| 188 | |||
| 189 | Before running the script, be sure it is the one that matches the | ||
| 190 | architecture for which you are developing. Environment setup scripts | ||
| 191 | begin with the string "``environment-setup``" and include as part of | ||
| 192 | their name the tuned target architecture. As an example, the following | ||
| 193 | commands set the working directory to where the SDK was installed and | ||
| 194 | then source the environment setup script. In this example, the setup | ||
| 195 | script is for an IA-based target machine using i586 tuning:: | ||
| 196 | |||
| 197 | $ cd /home/scottrif/poky_sdk | ||
| 198 | $ source environment-setup-core2-64-poky-linux | ||
| 199 | SDK environment now set up; additionally you may now run devtool to perform development tasks. | ||
| 200 | Run devtool --help for further details. | ||
| 201 | |||
| 202 | When using the environment script directly in a Yocto build, it can | ||
| 203 | be run similarly:: | ||
| 204 | |||
| 205 | $ source tmp/deploy/images/qemux86-64/environment-setup-core2-64-poky-linux | ||
| 206 | |||
| 207 | Running the setup script defines many environment variables needed in order to | ||
| 208 | use the SDK (e.g. ``PATH``, :term:`CC`, :term:`LD`, and so forth). If you want | ||
| 209 | to see all the environment variables the script exports, examine the | ||
| 210 | installation file itself. | ||
| 211 | |||
| 212 | .. _using_devtool: | ||
| 213 | |||
| 214 | Using ``devtool`` in Your SDK Workflow | ||
| 215 | ====================================== | ||
| 216 | |||
| 217 | The cornerstone of the extensible SDK is a command-line tool called | ||
| 218 | ``devtool``. This tool provides a number of features that help you | ||
| 219 | build, test and package software within the extensible SDK, and | ||
| 220 | optionally integrate it into an image built by the OpenEmbedded build | ||
| 221 | system. | ||
| 222 | |||
| 223 | .. note:: | ||
| 224 | |||
| 225 | The use of ``devtool`` is not limited to the extensible SDK. You can use | ||
| 226 | ``devtool`` to help you easily develop any project whose build output must be | ||
| 227 | part of an image built using the build system. | ||
| 228 | |||
| 229 | The ``devtool`` command line is organized similarly to | ||
| 230 | :ref:`overview-manual/development-environment:git` in that it has a number of | ||
| 231 | sub-commands for each function. You can run ``devtool --help`` to see | ||
| 232 | all the commands. | ||
| 233 | |||
| 234 | .. note:: | ||
| 235 | |||
| 236 | See the ":doc:`/ref-manual/devtool-reference`" | ||
| 237 | section in the Yocto Project Reference Manual. | ||
| 238 | |||
| 239 | ``devtool`` subcommands provide entry-points into development: | ||
| 240 | |||
| 241 | - *devtool add*: Assists in adding new software to be built. | ||
| 242 | |||
| 243 | - *devtool modify*: Sets up an environment to enable you to modify | ||
| 244 | the source of an existing component. | ||
| 245 | |||
| 246 | - *devtool ide-sdk*: Generates a configuration for an IDE. | ||
| 247 | |||
| 248 | - *devtool upgrade*: Updates an existing recipe so that you can | ||
| 249 | build it for an updated set of source files. | ||
| 250 | |||
| 251 | As with the build system, "recipes" represent software packages within | ||
| 252 | ``devtool``. When you use ``devtool add``, a recipe is automatically | ||
| 253 | created. When you use ``devtool modify``, the specified existing recipe | ||
| 254 | is used in order to determine where to get the source code and how to | ||
| 255 | patch it. In both cases, an environment is set up so that when you build | ||
| 256 | the recipe a source tree that is under your control is used in order to | ||
| 257 | allow you to make changes to the source as desired. By default, new | ||
| 258 | recipes and the source go into a "workspace" directory under the SDK. | ||
| 259 | |||
| 260 | To learn how to use ``devtool`` to add, modify, upgrade recipes and more, see | ||
| 261 | the :ref:`dev-manual/devtool:Using the \`\`devtool\`\` command-line tool` | ||
| 262 | section of the Yocto Project Development Tasks Manual. | ||
| 263 | |||
| 264 | Installing Additional Items Into the Extensible SDK | ||
| 265 | =================================================== | ||
| 266 | |||
| 267 | Out of the box the extensible SDK typically only comes with a small | ||
| 268 | number of tools and libraries. A minimal SDK starts mostly empty and is | ||
| 269 | populated on-demand. Sometimes you must explicitly install extra items | ||
| 270 | into the SDK. If you need these extra items, you can first search for | ||
| 271 | the items using the ``devtool search`` command. For example, suppose you | ||
| 272 | need to link to libGL but you are not sure which recipe provides libGL. | ||
| 273 | You can use the following command to find out:: | ||
| 274 | |||
| 275 | $ devtool search libGL mesa | ||
| 276 | A free implementation of the OpenGL API | ||
| 277 | |||
| 278 | Once you know the recipe | ||
| 279 | (i.e. ``mesa`` in this example), you can install it. | ||
| 280 | |||
| 281 | When using the extensible SDK directly in a Yocto build | ||
| 282 | ------------------------------------------------------- | ||
| 283 | |||
| 284 | In this scenario, the Yocto build tooling, e.g. ``bitbake`` | ||
| 285 | is directly accessible to build additional items, and it | ||
| 286 | can simply be executed directly:: | ||
| 287 | |||
| 288 | $ bitbake curl-native | ||
| 289 | # Add newly built native items to native sysroot | ||
| 290 | $ bitbake build-sysroots -c build_native_sysroot | ||
| 291 | $ bitbake mesa | ||
| 292 | # Add newly built target items to target sysroot | ||
| 293 | $ bitbake build-sysroots -c build_target_sysroot | ||
| 294 | |||
| 295 | When using a standalone installer for the Extensible SDK | ||
| 296 | -------------------------------------------------------- | ||
| 297 | |||
| 298 | :: | ||
| 299 | |||
| 300 | $ devtool sdk-install mesa | ||
| 301 | |||
| 302 | By default, the ``devtool sdk-install`` command assumes | ||
| 303 | the item is available in pre-built form from your SDK provider. If the | ||
| 304 | item is not available and it is acceptable to build the item from | ||
| 305 | source, you can add the "-s" option as follows:: | ||
| 306 | |||
| 307 | $ devtool sdk-install -s mesa | ||
| 308 | |||
| 309 | It is important to remember that building the item from source | ||
| 310 | takes significantly longer than installing the pre-built artifact. Also, | ||
| 311 | if there is no recipe for the item you want to add to the SDK, you must | ||
| 312 | instead add the item using the ``devtool add`` command. | ||
| 313 | |||
| 314 | Applying Updates to an Installed Extensible SDK | ||
| 315 | =============================================== | ||
| 316 | |||
| 317 | If you are working with an installed extensible SDK that gets | ||
| 318 | occasionally updated (e.g. a third-party SDK), then you will need to | ||
| 319 | manually "pull down" the updates into the installed SDK. | ||
| 320 | |||
| 321 | To update your installed SDK, use ``devtool`` as follows:: | ||
| 322 | |||
| 323 | $ devtool sdk-update | ||
| 324 | |||
| 325 | The previous command assumes your SDK provider has set the default update URL | ||
| 326 | for you through the :term:`SDK_UPDATE_URL` variable as described in the | ||
| 327 | ":ref:`sdk-manual/appendix-customizing:Providing Updates to the Extensible SDK After Installation`" | ||
| 328 | section. If the SDK provider has not set that default URL, you need to | ||
| 329 | specify it yourself in the command as follows:: | ||
| 330 | |||
| 331 | $ devtool sdk-update path_to_update_directory | ||
| 332 | |||
| 333 | .. note:: | ||
| 334 | |||
| 335 | The URL needs to point specifically to a published SDK and not to an | ||
| 336 | SDK installer that you would download and install. | ||
| 337 | |||
| 338 | Creating a Derivative SDK With Additional Components | ||
| 339 | ==================================================== | ||
| 340 | |||
| 341 | You might need to produce an SDK that contains your own custom | ||
| 342 | libraries. A good example would be if you were a vendor with customers | ||
| 343 | that use your SDK to build their own platform-specific software and | ||
| 344 | those customers need an SDK that has custom libraries. In such a case, | ||
| 345 | you can produce a derivative SDK based on the currently installed SDK | ||
| 346 | fairly easily by following these steps: | ||
| 347 | |||
| 348 | #. If necessary, install an extensible SDK that you want to use as a | ||
| 349 | base for your derivative SDK. | ||
| 350 | |||
| 351 | #. Source the environment script for the SDK. | ||
| 352 | |||
| 353 | #. Add the extra libraries or other components you want by using the | ||
| 354 | ``devtool add`` command. | ||
| 355 | |||
| 356 | #. Run the ``devtool build-sdk`` command. | ||
| 357 | |||
| 358 | The previous steps take the recipes added to the workspace and construct | ||
| 359 | a new SDK installer that contains those recipes and the resulting binary | ||
| 360 | artifacts. The recipes go into their own separate layer in the | ||
| 361 | constructed derivative SDK, which leaves the workspace clean and ready | ||
| 362 | for users to add their own recipes. | ||
diff --git a/documentation/sdk-manual/figures/sdk-autotools-flow.png b/documentation/sdk-manual/figures/sdk-autotools-flow.png deleted file mode 100644 index ec6685f8b6..0000000000 --- a/documentation/sdk-manual/figures/sdk-autotools-flow.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/sdk-manual/figures/sdk-environment.png b/documentation/sdk-manual/figures/sdk-environment.png deleted file mode 100644 index 78b8cad39e..0000000000 --- a/documentation/sdk-manual/figures/sdk-environment.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/sdk-manual/figures/sdk-installed-extensible-sdk-directory.png b/documentation/sdk-manual/figures/sdk-installed-extensible-sdk-directory.png deleted file mode 100644 index b71c8ad73c..0000000000 --- a/documentation/sdk-manual/figures/sdk-installed-extensible-sdk-directory.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/sdk-manual/figures/sdk-installed-standard-sdk-directory.png b/documentation/sdk-manual/figures/sdk-installed-standard-sdk-directory.png deleted file mode 100644 index 45c0154b19..0000000000 --- a/documentation/sdk-manual/figures/sdk-installed-standard-sdk-directory.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/sdk-manual/figures/sdk-makefile-flow.png b/documentation/sdk-manual/figures/sdk-makefile-flow.png deleted file mode 100644 index 0ccb4180a3..0000000000 --- a/documentation/sdk-manual/figures/sdk-makefile-flow.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/sdk-manual/figures/sdk-title.png b/documentation/sdk-manual/figures/sdk-title.png deleted file mode 100644 index e69e03935a..0000000000 --- a/documentation/sdk-manual/figures/sdk-title.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/sdk-manual/index.rst b/documentation/sdk-manual/index.rst deleted file mode 100644 index dc7186b911..0000000000 --- a/documentation/sdk-manual/index.rst +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ======================================================================================== | ||
| 4 | Yocto Project Application Development and the Extensible Software Development Kit (eSDK) | ||
| 5 | ======================================================================================== | ||
| 6 | |||
| 7 | | | ||
| 8 | |||
| 9 | .. toctree:: | ||
| 10 | :caption: Table of Contents | ||
| 11 | :numbered: | ||
| 12 | |||
| 13 | intro | ||
| 14 | extensible | ||
| 15 | using | ||
| 16 | working-projects | ||
| 17 | appendix-obtain | ||
| 18 | appendix-customizing | ||
| 19 | appendix-customizing-standard | ||
| 20 | |||
| 21 | .. include:: /boilerplate.rst | ||
diff --git a/documentation/sdk-manual/intro.rst b/documentation/sdk-manual/intro.rst deleted file mode 100644 index fbfc8c2ac7..0000000000 --- a/documentation/sdk-manual/intro.rst +++ /dev/null | |||
| @@ -1,208 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ************ | ||
| 4 | Introduction | ||
| 5 | ************ | ||
| 6 | |||
| 7 | eSDK Introduction | ||
| 8 | ================= | ||
| 9 | |||
| 10 | Welcome to the Yocto Project Application Development and the Extensible | ||
| 11 | Software Development Kit (eSDK) manual. This manual | ||
| 12 | explains how to use both the Yocto Project extensible and standard | ||
| 13 | SDKs to develop applications and images. | ||
| 14 | |||
| 15 | All SDKs consist of the following: | ||
| 16 | |||
| 17 | - *Cross-Development Toolchain*: This toolchain contains a compiler, | ||
| 18 | debugger, and various associated tools. | ||
| 19 | |||
| 20 | - *Libraries, Headers, and Symbols*: The libraries, headers, and | ||
| 21 | symbols are specific to the image (i.e. they match the image | ||
| 22 | against which the SDK was built). | ||
| 23 | |||
| 24 | - *Environment Setup Script*: This ``*.sh`` file, once sourced, sets up the | ||
| 25 | cross-development environment by defining variables and preparing for | ||
| 26 | SDK use. | ||
| 27 | |||
| 28 | Additionally, an extensible SDK has tools that allow you to easily add | ||
| 29 | new applications and libraries to an image, modify the source of an | ||
| 30 | existing component, test changes on the target hardware, and easily | ||
| 31 | integrate an application into the :term:`OpenEmbedded Build System`. | ||
| 32 | |||
| 33 | You can use an SDK to independently develop and test code that is | ||
| 34 | destined to run on some target machine. SDKs are completely | ||
| 35 | self-contained. The binaries are linked against their own copy of | ||
| 36 | ``libc``, which results in no dependencies on the target system. To | ||
| 37 | achieve this, the pointer to the dynamic loader is configured at install | ||
| 38 | time since that path cannot be dynamically altered. This is the reason | ||
| 39 | for a wrapper around the ``populate_sdk`` and ``populate_sdk_ext`` | ||
| 40 | archives. | ||
| 41 | |||
| 42 | Another feature of the SDKs is that only one set of cross-compiler | ||
| 43 | toolchain binaries are produced for any given architecture. This feature | ||
| 44 | takes advantage of the fact that the target hardware can be passed to | ||
| 45 | ``gcc`` as a set of compiler options. Those options are set up by the | ||
| 46 | environment script and contained in variables such as | ||
| 47 | :term:`CC` and | ||
| 48 | :term:`LD`. This reduces the space needed | ||
| 49 | for the tools. Understand, however, that every target still needs its own | ||
| 50 | sysroot because those binaries are target-specific. | ||
| 51 | |||
| 52 | The SDK development environment consists of the following: | ||
| 53 | |||
| 54 | - The self-contained SDK, which is an architecture-specific | ||
| 55 | cross-toolchain and matching sysroots (target and native) all built | ||
| 56 | by the OpenEmbedded build system (e.g. the SDK). The toolchain and | ||
| 57 | sysroots are based on a :term:`Metadata` | ||
| 58 | configuration and extensions, which allows you to cross-develop on | ||
| 59 | the host machine for the target hardware. Additionally, the | ||
| 60 | extensible SDK contains the ``devtool`` functionality. | ||
| 61 | |||
| 62 | - The Quick EMUlator (QEMU), which lets you simulate target hardware. | ||
| 63 | QEMU is not literally part of the SDK. You must build and include | ||
| 64 | this emulator separately. However, QEMU plays an important role in | ||
| 65 | the development process that revolves around use of the SDK. | ||
| 66 | |||
| 67 | In summary, the extensible and standard SDK share many features. | ||
| 68 | However, the extensible SDK has powerful development tools to help you | ||
| 69 | more quickly develop applications. Here is a table that summarizes | ||
| 70 | the primary differences between the standard and extensible SDK types | ||
| 71 | when considering which to build: | ||
| 72 | |||
| 73 | +-----------------------+-----------------------+-----------------------+ | ||
| 74 | | *Feature* | *Standard SDK* | *Extensible SDK* | | ||
| 75 | +=======================+=======================+=======================+ | ||
| 76 | | Toolchain | Yes | Yes [1]_ | | ||
| 77 | +-----------------------+-----------------------+-----------------------+ | ||
| 78 | | Debugger | Yes | Yes [1]_ | | ||
| 79 | +-----------------------+-----------------------+-----------------------+ | ||
| 80 | | Size | 100+ MBytes | 1+ GBytes (or 300+ | | ||
| 81 | | | | MBytes for minimal | | ||
| 82 | | | | w/toolchain) | | ||
| 83 | +-----------------------+-----------------------+-----------------------+ | ||
| 84 | | ``devtool`` | No | Yes | | ||
| 85 | +-----------------------+-----------------------+-----------------------+ | ||
| 86 | | Build Images | No | Yes | | ||
| 87 | +-----------------------+-----------------------+-----------------------+ | ||
| 88 | | Updateable | No | Yes | | ||
| 89 | +-----------------------+-----------------------+-----------------------+ | ||
| 90 | | Managed Sysroot [2]_ | No | Yes | | ||
| 91 | +-----------------------+-----------------------+-----------------------+ | ||
| 92 | | Installed Packages | No [3]_ | Yes [4]_ | | ||
| 93 | +-----------------------+-----------------------+-----------------------+ | ||
| 94 | | Construction | Packages | Shared State | | ||
| 95 | +-----------------------+-----------------------+-----------------------+ | ||
| 96 | |||
| 97 | .. [1] Extensible SDK contains the toolchain and debugger if :term:`SDK_EXT_TYPE` | ||
| 98 | is "full" or :term:`SDK_INCLUDE_TOOLCHAIN` is "1", which is the default. | ||
| 99 | .. [2] Sysroot is managed through the use of ``devtool``. Thus, it is less | ||
| 100 | likely that you will corrupt your SDK sysroot when you try to add | ||
| 101 | additional libraries. | ||
| 102 | .. [3] You can add runtime package management to the standard SDK but it is not | ||
| 103 | supported by default. | ||
| 104 | .. [4] You must build and make the shared state available to extensible SDK | ||
| 105 | users for "packages" you want to enable users to install. | ||
| 106 | |||
| 107 | The Cross-Development Toolchain | ||
| 108 | ------------------------------- | ||
| 109 | |||
| 110 | The :term:`Cross-Development Toolchain` consists | ||
| 111 | of a cross-compiler, cross-linker, and cross-debugger that are used to | ||
| 112 | develop user-space applications for targeted hardware; in addition, | ||
| 113 | the extensible SDK comes with built-in ``devtool`` | ||
| 114 | functionality. This toolchain is created by running a SDK installer | ||
| 115 | script or through a :term:`Build Directory` that is based on | ||
| 116 | your metadata configuration or extension for your targeted device. The | ||
| 117 | cross-toolchain works with a matching target sysroot. | ||
| 118 | |||
| 119 | Sysroots | ||
| 120 | -------- | ||
| 121 | |||
| 122 | The native and target sysroots contain needed headers and libraries for | ||
| 123 | generating binaries that run on the target architecture. The target | ||
| 124 | sysroot is based on the target root filesystem image that is built by | ||
| 125 | the OpenEmbedded build system and uses the same metadata configuration | ||
| 126 | used to build the cross-toolchain. | ||
| 127 | |||
| 128 | The QEMU Emulator | ||
| 129 | ----------------- | ||
| 130 | |||
| 131 | The QEMU emulator allows you to simulate your hardware while running | ||
| 132 | your application or image. QEMU is not part of the SDK but is | ||
| 133 | automatically installed and available if you have done any one of | ||
| 134 | the following: | ||
| 135 | |||
| 136 | - cloned the ``poky`` Git repository to create a | ||
| 137 | :term:`Source Directory` and sourced the environment setup script. | ||
| 138 | |||
| 139 | - downloaded a Yocto Project release and unpacked it to | ||
| 140 | create a Source Directory and sourced the environment setup | ||
| 141 | script. | ||
| 142 | |||
| 143 | - installed the cross-toolchain tarball and | ||
| 144 | sourced the toolchain's setup environment script. | ||
| 145 | |||
| 146 | SDK Development Model | ||
| 147 | ===================== | ||
| 148 | |||
| 149 | Fundamentally, the SDK fits into the development process as follows: | ||
| 150 | |||
| 151 | .. image:: figures/sdk-environment.png | ||
| 152 | :width: 100% | ||
| 153 | |||
| 154 | The SDK is installed on any machine and can be used to develop applications, | ||
| 155 | images, and kernels. An SDK can even be used by a QA Engineer or Release | ||
| 156 | Engineer. The fundamental concept is that the machine that has the SDK | ||
| 157 | installed does not have to be associated with the machine that has the | ||
| 158 | Yocto Project installed. A developer can independently compile and test | ||
| 159 | an object on their machine and then, when the object is ready for | ||
| 160 | integration into an image, they can simply make it available to the | ||
| 161 | machine that has the Yocto Project. Once the object is available, the | ||
| 162 | image can be rebuilt using the Yocto Project to produce the modified | ||
| 163 | image. | ||
| 164 | |||
| 165 | You just need to follow these general steps: | ||
| 166 | |||
| 167 | #. *Install the SDK for your target hardware:* For information on how to | ||
| 168 | install the SDK, see the ":ref:`sdk-manual/using:installing the sdk`" | ||
| 169 | section. | ||
| 170 | |||
| 171 | #. *Download or Build the Target Image:* The Yocto Project supports | ||
| 172 | several target architectures and has many pre-built kernel images and | ||
| 173 | root filesystem images. | ||
| 174 | |||
| 175 | If you are going to develop your application on hardware, go to the | ||
| 176 | :yocto_dl:`machines </releases/yocto/&DISTRO_REL_LATEST_TAG;/machines/>` download area and choose a | ||
| 177 | target machine area from which to download the kernel image and root | ||
| 178 | filesystem. This download area could have several files in it that | ||
| 179 | support development using actual hardware. For example, the area | ||
| 180 | might contain ``.hddimg`` files that combine the kernel image with | ||
| 181 | the filesystem, boot loaders, and so forth. Be sure to get the files | ||
| 182 | you need for your particular development process. | ||
| 183 | |||
| 184 | If you are going to develop your application and then run and test it | ||
| 185 | using the QEMU emulator, go to the | ||
| 186 | :yocto_dl:`machines/qemu </releases/yocto/&DISTRO_REL_LATEST_TAG;/machines/qemu>` download area. From this | ||
| 187 | area, go down into the directory for your target architecture (e.g. | ||
| 188 | ``qemux86_64`` for an Intel-based 64-bit architecture). Download the | ||
| 189 | kernel, root filesystem, and any other files you need for your | ||
| 190 | process. | ||
| 191 | |||
| 192 | .. note:: | ||
| 193 | |||
| 194 | To use the root filesystem in QEMU, you need to extract it. See the | ||
| 195 | ":ref:`sdk-manual/appendix-obtain:extracting the root filesystem`" | ||
| 196 | section for information on how to do this extraction. | ||
| 197 | |||
| 198 | #. *Develop and Test your Application:* At this point, you have the | ||
| 199 | tools to develop your application. If you need to separately install | ||
| 200 | and use the QEMU emulator, you can go to `QEMU Home | ||
| 201 | Page <https://wiki.qemu.org/Main_Page>`__ to download and learn about | ||
| 202 | the emulator. See the ":doc:`/dev-manual/qemu`" chapter in the | ||
| 203 | Yocto Project Development Tasks Manual for information on using QEMU | ||
| 204 | within the Yocto Project. | ||
| 205 | |||
| 206 | The remainder of this manual describes how to use the extensible and | ||
| 207 | standard SDKs. There is also information in appendix form describing | ||
| 208 | how you can build, install, and modify an SDK. | ||
diff --git a/documentation/sdk-manual/using.rst b/documentation/sdk-manual/using.rst deleted file mode 100644 index bfb306abf5..0000000000 --- a/documentation/sdk-manual/using.rst +++ /dev/null | |||
| @@ -1,147 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ********************** | ||
| 4 | Using the Standard SDK | ||
| 5 | ********************** | ||
| 6 | |||
| 7 | This chapter describes the standard SDK and how to install it. | ||
| 8 | Information includes unique installation and setup aspects for the | ||
| 9 | standard SDK. | ||
| 10 | |||
| 11 | .. note:: | ||
| 12 | |||
| 13 | For a side-by-side comparison of main features supported for a | ||
| 14 | standard SDK as compared to an extensible SDK, see the | ||
| 15 | ":ref:`sdk-manual/intro:introduction`" section. | ||
| 16 | |||
| 17 | You can use a standard SDK to work on Makefile and Autotools-based | ||
| 18 | projects. See the | ||
| 19 | ":ref:`sdk-manual/working-projects:using the sdk toolchain directly`" chapter | ||
| 20 | for more information. | ||
| 21 | |||
| 22 | Why use the Standard SDK and What is in It? | ||
| 23 | =========================================== | ||
| 24 | |||
| 25 | The Standard SDK provides a cross-development toolchain and libraries | ||
| 26 | tailored to the contents of a specific image. You would use the Standard | ||
| 27 | SDK if you want a more traditional toolchain experience as compared to | ||
| 28 | the extensible SDK, which provides an internal build system and the | ||
| 29 | ``devtool`` functionality. | ||
| 30 | |||
| 31 | The installed Standard SDK consists of several files and directories. | ||
| 32 | Basically, it contains an SDK environment setup script, some | ||
| 33 | configuration files, and host and target root filesystems to support | ||
| 34 | usage. You can see the directory structure in the | ||
| 35 | ":ref:`sdk-manual/appendix-obtain:installed standard sdk directory structure`" | ||
| 36 | section. | ||
| 37 | |||
| 38 | Installing the SDK | ||
| 39 | ================== | ||
| 40 | |||
| 41 | The first thing you need to do is install the SDK on your :term:`Build | ||
| 42 | Host` by running the ``*.sh`` installation script. | ||
| 43 | |||
| 44 | You can download a tarball installer, which includes the pre-built | ||
| 45 | toolchain, the ``runqemu`` script, and support files from the | ||
| 46 | appropriate :yocto_dl:`toolchain </releases/yocto/&DISTRO_REL_LATEST_TAG;/toolchain/>` directory within | ||
| 47 | the Index of Releases. Toolchains are available for several 32-bit and | ||
| 48 | 64-bit architectures with the ``x86_64`` directories, respectively. The | ||
| 49 | toolchains the Yocto Project provides are based off the | ||
| 50 | ``core-image-sato`` and ``core-image-minimal`` images and contain | ||
| 51 | libraries appropriate for developing against the corresponding image. | ||
| 52 | |||
| 53 | The names of the tarball installer scripts are such that a string | ||
| 54 | representing the host system appears first in the filename and then is | ||
| 55 | immediately followed by a string representing the target architecture:: | ||
| 56 | |||
| 57 | poky-glibc-host_system-image_type-arch-toolchain-release_version.sh | ||
| 58 | |||
| 59 | Where: | ||
| 60 | host_system is a string representing your development system: | ||
| 61 | |||
| 62 | i686 or x86_64. | ||
| 63 | |||
| 64 | image_type is the image for which the SDK was built: | ||
| 65 | |||
| 66 | core-image-minimal or core-image-sato. | ||
| 67 | |||
| 68 | arch is a string representing the tuned target architecture: | ||
| 69 | |||
| 70 | aarch64, armv5e, core2-64, i586, mips32r2, mips64, ppc7400, or cortexa8hf-neon. | ||
| 71 | |||
| 72 | release_version is a string representing the release number of the Yocto Project: | ||
| 73 | |||
| 74 | &DISTRO;, &DISTRO;+snapshot | ||
| 75 | |||
| 76 | For example, the following SDK installer is for a 64-bit | ||
| 77 | development host system and a i586-tuned target architecture based off | ||
| 78 | the SDK for ``core-image-sato`` and using the current DISTRO snapshot:: | ||
| 79 | |||
| 80 | poky-glibc-x86_64-core-image-sato-i586-toolchain-DISTRO.sh | ||
| 81 | |||
| 82 | .. note:: | ||
| 83 | |||
| 84 | As an alternative to downloading an SDK, you can build the SDK | ||
| 85 | installer. For information on building the installer, see the | ||
| 86 | ":ref:`sdk-manual/appendix-obtain:building an sdk installer`" | ||
| 87 | section. | ||
| 88 | |||
| 89 | The SDK and toolchains are self-contained and by default are installed | ||
| 90 | into the ``poky_sdk`` folder in your home directory. You can choose to | ||
| 91 | install the extensible SDK in any location when you run the installer. | ||
| 92 | However, because files need to be written under that directory during | ||
| 93 | the normal course of operation, the location you choose for installation | ||
| 94 | must be writable for whichever users need to use the SDK. | ||
| 95 | |||
| 96 | The following command shows how to run the installer given a toolchain | ||
| 97 | tarball for a 64-bit x86 development host system and a 64-bit x86 target | ||
| 98 | architecture. The example assumes the SDK installer is located in | ||
| 99 | ``~/Downloads/`` and has execution rights:: | ||
| 100 | |||
| 101 | $ ./Downloads/poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh | ||
| 102 | Poky (Yocto Project Reference Distro) SDK installer version &DISTRO; | ||
| 103 | =============================================================== | ||
| 104 | Enter target directory for SDK (default: /opt/poky/&DISTRO;): | ||
| 105 | You are about to install the SDK to "/opt/poky/&DISTRO;". Proceed [Y/n]? Y | ||
| 106 | Extracting SDK........................................ ..............................done | ||
| 107 | Setting it up...done | ||
| 108 | SDK has been successfully set up and is ready to be used. | ||
| 109 | Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. | ||
| 110 | $ . /opt/poky/&DISTRO;/environment-setup-i586-poky-linux | ||
| 111 | |||
| 112 | .. note:: | ||
| 113 | |||
| 114 | If you do not have write permissions for the directory into which you | ||
| 115 | are installing the SDK, the installer notifies you and exits. For | ||
| 116 | that case, set up the proper permissions in the directory and run the | ||
| 117 | installer again. | ||
| 118 | |||
| 119 | Again, reference the | ||
| 120 | ":ref:`sdk-manual/appendix-obtain:installed standard sdk directory structure`" | ||
| 121 | section for more details on the resulting directory structure of the installed | ||
| 122 | SDK. | ||
| 123 | |||
| 124 | Running the SDK Environment Setup Script | ||
| 125 | ======================================== | ||
| 126 | |||
| 127 | Once you have the SDK installed, you must run the SDK environment setup | ||
| 128 | script before you can actually use the SDK. This setup script resides in | ||
| 129 | the directory you chose when you installed the SDK, which is either the | ||
| 130 | default ``/opt/poky/&DISTRO;`` directory or the directory you chose during | ||
| 131 | installation. | ||
| 132 | |||
| 133 | Before running the script, be sure it is the one that matches the | ||
| 134 | architecture for which you are developing. Environment setup scripts | ||
| 135 | begin with the string "``environment-setup``" and include as part of | ||
| 136 | their name the tuned target architecture. As an example, the following | ||
| 137 | commands set the working directory to where the SDK was installed and | ||
| 138 | then source the environment setup script. In this example, the setup | ||
| 139 | script is for an IA-based target machine using i586 tuning:: | ||
| 140 | |||
| 141 | $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux | ||
| 142 | |||
| 143 | When you run the | ||
| 144 | setup script, the same environment variables are defined as are when you | ||
| 145 | run the setup script for an extensible SDK. See the | ||
| 146 | ":ref:`sdk-manual/appendix-obtain:installed extensible sdk directory structure`" | ||
| 147 | section for more information. | ||
diff --git a/documentation/sdk-manual/working-projects.rst b/documentation/sdk-manual/working-projects.rst deleted file mode 100644 index 7df73b1b17..0000000000 --- a/documentation/sdk-manual/working-projects.rst +++ /dev/null | |||
| @@ -1,404 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ******************************** | ||
| 4 | Using the SDK Toolchain Directly | ||
| 5 | ******************************** | ||
| 6 | |||
| 7 | You can use the SDK toolchain directly with Makefile and Autotools-based | ||
| 8 | projects. | ||
| 9 | |||
| 10 | Autotools-Based Projects | ||
| 11 | ======================== | ||
| 12 | |||
| 13 | Once you have a suitable :ref:`sdk-manual/intro:the cross-development toolchain` | ||
| 14 | installed, it is very easy to develop a project using the :wikipedia:`GNU | ||
| 15 | Autotools-based <GNU_Build_System>` workflow, which is outside of the | ||
| 16 | :term:`OpenEmbedded Build System`. | ||
| 17 | |||
| 18 | The following figure presents a simple Autotools workflow. | ||
| 19 | |||
| 20 | .. image:: figures/sdk-autotools-flow.png | ||
| 21 | :align: center | ||
| 22 | :width: 70% | ||
| 23 | |||
| 24 | Follow these steps to create a simple Autotools-based "Hello World" | ||
| 25 | project: | ||
| 26 | |||
| 27 | .. note:: | ||
| 28 | |||
| 29 | For more information on the GNU Autotools workflow, see the same | ||
| 30 | example on the | ||
| 31 | GNOME Developer | ||
| 32 | site. | ||
| 33 | |||
| 34 | #. *Create a Working Directory and Populate It:* Create a clean | ||
| 35 | directory for your project and then make that directory your working | ||
| 36 | location:: | ||
| 37 | |||
| 38 | $ mkdir $HOME/helloworld | ||
| 39 | $ cd $HOME/helloworld | ||
| 40 | |||
| 41 | After setting up the directory, populate it with files needed for the flow. | ||
| 42 | You need a project source file, a file to help with configuration, | ||
| 43 | and a file to help create the Makefile, and a README file: | ||
| 44 | ``hello.c``, ``configure.ac``, ``Makefile.am``, and ``README``, | ||
| 45 | respectively. | ||
| 46 | |||
| 47 | Use the following command to create an empty README file, which is | ||
| 48 | required by GNU Coding Standards:: | ||
| 49 | |||
| 50 | $ touch README | ||
| 51 | |||
| 52 | Create the remaining | ||
| 53 | three files as follows: | ||
| 54 | |||
| 55 | - ``hello.c``:: | ||
| 56 | |||
| 57 | #include <stdio.h> | ||
| 58 | |||
| 59 | int main() | ||
| 60 | { | ||
| 61 | printf("Hello World!\n"); | ||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | |||
| 65 | - ``configure.ac``:: | ||
| 66 | |||
| 67 | AC_INIT(hello,0.1) | ||
| 68 | AM_INIT_AUTOMAKE([foreign]) | ||
| 69 | AC_PROG_CC | ||
| 70 | AC_CONFIG_FILES(Makefile) | ||
| 71 | AC_OUTPUT | ||
| 72 | |||
| 73 | - ``Makefile.am``:: | ||
| 74 | |||
| 75 | bin_PROGRAMS = hello | ||
| 76 | hello_SOURCES = hello.c | ||
| 77 | |||
| 78 | #. *Source the Cross-Toolchain Environment Setup File:* As described | ||
| 79 | earlier in the manual, installing the cross-toolchain creates a | ||
| 80 | cross-toolchain environment setup script in the directory that the | ||
| 81 | SDK was installed. Before you can use the tools to develop your | ||
| 82 | project, you must source this setup script. The script begins with | ||
| 83 | the string "environment-setup" and contains the machine architecture, | ||
| 84 | which is followed by the string "poky-linux". For this example, the | ||
| 85 | command sources a script from the default SDK installation directory | ||
| 86 | that uses the 32-bit Intel x86 Architecture and the &DISTRO; Yocto | ||
| 87 | Project release:: | ||
| 88 | |||
| 89 | $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux | ||
| 90 | |||
| 91 | Another example is sourcing the environment setup directly in a Yocto | ||
| 92 | build:: | ||
| 93 | |||
| 94 | $ source tmp/deploy/images/qemux86-64/environment-setup-core2-64-poky-linux | ||
| 95 | |||
| 96 | #. *Create the configure Script:* Use the ``autoreconf`` command to | ||
| 97 | generate the ``configure`` script:: | ||
| 98 | |||
| 99 | $ autoreconf | ||
| 100 | |||
| 101 | The ``autoreconf`` | ||
| 102 | tool takes care of running the other Autotools such as ``aclocal``, | ||
| 103 | ``autoconf``, and ``automake``. | ||
| 104 | |||
| 105 | .. note:: | ||
| 106 | |||
| 107 | If you get errors from ``configure.ac``, which ``autoreconf`` | ||
| 108 | runs, that indicate missing files, you can use the "-i" option, | ||
| 109 | which ensures missing auxiliary files are copied to the build | ||
| 110 | host. | ||
| 111 | |||
| 112 | #. *Cross-Compile the Project:* This command compiles the project using | ||
| 113 | the cross-compiler. The | ||
| 114 | :term:`CONFIGURE_FLAGS` | ||
| 115 | environment variable provides the minimal arguments for GNU | ||
| 116 | configure:: | ||
| 117 | |||
| 118 | $ ./configure ${CONFIGURE_FLAGS} | ||
| 119 | |||
| 120 | For an Autotools-based | ||
| 121 | project, you can use the cross-toolchain by just passing the | ||
| 122 | appropriate host option to ``configure.sh``. The host option you use | ||
| 123 | is derived from the name of the environment setup script found in the | ||
| 124 | directory in which you installed the cross-toolchain. For example, | ||
| 125 | the host option for an ARM-based target that uses the GNU EABI is | ||
| 126 | ``armv5te-poky-linux-gnueabi``. You will notice that the name of the | ||
| 127 | script is ``environment-setup-armv5te-poky-linux-gnueabi``. Thus, the | ||
| 128 | following command works to update your project and rebuild it using | ||
| 129 | the appropriate cross-toolchain tools:: | ||
| 130 | |||
| 131 | $ ./configure --host=armv5te-poky-linux-gnueabi --with-libtool-sysroot=sysroot_dir | ||
| 132 | |||
| 133 | #. *Make and Install the Project:* These two commands generate and | ||
| 134 | install the project into the destination directory:: | ||
| 135 | |||
| 136 | $ make | ||
| 137 | $ make install DESTDIR=./tmp | ||
| 138 | |||
| 139 | .. note:: | ||
| 140 | |||
| 141 | To learn about environment variables established when you run the | ||
| 142 | cross-toolchain environment setup script and how they are used or | ||
| 143 | overridden by the Makefile, see the | ||
| 144 | :ref:`sdk-manual/working-projects:makefile-based projects` section. | ||
| 145 | |||
| 146 | This next command is a simple way to verify the installation of your | ||
| 147 | project. Running the command prints the architecture on which the | ||
| 148 | binary file can run. This architecture should be the same | ||
| 149 | architecture that the installed cross-toolchain supports:: | ||
| 150 | |||
| 151 | $ file ./tmp/usr/local/bin/hello | ||
| 152 | |||
| 153 | #. *Execute Your Project:* To execute the project, you would need to run | ||
| 154 | it on your target hardware. If your target hardware happens to be | ||
| 155 | your build host, you could run the project as follows:: | ||
| 156 | |||
| 157 | $ ./tmp/usr/local/bin/hello | ||
| 158 | |||
| 159 | As expected, the project displays the "Hello World!" message. | ||
| 160 | |||
| 161 | Makefile-Based Projects | ||
| 162 | ======================= | ||
| 163 | |||
| 164 | Simple Makefile-based projects use and interact with the cross-toolchain | ||
| 165 | environment variables established when you run the cross-toolchain | ||
| 166 | environment setup script. The environment variables are subject to | ||
| 167 | general ``make`` rules. | ||
| 168 | |||
| 169 | This section presents a simple Makefile development flow and provides an | ||
| 170 | example that lets you see how you can use cross-toolchain environment | ||
| 171 | variables and Makefile variables during development. | ||
| 172 | |||
| 173 | .. image:: figures/sdk-makefile-flow.png | ||
| 174 | :align: center | ||
| 175 | :width: 70% | ||
| 176 | |||
| 177 | The main point of this section is to explain the following three cases | ||
| 178 | regarding variable behavior: | ||
| 179 | |||
| 180 | - *Case 1 --- No Variables Set in the Makefile Map to Equivalent | ||
| 181 | Environment Variables Set in the SDK Setup Script:* Because matching | ||
| 182 | variables are not specifically set in the ``Makefile``, the variables | ||
| 183 | retain their values based on the environment setup script. | ||
| 184 | |||
| 185 | - *Case 2 --- Variables Are Set in the Makefile that Map to Equivalent | ||
| 186 | Environment Variables from the SDK Setup Script:* Specifically | ||
| 187 | setting matching variables in the ``Makefile`` during the build | ||
| 188 | results in the environment settings of the variables being | ||
| 189 | overwritten. In this case, the variables you set in the ``Makefile`` | ||
| 190 | are used. | ||
| 191 | |||
| 192 | - *Case 3 --- Variables Are Set Using the Command Line that Map to | ||
| 193 | Equivalent Environment Variables from the SDK Setup Script:* | ||
| 194 | Executing the ``Makefile`` from the command line results in the | ||
| 195 | environment variables being overwritten. In this case, the | ||
| 196 | command-line content is used. | ||
| 197 | |||
| 198 | .. note:: | ||
| 199 | |||
| 200 | Regardless of how you set your variables, if you use the "-e" option | ||
| 201 | with ``make``, the variables from the SDK setup script take precedence:: | ||
| 202 | |||
| 203 | $ make -e target | ||
| 204 | |||
| 205 | |||
| 206 | The remainder of this section presents a simple Makefile example that | ||
| 207 | demonstrates these variable behaviors. | ||
| 208 | |||
| 209 | In a new shell environment variables are not established for the SDK | ||
| 210 | until you run the setup script. For example, the following commands show | ||
| 211 | a null value for the compiler variable (i.e. | ||
| 212 | :term:`CC`):: | ||
| 213 | |||
| 214 | $ echo ${CC} | ||
| 215 | |||
| 216 | $ | ||
| 217 | |||
| 218 | Running the | ||
| 219 | SDK setup script for a 64-bit build host and an i586-tuned target | ||
| 220 | architecture for a ``core-image-sato`` image using the current &DISTRO; | ||
| 221 | Yocto Project release and then echoing that variable shows the value | ||
| 222 | established through the script:: | ||
| 223 | |||
| 224 | $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux | ||
| 225 | $ echo ${CC} | ||
| 226 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/&DISTRO;/sysroots/i586-poky-linux | ||
| 227 | |||
| 228 | To illustrate variable use, work through this simple "Hello World!" | ||
| 229 | example: | ||
| 230 | |||
| 231 | #. *Create a Working Directory and Populate It:* Create a clean | ||
| 232 | directory for your project and then make that directory your working | ||
| 233 | location:: | ||
| 234 | |||
| 235 | $ mkdir $HOME/helloworld | ||
| 236 | $ cd $HOME/helloworld | ||
| 237 | |||
| 238 | After | ||
| 239 | setting up the directory, populate it with files needed for the flow. | ||
| 240 | You need a ``main.c`` file from which you call your function, a | ||
| 241 | ``module.h`` file to contain headers, and a ``module.c`` that defines | ||
| 242 | your function. | ||
| 243 | |||
| 244 | Create the three files as follows: | ||
| 245 | |||
| 246 | - ``main.c``:: | ||
| 247 | |||
| 248 | #include "module.h" | ||
| 249 | void sample_func(); | ||
| 250 | int main() | ||
| 251 | { | ||
| 252 | sample_func(); | ||
| 253 | return 0; | ||
| 254 | } | ||
| 255 | |||
| 256 | - ``module.h``:: | ||
| 257 | |||
| 258 | #include <stdio.h> | ||
| 259 | void sample_func(); | ||
| 260 | |||
| 261 | - ``module.c``:: | ||
| 262 | |||
| 263 | #include "module.h" | ||
| 264 | void sample_func() | ||
| 265 | { | ||
| 266 | printf("Hello World!"); | ||
| 267 | printf("\n"); | ||
| 268 | } | ||
| 269 | |||
| 270 | #. *Source the Cross-Toolchain Environment Setup File:* As described | ||
| 271 | earlier in the manual, installing the cross-toolchain creates a | ||
| 272 | cross-toolchain environment setup script in the directory that the | ||
| 273 | SDK was installed. Before you can use the tools to develop your | ||
| 274 | project, you must source this setup script. The script begins with | ||
| 275 | the string "environment-setup" and contains the machine architecture, | ||
| 276 | which is followed by the string "poky-linux". For this example, the | ||
| 277 | command sources a script from the default SDK installation directory | ||
| 278 | that uses the 32-bit Intel x86 Architecture and the &DISTRO_NAME; Yocto | ||
| 279 | Project release:: | ||
| 280 | |||
| 281 | $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux | ||
| 282 | |||
| 283 | Another example is sourcing the environment setup directly in a Yocto | ||
| 284 | build:: | ||
| 285 | |||
| 286 | $ source tmp/deploy/images/qemux86-64/environment-setup-core2-64-poky-linux | ||
| 287 | |||
| 288 | #. *Create the Makefile:* For this example, the Makefile contains | ||
| 289 | two lines that can be used to set the :term:`CC` variable. One line is | ||
| 290 | identical to the value that is set when you run the SDK environment | ||
| 291 | setup script, and the other line sets :term:`CC` to "gcc", the default | ||
| 292 | GNU compiler on the build host:: | ||
| 293 | |||
| 294 | # CC=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux | ||
| 295 | # CC="gcc" | ||
| 296 | all: main.o module.o | ||
| 297 | ${CC} main.o module.o -o target_bin | ||
| 298 | main.o: main.c module.h | ||
| 299 | ${CC} -I . -c main.c | ||
| 300 | module.o: module.c module.h | ||
| 301 | ${CC} -I . -c module.c | ||
| 302 | clean: | ||
| 303 | rm -rf *.o | ||
| 304 | rm target_bin | ||
| 305 | |||
| 306 | #. *Make the Project:* Use the ``make`` command to create the binary | ||
| 307 | output file. Because variables are commented out in the Makefile, the | ||
| 308 | value used for :term:`CC` is the value set when the SDK environment setup | ||
| 309 | file was run:: | ||
| 310 | |||
| 311 | $ make | ||
| 312 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c | ||
| 313 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c | ||
| 314 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin | ||
| 315 | |||
| 316 | From the results of the previous command, you can see that | ||
| 317 | the compiler used was the compiler established through the :term:`CC` | ||
| 318 | variable defined in the setup script. | ||
| 319 | |||
| 320 | You can override the :term:`CC` environment variable with the same | ||
| 321 | variable as set from the Makefile by uncommenting the line in the | ||
| 322 | Makefile and running ``make`` again:: | ||
| 323 | |||
| 324 | $ make clean | ||
| 325 | rm -rf *.o | ||
| 326 | rm target_bin | ||
| 327 | # | ||
| 328 | # Edit the Makefile by uncommenting the line that sets CC to "gcc" | ||
| 329 | # | ||
| 330 | $ make | ||
| 331 | gcc -I . -c main.c | ||
| 332 | gcc -I . -c module.c | ||
| 333 | gcc main.o module.o -o target_bin | ||
| 334 | |||
| 335 | As shown in the previous example, the | ||
| 336 | cross-toolchain compiler is not used. Rather, the default compiler is | ||
| 337 | used. | ||
| 338 | |||
| 339 | This next case shows how to override a variable by providing the | ||
| 340 | variable as part of the command line. Go into the Makefile and | ||
| 341 | re-insert the comment character so that running ``make`` uses the | ||
| 342 | established SDK compiler. However, when you run ``make``, use a | ||
| 343 | command-line argument to set :term:`CC` to "gcc":: | ||
| 344 | |||
| 345 | $ make clean | ||
| 346 | rm -rf *.o | ||
| 347 | rm target_bin | ||
| 348 | # | ||
| 349 | # Edit the Makefile to comment out the line setting CC to "gcc" | ||
| 350 | # | ||
| 351 | $ make | ||
| 352 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c | ||
| 353 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c | ||
| 354 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin | ||
| 355 | $ make clean | ||
| 356 | rm -rf *.o | ||
| 357 | rm target_bin | ||
| 358 | $ make CC="gcc" | ||
| 359 | gcc -I . -c main.c | ||
| 360 | gcc -I . -c module.c | ||
| 361 | gcc main.o module.o -o target_bin | ||
| 362 | |||
| 363 | In the previous case, the command-line argument overrides the SDK | ||
| 364 | environment variable. | ||
| 365 | |||
| 366 | In this last case, edit Makefile again to use the "gcc" compiler but | ||
| 367 | then use the "-e" option on the ``make`` command line:: | ||
| 368 | |||
| 369 | $ make clean | ||
| 370 | rm -rf *.o | ||
| 371 | rm target_bin | ||
| 372 | # | ||
| 373 | # Edit the Makefile to use "gcc" | ||
| 374 | # | ||
| 375 | $ make | ||
| 376 | gcc -I . -c main.c | ||
| 377 | gcc -I . -c module.c | ||
| 378 | gcc main.o module.o -o target_bin | ||
| 379 | $ make clean | ||
| 380 | rm -rf *.o | ||
| 381 | rm target_bin | ||
| 382 | $ make -e | ||
| 383 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c | ||
| 384 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c | ||
| 385 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin | ||
| 386 | |||
| 387 | In the previous case, the "-e" option forces ``make`` to | ||
| 388 | use the SDK environment variables regardless of the values in the | ||
| 389 | Makefile. | ||
| 390 | |||
| 391 | #. *Execute Your Project:* To execute the project (i.e. ``target_bin``), | ||
| 392 | use the following command:: | ||
| 393 | |||
| 394 | $ ./target_bin | ||
| 395 | Hello World! | ||
| 396 | |||
| 397 | .. note:: | ||
| 398 | |||
| 399 | If you used the cross-toolchain compiler to build | ||
| 400 | target_bin | ||
| 401 | and your build host differs in architecture from that of the | ||
| 402 | target machine, you need to run your project on the target device. | ||
| 403 | |||
| 404 | As expected, the project displays the "Hello World!" message. | ||
