"pppd: illegal instruction" How to resolve

Embsys
Dear Friends,

      After cross compiling ppp-2.4.5 with arm-none-linux-gnueabi-gcc tool
chain, the binaries in sbin directory "pppd" are ending up with "illegal
instruction". 

      Hopefully i get the response as soon as possible.

With best regards.

Juergen Beisert
Could be an alignment issue or the toolchain creates assembler instructions
not supported by your CPU (for example it creates instructions for an ARMv5
and your CPU is an ARMv4)

davef
readelf -a <filename>

Embsys
Dear all,

I response to Juergen Beisert & davef, the below is the elf format of the
binaries generated.

[root@localhost sbin]# readelf -h pppd
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0xe514
  Start of program headers:          52 (bytes into file)
  Start of section headers:          580732 (bytes into file)
  Flags:                             0x5000002, has entry point, Version5
EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           40 (bytes)
  Number of section headers:         38
  Section header string table index: 35

With Regards,
Embsys.

Embsys
This is the related output of readelf -a pppd(This binary is exiting with
illegal instruction on mini2440)

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "ARM10TDMI"
  Tag_CPU_arch: v5TE
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align8_needed: Yes
  Tag_ABI_align8_preserved: Yes, except leaf SP
  Tag_ABI_enum_size: int

This is the related output of readelf -a openvpn(This binary is executing
well on mini2440)

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "4T"
  Tag_CPU_arch: v4T
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align8_needed: Yes
  Tag_ABI_align8_preserved: Yes, except leaf SP
  Tag_ABI_enum_size: int

I hope the response shall be given as soon as possible.

With Best Regards.

Juergen Beisert
Embsys,

did you already read the output? Just simple:

readelf -a openvpn -> "Tag_CPU_arch: v4T"
readelf -a pppd -> Tag_CPU_arch: v5TE

Your Mini2440 is based on Samsung S3C2440 and its core is a ARMv4.
You are using a cross compiler with wrong setup or default setup for your
Mini2440 and the pppd. You must change the architecture while compiling:
"-march=armv4t" or using a different compiler with default setup for ARMv4

Embsys
Dear Juergen,

The following is the procedure i am following to cross-compile ppp-2.4.5
module for mini2440.

#./configure 

#CC=arm-none-linux-gnueabi-gcc LD=arm-none-linux-gnueabi-ld CFLAGS=”-pipe
-Os -mtune=arm920t -march=armv4T -mabi=aapcs-linux -msoft-float” 
LDFLAGS=”-L/PPPARM/usr/lib”   make

#make install

Juergen Beisert
And does the buildsystem honors your CFLAG settings? I guess: No.

Do you know my board support package for the Mini2440? The manual also
shows how to build your own toolchain. And this toolchain do not need any
tweaks later on to create correct code for the target architecture. Maybe
it could help you. Refer http://www.friendlyarm.net/forum/topic/2737

Embsys
But the main factor is that, the CFLAGS attributes are not accepted either
by the configure file nor Makefile of ppp modules. I am expecting technical
support from you friends.

Embsys
Dear Juergen,

In response to your reply, the buildsytem honors CFLAG settings, since i
have cross compiled OpenVpn modules with the same buildsystem i.e.
fedora12 and same toolchain arm-none-linux-gnueabi-gcc.

But the configure file of ppp module is not supporting the configure
parameters my friend.

Thanks for your concern & for the link sent by you.

With Best Regards,
Nikhil N.D.

davef
> I hope the response shall be given as soon as possible.

Unfortunately, my ADSL modem died last night so I couldn't respond in a
timely manner to the output of a <readelf> on your files.

> I am expecting technical support from you friends.

Perhaps you didn't mean <expecting> . . . that word in this context
expresses more than "hope to hear from someone" or "appreciate your
comments".

An excellent book, which you can get an on-line copy of, is "Building
Embedded Linux Systems" by Karim Yaghmour.

Good luck,
Dave

Embsys
Hi Davef,

       Please to see your reply. I have been able to resolve some typical
issues related to point to point protocol, but this bug is somewhat
different.  

       I couldn't understand why the configuration file is not accepting
the parameters CC, CFLAGS, LD, LDFLAGS etc. even i have tried to set these
flags during "make", except "CC" any other flag like CFLAGS,LD values are
not updated during "make". 

       Davef, is there any alternative method to resolve this issue ? I am
thankful to you for sending the reference book.

