Hi everyone, I'm trying to execute the pthread example available on examples.tgz folder, but getting the following error when execute it: [root@FriendlyARM plg]# ls armpthread pen [root@FriendlyARM plg]# ./armpthread Illegal instruction [root@FriendlyARM plg]# I followed the steps described on "7.2.8 Thread programming examples" from micro 2440 user manual. I Attached the source code, with some additional debug lines (printf) that i had wrote, but the program doesn't even run. Compiling it with g++ and testing on Ubuntu works fine. The libpthread.so is on place, so i have no more ideas. [root@FriendlyARM /lib]# ls -la | grep pthread -rwxr-xr-x 1 root root 84248 Mar 26 2009 libpthread-2.8.so lrwxrwxrwx 1 root root 17 Apr 29 2009 libpthread.so.0 -> libpthread-2.8.so [root@FriendlyARM /lib]# Thanks in advance PS: my Makefile: CROSS=arm-linux- all: pthread_test pthread_test: $(CROSS)gcc -static -o pthread_test pthread_test.c -lpthread clean: @rm -vf pthread_test *.o *~
Illegal instruction - pthread example
sorry, forget to say that i renamed the cross compiled file to armpthread. I was testing it on ubuntu as pthread_test (gcc compile) and on qtopia (arm-linux-gcc compile) as armpthread. I did that to don't make any mess with names... xD
Davef, take a look at your .../arm/4.3.2/bin directory. I have arm-none-linux-gnueabi- and a lot of other executables: -rwxr-xr-x 1 eduardo eduardo 62 2009-03-25 04:19 arm-linux-g++ -rwxr-xr-x 1 eduardo eduardo 62 2009-03-25 04:19 arm-linux-gcc -rwxr-xr-x 2 eduardo eduardo 194440 2008-11-18 13:06 arm-none-linux-gnueabi-g++ -rwxr-xr-x 2 eduardo eduardo 192168 2008-11-18 13:06 arm-none-linux-gnueabi-gcc I got these files on micro 2440 DVD. Can anybody compile and test this pthread example on mini/micro 2440 for me please? Thanks in advance.
eduardo, I know they (arm-linux- variants) are in there and that they are the same size as the ones labelled arm-none-linux-gnueabi-, but for a reason that I do not understand people always seem to put: CROSS_COMPILE=arm-none-linux-gnueabi- Sorry that doesn't help you with your problem. I'll have look at your example tonight after work. Dave
eduardo, Don't know if this will be much help . . . I am using Eclipse and to do a cross-compile I have to make the source file thread.cpp to get it to build. I changed your: main() to int main(void) and it didn't get rid to the warning on line 19, but it looks like you have more serious problems. **** Internal Builder is used for build **** arm-none-linux-gnueabi-g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc/thread.o ../src/thread.cpp ../src/thread.cpp:19: warning: ISO C++ forbids declaration of 'main' with no type ../src/thread.cpp: In function 'int main()': ../src/thread.cpp:26: error: invalid conversion from 'void*' to 'void* (*)(void*)' ../src/thread.cpp:26: error: initializing argument 3 of 'int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*)' Build error occurred, build is stopped Time consumed: 719 ms. Good luck!
Davef, Thanks again for your help. YOU ARE GREAT!! With your help I solved the problem. I changed the compiler to g++ and built other pthread_test executable. New source code is attached. Have no time to test it now, but i think the big mistake was on "-static" parameter on the first makefile. xD regards ps: makefile: CROSS=arm-linux- all: compile compile: g++ -o pthread_test pthread_test.c -lpthread cross: $(CROSS)g++ -o pthread_test pthread_test.c -lpthread clean: @rm -vf pthread_test *.o *~
While searching on an Illegal Instruction I'm getting, I found your post. Not sure if your issue is the same as mine, but I tracked mine down to the use of a virtual function. I cannot find any way to get a virtual function to execute without producing an "Illegal Instruction". Here is a simple C++ program that runs fine on i386 and crashes on arm (compiled with 4.3.2 version of arm-none-linux-gnueabi-g++): Is there a fix to this in a later version of the arm compiler? ------ CUT HERE ------ #include <stdio.h> #include <stdlib.h> class Illegal { public: virtual void Crash(); }; void Illegal::Crash() { printf("Made it!\n"); } int main() { printf("main\n"); Illegal* i=new Illegal(); i->Crash(); delete i; } ------- CUT HERE -------
My mistake-- I had previously gotten by without using the -mcpu=arm9 flag when compiling. Having written an almost 5000 line program without running into this problem, I didn't suspect it until I assembled the program and saw the use of the BLX instruction was causing the crash. Adding the flag fixes the problem nicely.