IMX Hello World: Difference between revisions
Line 4: | Line 4: | ||
= Toolchain installation for out of Yocto builds= | = Toolchain installation for out of Yocto builds= | ||
Build the toolchain by: | Build the toolchain by running the following in your Yocto build directory: | ||
<pre>$ bitbake meta-ide-support | <pre> | ||
$ bitbake meta-ide-support | |||
$ bitbake meta-toolchain | $ bitbake meta-toolchain | ||
</pre> | </pre> | ||
The output will be located at tmp/deploy/sdk/. On a 64 bit Ubuntu you will get: | The output will be located at tmp/deploy/sdk/. On a 64 bit Ubuntu you will get: | ||
sdk/ | tmp/deploy/sdk/fsl-imx-x11-glibc-x86_64-meta-toolchain-cortexa9hf-vfp-neon-toolchain-4.1.15-1.1.0.sh | ||
Install the tools by running: | Install the tools by running: | ||
<pre>$ tmp/deploy/sdk/ | <pre> | ||
$ tmp/deploy/sdk/fsl-imx-x11-glibc-x86_64-meta-toolchain-cortexa9hf-vfp-neon-toolchain-4.1.15-1.1.0.sh | |||
</pre> | |||
Reply to all defaults 'y'<br> | Reply to all defaults 'y'<br> | ||
The toolchain name depend on your build machine and may change. | The toolchain name depend on your build machine and may change. |
Revision as of 13:57, 4 September 2016
Reference
Yocto Project Application Developer's Guide 2.0
Toolchain installation for out of Yocto builds
Build the toolchain by running the following in your Yocto build directory:
$ bitbake meta-ide-support $ bitbake meta-toolchain
The output will be located at tmp/deploy/sdk/. On a 64 bit Ubuntu you will get:
tmp/deploy/sdk/fsl-imx-x11-glibc-x86_64-meta-toolchain-cortexa9hf-vfp-neon-toolchain-4.1.15-1.1.0.sh
Install the tools by running:
$ tmp/deploy/sdk/fsl-imx-x11-glibc-x86_64-meta-toolchain-cortexa9hf-vfp-neon-toolchain-4.1.15-1.1.0.sh
Reply to all defaults 'y'
The toolchain name depend on your build machine and may change.
Hello World C command line example
$ mkdir ~/applications $ cd ~/applications $ gedit hello.c & #include <stdio.h> int main(int argc, char **argv) { printf("Hello World\n"); return(0); } Compile: $ source /opt/poky/1.8/environment-setup-armv7a-vfp-neon-poky-linux-gnueabi $ $CC -o hello hello.c Find you target ipaddr. Copy: $ scp hello root@192.168.1.130:~/ On Target: Fix an issue with the library happen in poky version 1.8 $ ln -s /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3 Run: root@var-som-mx6:~# ./hello Hello World
Hello World with BitBake example
File hellov.bb
# #@DESCRIPTION: Variscite Hello world example" # # http://www.variscite.com # support@variscite.com # PR = "r0" LICENSE = "GPLv2" S = "${WORKDIR}" LIC_FILES_CHKSUM = "file://hellov.c;md5=360191807313df2e50fded385dd7532b" SRC_URI = "file://hellov.c" do_compile() { ${CC} ${CFLAGS} ${LDFLAGS} -o hellov hellov.c } do_install() { install -d ${D}${bindir}/ install -m 0755 ${S}/hellov ${D}${bindir}/ } FILES_${PN} = "${bindir}/hellov"
File hello.c
/* * Variscite sample Hello World example */ #include <stdio.h> int main () { printf("Hello World<>\n"); return 0; }
Directory tree
variscite@rd-ub-14:~/var-som-mx6-yocto-fido$ tree sources/meta-variscite-mx6/recipes-test/ sources/meta-variscite-mx6/recipes-test/ └── hellov ├── hellov │ └── hellov.c └── hellov.bb 2 directories, 2 files
Create the directory tree as describe above and place the 2 files in the right directories.
Build and RUN
edit local.conf file and add: IMAGE_INSTALL_append = " hellov"
$ bitbake hello
Deploy your file system. hellov is part of it locate at /us/bin.
$ bitbake hello
Run:
root@var-som-mx6:~# hellov Hello World<>
python Hello World
On target: vi HelloWorld.py
#!/usr/bin/env python import fcntl, struct, glob print "Hello, world!"
Run:
root@var-som-mx6:~# python HelloWorld.py Hello, world!