"Hello world" (console) segmentation fault

David
Hi all,

I have been able to compile the example hello world (console) under ubuntu
8.10 using arm-linux-gcc delivered on the dvd following the tutorial.

It compiled fine, but once transfered on the board when I tried to execute
it on the board (with telnet from my main computer) I got "segmentation
fault" ?

I tried to compile both from 2 different computers :
number 1 : ubuntu 8.10 (x64) dual core processor
number 2 : ubuntu 9.10 (x86) (atom processor)

Can anyone help ?

best regards,
David

David
I forgot to mention that mini2440 is running under qtopia (image from
"factory") except network settings adjusted ...

I also tried "file hello" on the binary and it returned the same as in the
manual (elf 32bit files LSB, dynamiccaly linked etc ...)

I am running out of ideas ...

Next step will be to install Fedora on my computer but I doubt it changes
anything ?

gene.sally
Hi,

You may want to try statically linking and then trying to run the
application.  

arm-linux-gcc -s yourfile.c -o thebinary

IIRC (my apologies if I'm wrong), the toolchain's libraries don't match
with the libraries on the board and that's the cause of the problem.

Regards,
gene

David
Dear gene,

I've tried but I still get segmentation fault. The binary I get is smaller
for this way.

I've also tried to load the qtopia image from this site in the board but
still the same.

What do you advice me to do ? Do I have to build the whole kernel and the
toolchain too ?

1) Is there somewhere a "reference toolchain" and a the matching
"linux+qtopia image " ?

2) What kind of linux distribution do you use ?

Thanks for your help,
David

gene sally
David,

>> The binary I get is smaller for this way

When statically linking, the binary should be much larger than the binary
that uses shared libraries.  Can you double check that that file was indeed
statically linked?  Use 

$ file thebinary

As for what I'm using: I built a new toolchain & root file system using
buildroot (http://buildroot.uclibc.org/).  I never used the kernel/root
file system/toolchain that was shipped with the board for any development
activity.  If you want to get a clean, known development environment with
all of the sources (rfs, libraries, toolchain), use buildroot.


Regards,
gene

David
The file is still dynamically linked ... strange toolchain probably,

I'll go for buildroot as you mentionned, I used it on AVR32  (after some
hours of hard fight) but know I should be able to do the same for ARM9,

best regards,
David

David
Gene,

would you be so kind to share the config file of your buildroot for
mini2440, I've tried but there are some option I'm not sure ... 

thanks

lalitha
Dear David,

 please can you share how did you compile arm-linux-gcc toolchain on linux
host machine,and which toolchain did you use.

David
Dear Lalitha, I used the toolchain from the dvd and the examples too. The
toolchain the version where there is only 1 compiler for all (not 3
compilers)

thanks

lalitha
Dear David please can you tell the folder name which you have compiled and
steps to compile.

David
I tried to compile "hello" example, using arm-linux-gcc located at
"/usr/local/arm/4.3.2/bin"  

it launches : arm-linux-gcc -o hello hello.c

then the produced file return a segmentation fault when executed on
mini2440 with "factory" installation

"file hello" returns :
hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux
2.6.14, dynamically linked (uses shared libs), not stripped

" arm-linux-gcc -v" returns :
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/lite-respin/linux/src/gcc-4.3/configure
--build=i686-pc-linux-gnu --host=i686-pc-linux-gnu
--target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap
--disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld
--enable-languages=c,c++ --enable-shared --enable-symvers=gnu
--enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2008q3-72'
--with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls
--prefix=/opt/codesourcery
--with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc
--with-build-sysroot=/scratch/julian/lite-respin/linux/install/arm-none-linux-gn
ueabi/libc
--with-gmp=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-li
nux-gnueabi-i686-pc-linux-gnu/usr
--with-mpfr=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-l
inux-gnueabi-i686-pc-linux-gnu/usr
--disable-libgomp --enable-poison-system-directories
--with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux
-gnueabi/bin
--with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux
-gnueabi/bin
Thread model: posix
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) 

thanks,
David

Killerwatt
It looks as though the parameters for your target system does not agree.

lalitha
Dear David,

  please can you share how did you install arm-linux toolchain from
friendly_arm\linux\arm-linux-gcc-4.3.2\usr\local\arm\4.3.2\bin ....,
steps involved in installing toolchain.



Regards,
Lalitha

david
Dear Lalitha,