Thank You,
With Best Regards,
Nikhil N.D.

Juergen Beisert
Embsys,

with "buildsystem" I mean the autotoolized or simply make file based
approach of each package to convert the sources into binaries. This does
not include the host system and the also not include the toolchain.

To make each individual source package work, you must take a look into its
build approach.
This is what high level systems like buildroot/openembedded/PTXdist already
did for you.
If you build your packages by your own, you can't expect technical support
from others. No-one knows what you have done, what you have changed, what
your cross-compiler and library environment is and so on.
We can only guess in this case.

Juergen Beisert
"is there any alternative method to resolve this issue ?"
-> use a toolchain that is configured for ARMv4 as its default
-> your toolchain is configured for ARMv5 as its default
 -> that's why you must overwrite the architecture setting on each(!) call
 -> you can do that, but -> headache

Embsys
Dear Juergen Beisert & davef,

Thanks for your concern towards the reply given for the query. I have
successfully installed the tool chain for armv4t architecture 
"arm-angstrom-linux-gnueabi-gcc" developed by "openmoko". I am ending up
with the following error while executing...

#./arm-angstrom-linux-gnueabi-gcc xxx.c
as: unrecognized option '-mfloat-abi=soft'

I shall be appreciating your valuable suggestions.
     
With Best Regards,
Nikhil N.D.

davef
You could try this:

-msoft-float -D__GCC_FLOAT_NOT_NEEDED

from:

http://mini2440vietnam.blogspot.com/2011/04/upgrade-qt462-in-mini2440.html

I have never used arm-angstrom-linux-gnueabi-gcc

Good luck.

Dave

Juergen Beisert
Embsys,

you should test with "arm-angstrom-linux-gnueabi-gcc -v" what the default
settings of this compiler are. Maybe you do not need to change architecture
specific settings anymore. For example my ARMv4 compiler was built with
these settings:

--with-float=soft --with-fpu=vfp --with-arch=armv4t

So, in may projects no software package has to be changed regarding the
architecture specific setting when I use this toolchain.

Embsys
Dear Davef,

Where can i set this flag. Can't we give this flag at command prompt during
compilation? I have used it many times  while configuring software, but how
can i use it while compiling.?

With regards,
Embsys.

Embsys
Dear Juergen Beisert,

Then what according to your opinion Juergen i should do while using this
compiler "arm-angstrom-linux-gnueabi-gcc" to eleminate the following error 

#./arm-angstrom-linux-gnueabi-gcc xxx.c
as: unrecognized option '-mfloat-abi=soft'

With Best Regards,
Nikhil N.D.

davef
export CROSS_COMPILE=arm-armstrong-linux-gnueabi-
export CC=${CROSS_COMPILE}"gcc -march=armv4t -msoft-float
-D__GCC_FLOAT_NOT_NEEDED"

keywords: export compiler options flags

Juergen Beisert
Embsys,

no, you should check with "arm-angstrom-linux-gnueabi-gcc -v" if this
toolchains does already what you need: Generating code with correct
architecture settings. If yes, you do not need to change any architecture
specific settings like "-march=armv4t" or "-msoft-float" any more. They are
the default then.
You still need to add these command line options if your toolchain does
_not_ use it by default.

Embsys
Dear Juergen & davef,

With your kind efforts, I ultimately succeeded in cross-compiling. Thanks a
lot for this. 

But i struck with another error my friends. The system is unable to respond
to /dev/ttyS0 though i have installed all the related drivers for PPP &
serial. 

Hence, I request you to rectify my error with the type of drivers for ppp &
serial needed to be selected before building the zImage for mini2440.

Thank You.

With Best Regards,
Embsys.

Juergen Beisert
You are running an ARM based system with a different UART hardware than a
x86 based PC. Try "/dev/ttySAC[0-2]" instead.

Embsys
Dear Juergen Beisert,

Thanks a lot my friend.

With Regards,
Nikhil N.D.

Anna Hazare
Dear All Trouble Shooters,

I am impressed with the kind of path you have shown to Embsys. I have
successfully installed PPP on mini2440 and connected to PPP server and thus
internet. But when I run openvpn over ppp-network iam getting the following
error, 

TLS negotiation failed to occure within 60 secs (check network
connectivity)

But, I am able to establish connection between openvpn server and client
with normal TCP/IP connection.

Can any one help me in this regard.

With Best Regards,
Nikhil N.D.