IMX Hello World

From Variscite Wiki
Revision as of 15:31, 13 December 2015 by Ron (talk | contribs) (→‎Directory tree)
VAR-SOM-MX6 - Hello World

Reference

Yocto Project Application Developer's Guide 2.0

Toolchain installation for out of Yocto builds

Build the toolchain by:

$ bitbake meta-ide-support
$ bitbake meta-toolchain

In your Yocto build directory. The output will be located at tmp/deploy/sdk/. On a 64 bit Ubuntu you will get:

sdk/poky-eglibc-x86_64-meta-toolchain-cortexa9hf-vfp-neon-toolchain-1.8.sh

Install the tools by running:

$ tmp/deploy/sdk/poky-eglibc-x86_64-meta-toolchain-cortexa9hf-vfp-neon-toolchain-1.8.sh

Reply to all defaults 'y'
The toolchain name depend on your build machine and may change.

hello World C

$ 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 with BitBake

File hello_0.0.bb

#
#@DESCRIPTION: Variscite Hello world example"
#@MAINTAINER: Ron Donio <ron.d@variscite.com>
#
# http://www.variscite.com
# support@variscite.com
#

PR = "r0"
LICENSE = "GPLv2"

S = "${WORKDIR}"

LIC_FILES_CHKSUM = "file://hello.c;md5=360191807313df2e50fded385dd7532b"
SRC_URI = "file://hello.c"

do_compile() {
             ${CC} ${CFLAGS} ${LDFLAGS} -o hello hello.c
}

do_install() {
             install -d ${D}${bindir}/
             install -m 0755 ${S}/hello ${D}${bindir}/
}

FILES_${PN} = "${bindir}/hello"

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/
└── hello
    ├── hello
    │   └── hello.c
    └── hello_0.0.bb

2 directories, 2 files

Create the directory tree as describe above and place the 2 files in the right directories.

Build

$ bitbake hello