I've extracted the file arm-linux-gcc-4.3.2.tgz from the dvd keeping the
same path as the archive "/usr/local/arm/4.3.2/" then it has 5
subdirectorys "arm-none-linux-gnueabi" "bin" "lib" "libexec" "share"

Which line makes you think there is something wrong ?

Happy new year !

Best regards,
David

david
And the I added "/usr/local/arm/4.3.2/bin" to the PATH

lalitha
Dear David,

  thanks lot I got the point now. one more issue is in which makefile i
should add this PATH. 
where should I copy linux-2.6.29-mini2440-20090708
(once gain I mean path in the Linux host machine)

Regards
Lalitha

david
I completed the linux PATH variable which you can check typing "echo $PATH"
(where Linux try to find executables when you type a command)

type something like this :
export PATH=$PATH:/usr/local/arm/4.3.2/bin
(not sure of the syntax check on google please)

Killerwatt : this question was for you : "Which line makes you think there
is something wrong ?" if you have a working config can you show me what I
should get ?



David

Killerwatt
This is still going on already. "then produced the file return a
segmentation fault when executed on mini2440 with" factory "installation"

I guess that the problem is not the compiler, but at the boot loader.
Therefore one must "pull S3C2440.pdf" advice.
Only in this way, the parameters for the target system are comparable.

ftorama
Coming a bit late, sorry....

How did you send your binary to the board?

I met the same problem because I used Filezilla for transmitting programs,
having let it in ASCII mode. When I put it to binary mode, everything
worked fine

lalitha
I have successfully set the PATH and able to compile the
linux/examples/led.c file but I am facing how to run this on target
machine(I mean on friendlyarm board)

Jaquouille
Hi ftorama, 

I also had the "segmentation fault" problem and tried to solve it during 2
days, and finally I read your post and force a BINARY transfert in
Filezilla ... and now it works perfectly.

Thanks

Xristos
ftorama you are my Hero!!! :)

LDS
Anyone remembered to use a usb flash disk and just copy the file?
That's why there's a USB host port in there.


Regards,
Luis

Al W
I was hoping this would solve my problem which seems to be exactly the
same. But I had been using binary ftp and the files match exactly. Further,
the file command correctly identifies the file after it has been to the
target board.

I do note that I must use -static or I get a "not found" error, so clearly
I have a missing .so somewhere, but with the static link I get a
segmentation fault.

Any help?

Al W
Well just to follow up, I figured out how to scrub the flash and loaded a
newer image in. Now all works as expected.

FAtih
Hello everybody,

    I have this segmentation fault too. I am using
arm-none-linux-gnueabi-gcc with eclipse IDE for cortex-arm8 processor but i
send the binary file to the beagleboard with scp i get this segmentation
fault error. How can i solve the problem? what does this problem show us?

Fatih

chris
Hi there,
I have the same segmentation fault and I have tried two different projects
(though both are helloworld), one I tried compiling using terminal on
ubuntu and the other I compiled using eclipse , the one with terminal works
fine on ARM board but the one compiled using eclipse gives me "segmentation
fault" :

project name : hello

arm-linux-gcc -o hellogcc hello.c
file hellogcc gives 

hellogcc: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically
linked (uses shared libs), for GNU/Linux 2.6.14, not stripped

while the second project I compiled using eclipse 

project name : eclipse1 

file eclipse1 gives

eclipse1: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically
linked (uses shared libs), not stripped

NOTE THE MISSING "for GNU/Linux 2.6.14" any idea why ? Can that be the
reason for segmentation fault ? 

Ta,
Chris

YodArm
Hello everybody,

This problem is probably due to a corrupted file on the target board.

Please check the used ftp tool transfer mode:

It must be BINARY (ASCII mode is generally the default!).

In ASCII mode, the CR (0x0D) code is interpreted as an end of record (line)
so the file's structure is not respected in case of a binary file
containing this character value. The case happens almost everytime.

Best Regards,

YodArm

Josh
@YodArm : WOW you just saved my life! I was fighting again a "segmentation
fault" on my server for a couple of weeks and I start loosing hope... I
switched my ftp client to BINARY and it solves the problem! Thank again,
you are a genius :)

cjc
YodArm,

you are so right!!!!!

i used filezilla. After i changed the mode into binary, the 'segmentation
fault' disappeared.

this is wired though.

i have used the filezilla in ascii mode for a while for EPC-8000 pxa270
linux, and it works fine.