element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
WaRP7
  • Products
  • Dev Tools
  • Single-Board Computers
  • WaRP7
  • More
  • Cancel
WaRP7
Blog Warp7 cross compilation toolchain-helloworld
  • Blog
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
WaRP7 requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: bheemarao
  • Date Created: 24 Feb 2017 9:28 AM Date Created
  • Views 386 views
  • Likes 1 like
  • Comments 2 comments
  • warp7
  • helloworld
  • cross compilation
  • arm toolchain
Related
Recommended

Warp7 cross compilation toolchain-helloworld

bheemarao
bheemarao
24 Feb 2017

Let us have a look on basic cross compilation of Helloworld program for warp7 board.

 

There are 3 steps in this tutorial:

1) Installation of cross compilation tool:

2) Writing a helloworld and cross compiling for the target board

3) To copy the executable into the warp7 and execute it.

 

The cross-toolchain consists of a cross-compiler, cross-linker, and cross-debugger that are used to develop user-space applications for targeted hardware. This toolchain is created either by running the ADT Installer script, a toolchain installer script, or through aBuild Directory that is based on your metadata configuration or extension for your targeted device. The cross-toolchain works with a matching target sysroot.

 

Step-1:

$bitbake <image> -c populate_sdk

In my case image is “fsl-image-machine-test”

i.e

$ bitbake fsl-image-machine-test -c populate_sdk

or

$ bitbake meta-toolchain

 

Then you can find the poky installation at

/home/bheema/fsl-warp7-yocto/build-x11-machine-test/tmp/deploy/sdk/

 

image

Next we need to install the tool chain, by giving below command:

 

root@Bheema:~/warp_appln# cd /home/bheema/fsl-warp7-yocto/build-x11-machine-test/tmp/deploy/sdk

root@Bheema:~/fsl-warp7-yocto/build-x11-machine-test/tmp/deploy/sdk# ./poky-glibc-x86_64-meta-toolchain-cortexa7hf-neon-toolchain-2.1.2.sh

the installation will ask default location /opt/poky/2.1.2

proceed further as shown below snap

image

now the toolchain has been installed in /opt/poky/2.1.2 folder

 

Step-2 :

I have created my working folder as “warp_appln” under home directory create helloworld.c with below contents inside this directory:

 

root@Bheema:~/warp_appln# gedit helloworld.c

 

#include <stdio.h>

int main()

{

            printf("hello world\n");

            return 0;

}

image

 

in order to compile we need to source the toolchain to working folder

 

root@Bheema:~/warp_appln# source /opt/poky/2.1.2/environment-setup-cortexa7hf-neon-poky-linux-gnueabi

 

we can compile the helloworld.c in 3 different ways as shown below:

a:

root@Bheema:~/warp_appln# ${CC} helloworld.c -o helloworld1.out

image

The cross-toolchain works with a matching target sysroot.

 

${CC} is macro defined while we source the toolchain. It is using the SDK environment variables which you sourced earlier:

CC="arm-poky-linux-gnueabi-gcc  -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 –sysroot=$SDKTARGETSYSROOT"

 

SDKTARGETSYSROOT is the path of installed toolchain:

SDKTARGETSYSROOT = /opt/poky/2.1.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi/

 

The matching target sysroot contains needed headers and libraries for generating binaries that run on the target architecture. The sysroot is based on the target root filesystem image that is built by the OpenEmbedded build system Poky and uses the same metadata configuration used to build the cross-toolchain.

 

b:

Optionally to compile our helloworld you can give below command

 

root@Bheema:~/warp_appln# arm-poky-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/poky/2.1.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi helloworld.c -o helloworld2.out

 

image

 

c:

Another method is to create “Makefile” inside “warp_appln” working folder with below contents

 

root@Bheema:~/warp_appln# gedit Makefile

 

CROSS=arm-poky-linux-gnueabi-

all:

            ${CC} helloworld.c -o helloworld3.out

clean:

            @rm -vf helloworld *.o *~

image

Now compile it using make command

 

root@Bheema:~/warp_appln# make

arm-poky-linux-gnueabi-gcc  -march=armv7ve -marm -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/poky/2.1.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi helloworld.c -o helloworld3.out

 

root@Bheema:~/warp_appln# ls

helloworld1.out  helloworld2.out  helloworld3.out  helloworld.c helloworld.zip  Makefile

 

image

now you can see all the three *.out files which has been created

 

Step-3 :

copying the helloworld.out to warp board using u-boot command

 

Note: we are proceeding further assuming your warp7 board is already loaded with pre-built image (which is working board)

now plug on the warp7 board to your computer and open a serial port terminal by using picocom command

root@Bheema:~/warp_appln# picocom -b 115200 /dev/ttyUSB0

image

now type below command at u-boot prompt

=>ums 0 mmc 0

 

you can see the warp7 emmc memory gets detected as shown below:

these are mounted on “/dev/sdc” with 3 partitions:

 

Boot: ~9 MB: “/media/bheema/Boot imx7s-” which is u-boot for warp7 and

rootfs: ~700MB: “/media/bheema/84804b4b-bc0e-4b3d-ac36-870eae0aca0f” where our linux kernel is loaded

image

/dev/sdc is available to user to copy the compiled executable files

 

root@Bheema:~/warp_appln# cp *.out /media/bheema/84804b4b-bc0e-4b3d-ac36-870eae0aca0f/

image

you can see that we have copied / transfered all the 3 executables  to warp7 board

you can verify the exact file has been copied to target board by checking crc checksum

 

root@Bheema:~/warp_appln# md5sum helloworld1.out

2e5191e3cd9134b78192fff8426d9ba8  helloworld1.out

root@Bheema:~/warp_appln# md5sum /media/bheema/84804b4b-bc0e-4b3d-ac36-870eae0aca0f/helloworld1.out

2e5191e3cd9134b78192fff8426d9ba8 /media/bheema/84804b4b-bc0e-4b3d-ac36-870eae0aca0f/helloworld1.out

root@Bheema:~/warp_appln#

 

now type ctrl+c on u-boot window and type reset

=> ctrl+c

=> reset

=> ums 0 mmc 0

 

UMS: LUN 0, dev 0, hwpart 0, sector 0x0, count 0xe18000

 

CTRL+C - Operation aborted

  => reset

image

warp board will be reset with changes wait till login screen occurs

image

you can execute the helloworld.out as shown below:

image

root@imx7s-warp:/# ./helloworld1.out

hello world

root@imx7s-warp:/# ./helloworld2.out

hello world

root@imx7s-warp:/# ./helloworld3.out

hello world

root@imx7s-warp:/#

 

Happy toolchain & cross compiling using warp7 target image image image image

  • Sign in to reply
  • hanooi
    hanooi over 5 years ago

    Great!  Much needed and much appreciated!

     

    So are we limited to only using Ubuntu to load our cross compiled programs onto the Warp7?  I'm currently working with ARM to get their DS-MDK development environment up to snuff with the Warp7.

     

    Turns out, we are pushing the frontiers of technology here.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • tbsi
    tbsi over 5 years ago

    hi bheemarao,

     

    Thank you very much,

     

    Thanks,

    Ta si

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube