IMX Hello World: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{PageHeader|Hello, World!}} {{DocImage|category1=Yocto|category2=VAR-SOM-MX6}}[[Category:DART-6UL]][[Category:VAR-SOM-MX7]] __toc__ | {{PageHeader|Hello, World!}} {{DocImage|category1=Yocto|category2=VAR-SOM-MX6}}[[Category:DART-6UL]][[Category:VAR-SOM-MX7]] __toc__ | ||
= Yocto references = | |||
- [http://www.yoctoproject.org/docs/2.1/adt-manual/adt-manual.html Yocto Project Application Developer's Guide 2.1]<br> | |||
- See the "Build Yocto from source code" section in this Wiki website, for your appropriate board and Yocto release. | |||
= Sample C "Hello, world!" program = | = Sample C "Hello, world!" program = | ||
Line 15: | Line 19: | ||
== Toolchain installation for out of Yocto builds == | == Toolchain installation for out of Yocto builds == | ||
To install the toolchain:<br> | To install the toolchain:<br> | ||
For Variscite's MX6 boards, follow [[VAR-SOM-MX6 Toolchain installation for out of Yocto Krogoth builds]].<br> | For Variscite's MX6 boards, follow [[VAR-SOM-MX6 Toolchain installation for out of Yocto Krogoth builds]].<br> | ||
For DART-6UL, follow [[DART-6UL Toolchain installation for out of Yocto Krogoth builds]].<br> | For DART-6UL, follow [[DART-6UL Toolchain installation for out of Yocto Krogoth builds]].<br> | ||
Line 81: | Line 84: | ||
This will put the myhello app in your rootfs. | This will put the myhello app in your rootfs. | ||
Revision as of 10:59, 20 April 2017
Yocto references
- Yocto Project Application Developer's Guide 2.1
- See the "Build Yocto from source code" section in this Wiki website, for your appropriate board and Yocto release.
Sample C "Hello, world!" program
Create a file called myhello.c with the following content:
#include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }
Building out of Yocto
Toolchain installation for out of Yocto builds
To install the toolchain:
For Variscite's MX6 boards, follow VAR-SOM-MX6 Toolchain installation for out of Yocto Krogoth builds.
For DART-6UL, follow DART-6UL Toolchain installation for out of Yocto Krogoth builds.
For VAR-SOM-MX7, follow VAR-SOM-MX7 Toolchain installation for out of Yocto Krogoth builds.
Build
Source the environment setup script (see the previous "Toolchain installation" section) Compile: $ $CC myhello.c -o myhello
Now you should have an app called myhello, that can be copied (using scp, for example) and run on your target board.
Building using Yocto
Sample bitbake recipe of an "Hello, world!" application
Create a file called myhello.bb with the following content:
DESCRIPTION = "Simple helloworld application" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" SRC_URI = "file://myhello.c" S = "${WORKDIR}" do_compile() { ${CC} myhello.c -o myhello } do_install() { install -d ${D}${bindir} install -m 0755 myhello ${D}${bindir} }
Create the following directory tree under your Yocto directory, and place in it the two files described above:
sources/meta-variscite-imx/recipes-examples/ └── myhello ├── files │ └── myhello.c └── myhello.bb 2 directories, 2 files
Build
Run the following in your Yocto build directory:
$ bitbake myhello
To find the location of the output package you can run the following in your Yocto build directory:
$ cd tmp/deploy/rpm $ find -name myhello*
To add the output of this recipe to your output images, add the following to your conf/local.conf file in your Yocto build directory:
IMAGE_INSTALL_append = " myhello"
This will put the myhello app in your rootfs.