Page 1 of 1

SAMA5D4 simple Hello World

Posted: Tue Jun 28, 2016 7:59 pm
by decoPo
Hi everyone!

Can some advice me, how to write and compile simple "Hello World" like program for SAMA5D4? Lots of tutorial on a web are out of date.

Suppose these steps:
1) upload Linux image for SAMA5D4 (eg. linux4sam-poky-sama5d4_xplained-5.3.zip)
2) install Eclipse + GCC toolchain with GDB (eg. on Ubuntu 16.04)
3) setup toolchain
4) write code and debuging
I'm stucked on step 3) and 4).

Cheers!

Re: SAMA5D4 simple Hello World

Posted: Tue Jun 28, 2016 10:08 pm
by tsvoipio
For the first steps, forget Eclipse. It is nice, but needs plenty of subordinate software working.

Lets guess that your Linux is Debian-based. There is a bundle of development tools, including GCC, GDB and binary tools. The bundle can be installed with:

sudo apt-get install build-essential.

You should then check that gcc is there:

gcc --version

You can check the other tools in a similar way, e.g. for gdb:

gdb --version

For the first try, I'd get a simple text editor, like nano, which is installed in most distributions in the base installation.

Use the editor at hand and write file hello.c:

--- clip clip ---

#include <stdio.h>

int main(void)
{
printf("Hello\n");
return 0;
}

--- clip clip ---

Just write the lines between --- clip clip --- markers, not them.

Compile the file:

gcc -o hello hello.c

If all goes well, run it:

./hello

--

-TV

Re: SAMA5D4 simple Hello World

Posted: Wed Jun 29, 2016 8:17 am
by decoPo
Thank you for the fast response. This is exactly what I need :D .

But my question is what I have to do to achieve this on SAMA5D4 XULT?

It doesn't work on linux4sam-poky-sama5d4_xplained-5.3.zip (YOCTO / POKY).

Does exist way how to get image which contains GCC (Debian based Linux)? Or I have to compile own instalation.

Even better is compile program on my computer (Ubuntu or Windows) and copy binary to SAMA5D4.

VS

Re: SAMA5D4 simple Hello World

Posted: Wed Jun 29, 2016 2:11 pm
by tsvoipio
It seems that you have just a demo package on your root file system. Please check if there is apt-get:

sudo apt-get

If it is there, you can use it to load packages from the Net.

There are plenty of instructions for using your Linux host if you Google 'sama5d4 cross-compile'.

--

-TV

Re: SAMA5D4 simple Hello World

Posted: Wed Jun 29, 2016 3:45 pm
by decoPo
Yes it is DEMO package. There isn't apt-get.

I'm not very experienced in Linux, I'm HW engineer. Information from google is very confusing for me. I've spent lot of time on Internet. I just need one working image (not demo) for SAMA5D4 XULT which I can uploade via SAM-BA to FLASH. I thought that Atmel is providing it. Rather then some Qt demo :(

The aim is connect some HW (40button keypad via multiplex + monochrome graphic LCD via SPI or I2C) on SAMA5D4 XULT before I design PCB. I have no time to trying different linux images.

Vladislav

Re: SAMA5D4 simple Hello World

Posted: Wed Jun 29, 2016 4:36 pm
by tsvoipio
Just get the instructions for generating the code on your desktop computer for the SAM. To do this, you need a cross-compilation toolkit, as the target computer is different from your desktop computer.

We will lose more time if I try to remotely lead you to get the tools and use them for a processor board I do not have at hand.

--

-TV

Re: SAMA5D4 simple Hello World

Posted: Wed Jun 29, 2016 8:10 pm
by blue_z
decoPo wrote:Lots of tutorial on a web are out of date.!
Could you list a few of these, and indicate why you think they're out of date?
decoPo wrote:I just need one working image (not demo) for SAMA5D4 XULT which I can uploade via SAM-BA to FLASH. I thought that Atmel is providing it. Rather then some Qt demo :(
You don't have to use Qt5 or the demo applications. It's the cheap and fast way to update the kernel from the basic kernel that's pre-installed.
decoPo wrote:The aim is connect some HW (40button keypad via multiplex + monochrome graphic LCD via SPI or I2C) on SAMA5D4 XULT before I design PCB. I have no time to trying different linux images.
If you want a kernel and rootfs customized with just what you deem the essentials, then Buildroot would be the best choice IMO.
If time is money, then hire a FW consultant.

Regards.

Re: SAMA5D4 simple Hello World

Posted: Wed Jun 29, 2016 9:40 pm
by decoPo
My contractor hired Linux specialist who continue on this today.
When I'll have SAMA5D4 XULT back, I'll try to test Buildroot and other again but more systematically.
Thanks for support.

Best Regards,
Vladislav