Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to build ARM Linux toolchain?

Status
Not open for further replies.

Sobakava

Full Member level 6
Joined
Mar 27, 2002
Messages
350
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,298
Activity points
3,342
Hi,

I've an ARM9 board with AT91RM9200 and ARM-Linux working on it. It boots with Uboot using RS232+Ethernet.

I want to develop software for this platform.. Simple 'hello world' application first...

I am not experienced on linux. I just installed Cygwin to my Win2K PC.

Could anyone explain me how to build my toolchain for this configuration?


https://ecos.sourceware.org/build-toolchain.html
I tried this way. But I am in suspect I did something wrong.

mkdir -p /tmp/build/binutils
cd /tmp/build/binutils
/src/binutils-2.13.1/configure --target=TARGET \
--prefix=/gnutools -v 2>&1 | tee configure.out

this batch gives "could not find configure" I think I do it in wrong directory.

anyway, I need clear and good explanation from building toolchain to compiling my first 'hello world' application.

Best Regards
 

Re: ARM Linux Toolchain

For building GNU tools:
**broken link removed**
**broken link removed**
**broken link removed**
 

ARM Linux Toolchain

Hi,

I installed the tools from https://www.gnuarm.com on Cygwin under Win2K.

Then I wrote a simple test code :

int main() {

printf("Hello World");
}


and compiled with:

arm-elf-gcc -mcpu=arm920t -mthumb -O2 -g -c hello_world.c


then linked with:

arm-elf-gcc -mcpu=arm920t -mthumb -o hello_world hello_world.o -lc

there are no error or warning messages appear.
so, now I've linked hello_world file. It is 216KB.
Is it normal?? (object code is 2100bytes)

are the compiler and linker options for my executable correct? (My CPU is Atmel ARM9 AT91RM9200 and ARM-Linux 2.95.3 working on it)

If I copy this executable into my RAMDISK image which my board loads at startup, could I run it after booting?

Regards
 

ARM Linux Toolchain

**broken link removed**

now I can simulate my code in gdb as described here... it is working. And I can see it is ELF Executable using "file" command of Cygwin.

so, will it work on my target board?
 

Re: ARM Linux Toolchain

You will have to check the linker file is correctly setup for your target, eg. ram/rom memory addresses.
Also you will need your own startup file as the default one will probably not work for your target.

For initial testing do everything in ram.

Using printf will add quite a bit of code, you can use iprintf which is a integer only printf (no floating support) to reduce code size.
Also using uclibc instead of newlib can help with code reduction.

Also for your first test I would not use thumb mode or any optimisations (O0 instead of -O2).

Regards
NTFreak
 

ARM Linux Toolchain

now, I don't have linux installed here yet. and my bootloader loads a ramdisk image from PC.
I can see the contents of this ramdisk image under windows using Explore2fs utility. but I can not add a file to it (explore2fs is read-only tool)

and:
mkdir r
mount -o loop ramdisk /r
--->adding files
unmount

does not work under Cygwin.

How can I add my files to this ramdisk image for testing?
 

ARM Linux Toolchain

finally I could transfer my hello_world file to target.
I'm using Hyperterminal with my ARM9 board.

but unfortunately when I try to execute hello_world file, it says : bash: hello_world: command not found.

even if I can see the file with "dir" command.

it seems linux (arm) does not see the file as a valid executable.

under Cygwin:

file hello_world <
hello_world: ELF 32-bit LSB executable, ARM, version 1 (ARM), statically linked, not stripped.


I copied an executable (mount) my arm-linux archive to Cygwin folder for see the difference:

file mount <
mount: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dyn
amically linked (uses shared libs), stripped


so, mount command executable works but my hello_world executable does not work. What am I doing wrong?

ntfreak, you told :
"You will have to check the linker file is correctly setup for your target, eg. ram/rom memory addresses.
Also you will need your own startup file as the default one will probably not work for your target.
For initial testing do everything in ram. "

how to do that?

regards
 

Re: ARM Linux Toolchain

