1

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

László Papp
  • 51,870
  • 39
  • 111
  • 135
Gobliins
  • 3,848
  • 16
  • 67
  • 122

1 Answers1

0

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.

old_timer
  • 69,149
  • 8
  • 89
  • 168
  • 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 Sep 15 '10 at 08:14
  • 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. – old_timer Sep 15 '10 at 13:30
  • 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 – old_timer Sep 15 '10 at 13:33
  • 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. – old_timer Sep 15 '10 at 13:35
  • Well for first just some simple app. like hello world in c no c++, libs i use only stdio, stdlib. – Gobliins Sep 16 '10 at 07:52
  • 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 Sep 16 '10 at 07:56
  • 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 Sep 16 '10 at 07:59
  • btw used compiler and linker from codesourcery, seems kinda the same results as yagarto with the newlib stuff, referene to another path – Gobliins Sep 16 '10 at 08:08
  • 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 – old_timer Sep 16 '10 at 20:45
  • 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. – old_timer Sep 16 '10 at 20:47
  • ok i can compile now with arm-none-eabi-gcc -g -Wall but i dont get the .bin as result – Gobliins Sep 22 '10 at 12:22
  • 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. – old_timer Sep 23 '10 at 19:21
  • Which debugger do you use for your arem bare metal programms? – Gobliins Oct 11 '10 at 13:11
  • 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 Oct 22 '10 at 06:58
  • i tried your code from the sam7blog but didnt work for me neither – Gobliins Oct 22 '10 at 11:04
  • good to hear, I was about to have you send me your code or examples of what doesnt work. – old_timer Oct 25 '10 at 15:13
  • so i am now running a linux buildroot 2.6.x kernel on my board. And i wonder which cross compiler i should use now. Do i still use the arm-none-eabi-gcc or do switch now to a arm-elf, arm-linux gcc? – Gobliins Nov 15 '10 at 09:39
  • switch to the arm-none-linux-gnueabi one, if using Codesourcery that is, if not codesourcery then you still one one made to build linux binaries. – old_timer Nov 15 '10 at 14:29
  • One more time i need your advice, i got already some good programs running on my target machine but when it comes to hardware access i fail. Can you give me some advice what needs to be done for accessing the hw again? – Gobliins Dec 23 '10 at 08:41
  • what kind of hardware are you talking about, things inside the chip like timers or things outside the chip? – old_timer Dec 23 '10 at 22:21
  • First some LED´s then Buttons (HW Interrupts) from the board maybe later the Internal Clock. – Gobliins Jan 03 '11 at 07:32
  • btw i now have linux as os and compiled my code with arm-none-linux-hnueabi – Gobliins Jan 03 '11 at 09:00
  • ok for the leds i found out theres a /sys/class/leds/ directory with some stuff like brightness, device, power, uevent etc. – Gobliins Jan 03 '11 at 12:17
  • Well you are beyond my experience at this point, I normally work in a non-operating system environment, right on the metal. linux provides mechanisms for gaining access to and accessing devices (map the memory space for the registers, then read/write those pointers, etc). – old_timer Jan 03 '11 at 23:30
  • ok np then, and thx anyways. If you find sth. of intrest on this subject tough, you can tell me. – Gobliins Jan 05 '11 at 08:08
  • But when there is also a need to use interfaces such as ethernet, I guess it will be problematic to work with bare-metal. What do you think ? – ransh Jun 19 '15 at 06:43
  • not necessarily there are ip stacks that are made for bare metal. sure you do need to manage several tasks which on an operating system are threaded but dont have to be. servicing the peripheral to receive or send data, checking the data, wading through the layers of the ip stack, dealing with arps and such as needed, etc. an operating system or making your own (then you have to ask am I still bare metal) enough that it can time slice multiple tasks does make something like ethernet easier. – old_timer Jun 19 '15 at 14:23