Cross-Compiling Code; Accessing registers

Moderator: nferre

zbaltzer
Posts: 5
Joined: Sun Sep 20, 2015 9:12 pm

Cross-Compiling Code; Accessing registers

Sun Sep 20, 2015 10:44 pm

By trade I'm a microelectronics engineer, by profession I do electrical engineering, firmware programming. Currently what I'm working on is developed on the Raspberry Pi, obviously a poor choice for anything commercial related. A little background I guess.. I'm developing a product for sound recognition in deaf households so they can become more aware of what's going on around them. Being the sole developer, I've learned a lot about embedded programming over the last year. I've been looking at other development platforms as the Pi isn't sufficient and saw that the Atmel A5 series may have exactly what I need.

Thankfully the code I've developed is completely C compatible except for one small section of code. That code is taking in a analog reading from an external ADC. I know that the ATSAMA5D36 has a built in 12-bit ADC on board and was hoping to utilize it. I have gotten the cross compiling to work using arm-linux-gnueabihf-gcc on Ubuntu 14.04 LTS. The problem I'm having is that I can't edit/read errors without the compiler giving me an error for an unrecognized variable name.

I know Atmel has a software library for all of this and it was downloaded to the Ubuntu machine and installed using make CROSS_COMPILE=arm-none-eabi- . I have two questions for you, and then I'd be able to continue along the way developing.

Whenever I compile my Xplained program using arm-none-eabi-gcc , It won't compile with an error: "exit.c:(.text.exit+0x2c): undefined reference to '_exit'", so the fix to that was to run "arm-none-eabi-gcc main.c -o main --specs=nosys.specs" but I can't seem to access any registers. For example, it says 'ADC_CR' undeclared, which is the ADC control register name. I also get a segmentation fault error when attempting to run none-eabi compiled code on the sama5d3 xplained board but a Hello World program runs just fine with arm-linux-gnueabihf-gcc but still I get the register name undeclared problem.

1.) Is there anyway to get Atmel's software kit to be recognized by arm-linux-gnueabihf-gcc? If so, how?

2.) Anyway for arm-none-eabi-gcc to not return a segmentation fault when code is uploaded? If so, how do I get control of the CPU registers?
joshw
Posts: 14
Joined: Sat Jan 17, 2015 4:29 am

Re: Cross-Compiling Code; Accessing registers

Mon Sep 21, 2015 2:46 am

Hello,

As I'm guessing you understand, arm-none compilers are intended to produce code which is run outside of a Linux environment (i.e. "bare metal") and arm-linux compilers are intended to produce code which runs in a Linux environment.

Can you clarify what your SAMA5D36 environment is? If it is Linux, you will want to use the Industrial IO (iio for short) interface to the SAMA5D36 ADC rather than reading the registers directly.
Josh @ CIHOLAS Inc
zbaltzer
Posts: 5
Joined: Sun Sep 20, 2015 9:12 pm

Re: Cross-Compiling Code; Accessing registers

Mon Sep 21, 2015 3:59 pm

I am using the demo build of yocto provided.

How would i go about using that inside a C program and getting the compiler to agree with the instructions? specifically the arm-linux compiler?

Thank you for the help; As you can tell I'm new to this sort of thing.
zbaltzer
Posts: 5
Joined: Sun Sep 20, 2015 9:12 pm

Re: Cross-Compiling Code; Accessing registers

Tue Sep 22, 2015 1:39 am

So i looked into the iio and got it reading successfully . However the ADC is incredible slow to post. I'm using this for an audio processing and would like 44100 samples/sec. Does anyone know how to get started with bare-metal programming on this board? or how to speed up the acquisition time in linux to get the sample time up to 44100 samples a second?
blue_z
Location: USA
Posts: 1971
Joined: Thu Apr 19, 2007 10:15 pm

Re: Cross-Compiling Code; Accessing registers

Wed Sep 23, 2015 9:22 pm

zbaltzer wrote:So i looked into the iio and got it reading successfully . However the ADC is incredible slow to post.
You're complaining without providing any details of what you're doing.
See discussions/viewtopic.php/f,12/t,23028/hilit,IIO.html
zbaltzer wrote:I'm using this for an audio processing and would like 44100 samples/sec. Does anyone know how to get started with bare-metal programming on this board? or how to speed up the acquisition time in linux to get the sample time up to 44100 samples a second?
Voice-grade sampling (e.g. 8 bits at 8KHz) might be possible.
But if you're looking to get CD Red Book rates, then you're asking the wrong questions.
Did you notice that the integrated ADC is only 12 bits per sample?

Regards
zbaltzer
Posts: 5
Joined: Sun Sep 20, 2015 9:12 pm

Re: Cross-Compiling Code; Accessing registers

Wed Sep 23, 2015 11:15 pm

I know. 12-bit is okay. It's a simplified audio demo I'm doing.

My question then is: How do I compile and run bare-metal code on this board? Is there any tutorial someone can point me to or give me a simple step by step into how to do that? One that someone who isn't all to familiar with embedded linux can follow?

Or how I can get faster ADC samples from the demo linux build? At minimum 30ksamples/sec.
blue_z
Location: USA
Posts: 1971
Joined: Thu Apr 19, 2007 10:15 pm

Re: Cross-Compiling Code; Accessing registers

Thu Sep 24, 2015 9:20 pm

zbaltzer wrote:How do I compile and run bare-metal code on this board? Is there any tutorial someone can point me to or give me a simple step by step into how to do that?
There have been a few startup postings in this forum and guides made available. Have you put any effort into a search? It would help if you learned to use the proper names.
The "Atmel's software kit" has the proper name of Software Package or SoftPack. Have you looked at its documentation?
zbaltzer wrote:Or how I can get faster ADC samples from the demo linux build? At minimum 30ksamples/sec.
You'll probably have to perform your own experiments.

Regards
joshw
Posts: 14
Joined: Sat Jan 17, 2015 4:29 am

Re: Cross-Compiling Code; Accessing registers

Fri Sep 25, 2015 2:29 pm

I haven't personally tried it, but the IIO system is supposed to be able to meet your requirements.
http://events.linuxfoundation.org/sites ... _speed.pdf
Josh @ CIHOLAS Inc

Return to “SAMA5-based”

Who is online

Users browsing this forum: No registered users and 1 guest