views:

159

answers:

1

Hi community,

i want to run a simple hello world, written in c, app. on my at91sam9rl-ek.

is it possible without an os?

and (if it is) how do i have to compile it? -right now i try using g++ lite for creating arm code

(In general which programms can the board start without OS, assembler, arm code?)

A: 

Sure, no problem running without an operating system, I do that kind of thing daily...

http://sam7stuff.blogspot.com/

You programs are, at least at first, not going to resemble desktop applications, I would avoid any libraries C libraries, no printfs or strcmps or things like that until you get the feel for it and find the right tools. No floating point as well. add some numbers do some shifting blink some leds.

codesourcery lite is probably the fastest way to get started, the gnueabi one I believe is the one you want.

This winarm site has a compiler and tons of non-os projects for seems like every arm based microcontroller. http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/

Atmel is very very good about information, no doubt they have example programs you can try as well on the eval board.

emdebian is another cross compiler that is somewhat up to date and has binaries. building a gcc from scratch for cross compiling is not bad at all. The C library is another story though, and even the gcc library for that matter. I find it easier to do without either library.

It is possible get a C library working and run a great many kinds of programs. Depends on what you are looking to do. Ahh, just looked at the specs, that is a pretty serious eval board, plenty of power for an operating system should you choose to run one. You can certainly run programs that use the display as a user interface. read/write sd cards, usb, basically everything on the board, without an os, if you choose.

dwelch
Well thx for the response, so which code can my board understand? didnt get it at all. Btw when i compile with winarm, yagarto or codesourcery i am gettin some "undefined reference to _exit.. _lseek... etc" errors. I read about some newlib and syscalls which i need for my board, maybe you got another hint for me?
Gobliins
what are you compiling, my guess is you are trying to compile something that needs a C library? And how are you compiling it, those are C library calls which are likely compiled to use an OS. I normally use gcc with these options. -Wall -O2 -nostdlib -nostartfiles -ffreestanding and provide my own startup code and dont use c or gcc libs.
dwelch
Newlib is/was a good way to run embedded with a C library. Getting a combination of binutils, gcc, and newlib that works has become difficult. using C++ makes that nightmare worse. Newlib has a very very easy way to create your own implementation of the system calls, exit, abort, seek, open, close, read, write, etc. Instructions like these http://www.dwelch.com/ipod/gccarm.txt used to work. And a compiler and libs like that would make what you are doing that much easier
dwelch
I have not dug into how codesourcery or winarm or yagarto or devkitarm to see how they solved the system calls in the C library problem. At the time I found it easier to build my own that deconstruct and rebuild portions of theirs.
dwelch
Well for first just some simple app. like hello world in c no c++, libs i use only stdio, stdlib.
Gobliins
The linker arm-none-eabi-gcc i use from yagarto tries to get reference to these functions in a path "C:\msys\1.0\home\yagarto\newlib-build\arm-elf\newlib\....." but i dont have this path, never had it.
Gobliins
When i create my own syscalls i get some warnings but it had compiled, so now i got a .exe file? is that correct for the arm board, i always thought bout .bin, .hex, .asm? should be the result
Gobliins
btw used compiler and linker from codesourcery, seems kinda the same results as yagarto with the newlib stuff, referene to another path
Gobliins
int main (void) { printf("hello world\n"); return(0); } is an incredibly high level complicated, advanced, program for a no-os first program. I assume you did not literally mean that. You should remove all includes no stdio.h no stdlib.h no string.h, no libs at all
dwelch
void main ( void ) { int i; for(i=0;i<100;i++) continue; } is more along the lines of the first program to try to cross compile. then add in writes to registers to make an led blink.
dwelch
ok i can compile now with arm-none-eabi-gcc -g -Wall but i dont get the .bin as result
Gobliins
ok i have it thx
Gobliins
only thing, how do i set the entry point (start address)?
Gobliins
when linking you can use a linker script or -Ttext=0x123456 kind of thing. My blinker example should have that if not let me know and I will post how to do it.
dwelch
do you work with eclipse?
Gobliins
no I use a text editor and a command line to run make.
dwelch
Which debugger do you use for your arem bare metal programms?
Gobliins
I do not use any debugger
dwelch
because when i run my programs in the debugger, they work pretty good. But as soon as is want to run the binaries from the board nothing happens. And i guess its because some errors in my startup / linkerskript
Gobliins
i tried your code from the sam7blog but didnt work for me neither
Gobliins
ok got it worked. seemed like i didnt copy all the data.
Gobliins
good to hear, I was about to have you send me your code or examples of what doesnt work.
dwelch