Simple user space compile

Moderator: nferre

illishar
Posts: 5
Joined: Sat Nov 29, 2014 1:20 pm

Simple user space compile

Mon Dec 01, 2014 9:47 am

Hello, 

We've bought the sama5d3 xplained in order to do a few tests with the 64bit FPU. We've powered it up, poked around in the preflashed linux, everything is fine. Now we'd like to compile a few of our tests and execute them. 

... how do we do that? I can't find any doc that says "download this compiler, build with this makefile, transfer to board, execute". 
My conclusion so far, is that we have to set up a build machine and compile yocto from scratch. This will literally take *days*, if not weeks. (Not exactly what I'd call prototyping.)

Do you know of a small guide that compiles a simple linux hello world app, for the sama5d3 xplained? (Without building the whole yocto project.)
bseljak
Posts: 28
Joined: Thu Apr 03, 2014 1:28 am

Re: Simple user space compile

Mon Dec 01, 2014 11:35 am

Hi!
You could run Debian from SD card: https://sborut.wordpress.com/2014/04/08 ... -xplained/ and compile/test in native environment on sama5d3 Xplained board... 
Borut 
illishar
Posts: 5
Joined: Sat Nov 29, 2014 1:20 pm

Re: Simple user space compile

Mon Dec 01, 2014 2:31 pm

Not a bad suggestion. Unfortunately I don't have an sd card that's bigger than 4GB right now.
bseljak
Posts: 28
Joined: Thu Apr 03, 2014 1:28 am

Re: Simple user space compile

Mon Dec 01, 2014 3:34 pm

For this image it is enough 2GB. 
Borut
illishar
Posts: 5
Joined: Sat Nov 29, 2014 1:20 pm

Re: Simple user space compile

Thu Dec 04, 2014 1:14 pm

I've finally succeeded with my tests. 

It took 4 full days!!! to find my way around the jibber jabber with trial 'n errors etc.

It would've been faster to go with the suggested Debian on sdcard solution and I actually did end up with something similar.

Here're some of the highlights:


First job is to get console output from the preflashed linux. The builtin usb driver (Serial Gadget), is nowhere near working on my Windows7s. I tried both 64bit & 32bit versions. Windows won't recognize it, despite my many attempts. And I didn't have a WinXP. To be honest, this is not Atmels fault. The linux serial gadget is utter crap. No matter, the board's got a dbg console as well. Which is prolly better anyway. After some grief I found out the VCC pin isn't connected. WTF!! Oh, but that's prolly just a jumper. No, it isn't!!! You have to solder it! *Sigh*

I started out with the yocto tools. Yocto is rather simple in theory. It's got layers and the layers's got recipes. Recipes are a kind of "master makefile" for a given app/component. Nice.
However, when you actually want to get your hands dirty, it gets rather complex. Try to change the global/local compiler optimizing or change the output to use a builtin initramfs image etc. Naturally it can be done, but yocto seems to have a steep learning curve. 

If you want to compile and test a single user space app, yocto's got an Eclipse plugin. Nice. However, like all other yocto stuff, it's hellishly difficult to set up. What's worse, I never found out how to change the compiler optimizing from "-O0" to "-O3". You can change it inside Eclipse, but it'll ignore it. 

Ok, then instead of yocto you can go the buildroot way. Buildroot is much more comfortable for those of us, that're used to menuconfig, makefiles, embedded distributions, etc. And Atmel also includes a buildroot section. Nice. Unfortunately Atmel hasn't included a config for the sama5d3xplained. It did have one for sama5d3ev though, so I used that... Which didn't make a difference since the Atmel buildroot can't compile!!! It may have been something with buildroot vs. Ubuntu 14, who cares. 

Ok, after a search on Google you'll notice that the upstream buildroot does have a sama5d3xplained config. Nice. And it's able to compile just fine!!! However, just like the Debian build, this one is also based on a sdcard. So, I got my hands on a big fat sdcard and a PC sdcard reader. The documentation (from upstream buildroot) is very comprehensible in this regard and I was able to create an sdcard that worked. Nice.

If you want to compile and test a single user space app, buildroot's also got an Eclipse plugin, just like yocto. This is much more simple to set up though. And the compiler settings (from inside Eclipse) actually works. 
In order to transfer the compiled outputs to the board, I set up a tftp server on my Ubuntu and downloaded through that. The prebuilt yocto image has SSH, so you can transfer stuff that way. The buildroot default has nothing on bootup, so you have to do it by hand. Eg. set up the ethernet, start whatever service, etc.)



All in all, I'm rather pleased with the sama5d3xplained. We all are. (The tests were *really* successful.) I'm glad that I wasn't a complete newbie though. My colleagues would've had a hard time doing this, I think.  
bseljak
Posts: 28
Joined: Thu Apr 03, 2014 1:28 am

Re: Simple user space compile

Fri Dec 05, 2014 12:23 am

... great ... but my solution (mentioned above) is much faster and don't require linux host (you compile on sama5d3....). It is solution for newbie.  

1. Download debian image ....
2. Write to sdcard
3. Connect network cable to the board
4  Conect debug uart-usb cable to the board (optional but recomended) 
5. Boot sama5d3... from sdcard
6. Login to the bord over debug uart, usb gadget serial  or ssh
Enter: 
  sudo apt-get update 
  sudo apt-get upgrade
  sudo apt-get install build-essential 
Copy files to the board using scp (or winscp) and compile.... 

It took les than an hour.   :)

 Borut
illishar
Posts: 5
Joined: Sat Nov 29, 2014 1:20 pm

Re: Simple user space compile

Fri Dec 05, 2014 3:38 pm

I agree.
I just didn't have a (non micro) sdcard or an sdcard reader, when I started out. Nor any experience with flashing linux on sdcards. (It turns out that you just have to create a FAT16 partition and copy in linux/uboot files. Who'd have guessed.)

Furthermore I was also concerned about what kind of FPU support the Debian build would feature. 

Return to “SAMA5-based”

Who is online

Users browsing this forum: No registered users and 2 guests