What permission has the "hello_world" ?
Is the "executable" bit set?

If you try to execute it via full path like "/usr/bin/hello-world"...what does it say then? "Permission denied" ?
 

ARM Linux Toolchain

how to set file's executable bit if it is not set?
 

Re: ARM Linux Toolchain

Ui...developing for Linux and no clue about its usage? (o;


Code:
chmod +x filename


Please get some Linux/UNIX ebooks (o;
 

ARM Linux Toolchain

come on...
I'm new to linux and arm-linux, this is why asking my questions here. probably they are stupid questions for professionals but the help I'm getting in this forum really improves my skills and it saves my time... this is why this forum exists...

of course I need to learn linux commands and details as soon as possible, but now, I'm a bit excited about running my first application on arm-linux. I'm sorry if I bother you..

I tried to set hello_world's exe using "chmod +x hello_world" but as I can see, nothing changes... I use "ls -al" to list files... I'm doing this under Cygwin... probably I can't set executable bit under Cygwin, I'll try to set it under arm-linux on target board... but... the "mount" file, it's executable bit is also not set but it is working...

probably I've problems with linking. I don't know if I need some extra parameters for entry point of executable etc...

regards
 

Re: ARM Linux Toolchain

Can you post here the "ls -l" output?

Ehhm..did you try now with absolute path like "/usr/bin/hello_world" ?

I assume all needed libraries are in place on your target system since other programs can find them...
 

ARM Linux Toolchain

Did you try to run bin fle when logged as root user ?
 

Re: ARM Linux Toolchain

Cygwin under Win2K on an FAT32 partition:

  • $ ls -al <
    total 15645
    -rw-r--r-- 1 Administ None 216193 Aug 24 10:27 hello_world
    -rw-r--r-- 1 Administ None 53 Aug 24 10:20 hello_world.c
    -rw-r--r-- 1 Administ None 2100 Aug 24 10:27 hello_world.o
    -rw-r--r-- 1 Administ None 59692 Aug 25 11:06 mount

    chmod +x hello_world <

    $ ls -al <
    total 15645
    -rw-r--r-- 1 Administ None 216193 Aug 24 10:27 hello_world
    -rw-r--r-- 1 Administ None 53 Aug 24 10:20 hello_world.c
    -rw-r--r-- 1 Administ None 2100 Aug 24 10:27 hello_world.o
    -rw-r--r-- 1 Administ None 59692 Aug 25 11:06 mount

    $ file mount <
    mount: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), stripped

    $ file hello_world <
    hello_world: ELF 32-bit LSB executable, ARM, version 1 (ARM), statically linked, not stripped

I'll also post what do I see when I try to execute hello_world using full path on target soon.
 

ARM Linux Toolchain

now I changed flags of hello_world under Linux on target board.

it is -rwxrwxrwx

when I try to run it /usr/bin/hello_world
it says:
Segmentation fault

What's wrong?
 

Re: ARM Linux Toolchain

$ file hello_world <
hello_world: ELF 32-bit LSB executable, ARM, version 1 (ARM), statically linked, not stripped

How did you compile/link this "hello_world" program and what libraries did you link against?

Have you tried just a simple program which does nothing and doesn´t use any libraries?
 

ARM Linux Toolchain

int main() {

printf("Hello World");
}


and compiled with:

arm-elf-gcc -mcpu=arm920t -mthumb -O2 -g -c hello_world.c


then linked with:

arm-elf-gcc -mcpu=arm920t -mthumb -o hello_world hello_world.o -lc


this was my compiling and linking.

now I removed printf() and just used and empty for() loop and compiled with same way,
now I'm adding it to ramdisk image. (my god, there must be an easier way to non-linux hosts to add this file!)
 

Re: ARM Linux Toolchain

Don't know much about ARM (yet ;o)...

-mcpu=arm920t -mthumb

But is your Kernel same way compiled as your application?
Or do you see how the "mount" program is compiled for Arm?

Maybe you wanna try remove the "thumb" mode?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top