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.







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 %*$§.




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

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 )

Next and Finish

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

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;



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







Step 6: build the program



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)


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


chmod +x HelloARMWorld
ls -l


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






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







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
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
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