element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • 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 Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
  • Settings
Enchanted Objects
  • Challenges & Projects
  • Design Challenges
  • Enchanted Objects
  • More
  • Cancel
Enchanted Objects
Blog 1958 Turntable from the Black Forest - 13: Breakthrough - Run my own C++ Program on the SAMA5D4
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 27 Apr 2015 12:01 PM Date Created
  • Views 1372 views
  • Likes 4 likes
  • Comments 13 comments
  • sama5d4
  • enchanted_player
  • enchanted_objects
  • cross_compile
  • arm
  • atmel
Related
Recommended

1958 Turntable from the Black Forest - 13: Breakthrough - Run my own C++ Program on the SAMA5D4

Jan Cumps
Jan Cumps
27 Apr 2015

image

 

I've done many attempts to build and execute my own C program on the atmel sama5d4 xplained ultra board.

And today is the big day. Thanks to the tutorial on mikrocontroller-software.de, I was able to cross-compile and run my first binary.

 

Hooray!

 

image

 

 

Was it difficult?

 

No. Once I found the how-to guide, I greased up my German language skills. I had everything running in less than 20 minutes.

That's always how things happen. You chase your tail for a good month. Then you find that gem on the internet that walks you through the steps.

And it turned out to be not difficult at all.

Hindsight is a %*$§.

 

Step-by-Step

 

I can't explain it better than mikrocontroller-software.de. But I've made screenshots along the way, so it would be a shame not to share them.

 

Step 1: Start Eclipse for DS-5 and create a new C++ Project

image

Step 2: name the project, type = Executable : Empty Project, Toolchains: GCC 4.x built-in (or another one, I wasn't adventurous enough yet to try a different one then that of the how-to guide image )

Next and Finish

image

Step 3: create the main.cpp file by right clicking on the project and adding a new C++ source file

image

image

Step 4: Enter the source lines. I stayed faithful to the example and kept the word A7 in there.

 

#include <iostream>


int main() {
  std::cout << "Hello World! Cortex A7 Atmel\r\n";
  return 0;
}

 

image

 

Step 5: inform the toolchain about the target platform. You do that by setting additional flags on the command lines.

The following flag needs to be added (see the original how-to to check why ARM5 needs v7):

 

-marm -march=armv7-a

 

a:

image

b:

 

image

c:

image

 

Step 6: build the program

 

image

 

Step 7: review the console output:

 

12:21:50 **** Build of configuration Debug for project HelloARMWorld ****
make all
'Building file: ../main.cpp'
'Invoking: GCC C++ Compiler 4 [arm-linux-gnueabihf]'
arm-linux-gnueabihf-g++ -O0 -g3 -Wall -c -fmessage-length=0 -marm -march=armv7-a -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
'Finished building: ../main.cpp'
' '
'Building target: HelloARMWorld'
'Invoking: GCC C++ Linker 4 [arm-linux-gnueabihf]'
arm-linux-gnueabihf-g++ -marm -march=armv7-a -o "HelloARMWorld"  ./main.o
'Finished building target: HelloARMWorld'
' '


12:21:54 Build Finished (took 3s.862ms)

 

Step 8: load the program and set it as executable

 

a: load the program, in binary mode, with your favorite SCP tool (I use WinSCP)

image

 

image

b: start your favorite terminal (I use PuTTY) and set the executable flag and verify that all is ok

 

chmod +x HelloARMWorld
ls -l

 

image

Step 9: execute the program, sit back and enjoy your success

 

./HelloARMWorld

 

image

 

 

A big thank you to http://www.mikrocontroller-software.de/

 

 

 

Summary

 

 

Is this what I wanted to do? No, not 100%. But very very close.

My goal was to be able to build bare-metal application for the board , load and execute it.

I'm currently able to build an application, and run it on Linux.

That is a good situation to be in. It unlocks a multitude of possibilities that I wasn't able to investigate earlier.

If time allows, I will step deeper into the bare metal. But now I'm first going to enjoy my newly gained access to those new possibilities.

 

 

Table of Contents
Chapter 1: Fix the turntable
1: Perpetuum Ebner Musical 1
2: A Time to Kill and a Time to Heal
3: Preparation for Motor Drive
4: Motor control with Infineon Motor Shield and Arduino UNO
5: Turntable speed sample testbed with Arduino UNO
6: Turntable Speed Sensor design
7: Control Theory - End of Chapter 1
Chapter 2: First Enchantments
8: Digital Light Organ Enchantment
9: Autonomous Servo Lift
10: SMD Time - Solder the IR Speed Sensor PCB
11: Yelp - who can Help me to Compile and Run my First SAMA5D4 C Program
12: Son et Lumiere - End of Chapter 2
Chapter 3: Taming the Board
13: Breakthrough - Run my own C++ Program on the SAMA5D4
14: Digital Light Organ Input Buffer
15: SAMA5D4 Blinky
16: Scope Creep
17: Audio Sampling with 16-bit ADC ADS8343
18: Sending Files to SAMA5D4 over USB
19: Port my Light Organ from Arduino to SAMA5D4
20: Fast Fourier Transform on the SAMA5D4 - End of Chapter 3
Epilogue: Reaching for the Clouds
21: Right-Sizing my Plans
22: My Own C++ Buffered Sampler on the SAMA5D4
Interlude
23: Building In the Motorized Light Organ
24: Up to the Clouds with Yún
25: Publish or Perish
26: Turntable Finished
Stretch & Boni
Bonus 1a: Remote Light Organ with WiFI pt. 1
Bonus 1b: Remote Light Organ with WiFI pt. 2
Grande Finale: Paho MQTT Client on the SAMA5D4
Related blog
Vintage Turntable repair: Can I fix a Perpetuum Ebner from 1958
Review 1: Atmel SMART SAMA5D4 Xplained Ultra Unboxing and First Steps
Review 2: Atmel SMART SAMA5D4 Xplained Ultra - Building the Libraries from Source
Review 3: Digital Continuous Rotation (360°) Servo Part 1
Review 4: Digital Continuous Rotation (360°) Servo Part 2
Review 5: Atmel SMART SAMA5D4 Xplained Ultra - TCP/IP running
Review 6: Atmel SMART SAMA5D4 Xplained Ultra - LINUX Distro with SSH support
poem
Enchanted Objects: Let's work together to tame the ATMEL SMART SAMA5D4 Xplained Ultra kit
17 bis: Off South...
Review 7: Atmel SMART SAMA5D4 Xplained Ultra - C++ ADC Example on Linux
Review 8: Atmel SMART SAMA5D4 Xplained Ultra - Product Review
Review 9a: Atmel SMART SAMA5D4 Xplained Ultra - Set up ADC Buffer with Hardware Trigger Part 1
Review 9b: Atmel SMART SAMA5D4 Xplained Ultra - Set up ADC Buffer with Hardware Trigger Part 2
Review 10: Atmel SMART SAMA5D4 Xplained Ultra - New Content on AT91.com
1958 Turntable from the Black Forest - Summary of the Enchanted Player Story
  • Sign in to reply

Top Comments

  • DAB
    DAB over 10 years ago +1
    Looks easy enough, but as you said, everything goes easier when you have good instructions to follow. Thanks DAB
  • clem57
    clem57 over 10 years ago +1
    Why do you want to build on the bare metal? Linux provides so much help to do things faster. Right? Clem
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to clem57 +1
    I have 3 reasons - all the source examples on the Atmel site are bare metal (the code pack with ADC and security projects). I' d like to be able to run them and investigate how they are working. Atmel…
  • Jan Cumps
    Jan Cumps over 10 years ago in reply to Workshopshed

    I read it on Atmel SAM5D4 Mounting USB Stick [ATMELRegistered SAMA5D4 Xplained Ultra Getting Started]

    It's the same site that I used in this blog to get "Hello, world! compiled.

     

    I was actually looking at the GPIO examples on the site, and got sidetracked.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 10 years ago in reply to Workshopshed

    df -h  or lsusb   can give you a good idea...

    Clem

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 10 years ago in reply to Jan Cumps

    Couple of people with the same error via google but no ideas on the fix.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 10 years ago in reply to Jan Cumps

    How do you know what device the SDCard or Memory stick is loaded as?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 10 years ago

    While we're at it, talking from xplained ultra to yun:

     

    image

     

    The other way around doesn't work yet. I got a:

     

    ssh: Connection to root@192.168.1.21:22 exited: Couldn't set nonblocking

    • Cancel
    • Vote Up +1 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 © 2025 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

  • X
  • Facebook
  • linkedin
  • YouTube