Building Cross-Compiler: Intel Xeon E5649 >>> ARMv7 with libcURL - c

i don't exactly understand the manual/help from libcURL. I'm trying to build a Cross-Compiler including the libcURL library. I installed a Cross-Compiler on my Server with the help of this video and can start it with arm-linux-gnueabihf-gcc hello_simple.c. I could compile simple c-code like printf ("Hello World"); After that i tried to install libcURL and read that I need to compile the lib and use the configure file to set the build and host. I used different configuration like: sudo ./configure --build=i586-pc-linux-gnu --host=arm-linux --target=arm-linux --prefix=/home/nevadmin/dev/gcc but neither did one worked. I think I'm making somewhere mistakes. This is the output after configuration is made:
curl version: 7.46.0
Host setup: arm-unknown-linux-gnu
Install prefix: /home/nevadmin/dev/gcc
Compiler: gcc
SSL support: no (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} )
SSH support: no (--with-libssh2)
zlib support: no (--with-zlib)
GSS-API support: no (--with-gssapi)
TLS-SRP support: no (--enable-tls-srp)
resolver: default (--enable-ares / --enable-threaded-resolver)
IPv6 support: no (--enable-ipv6)
Unix sockets support: enabled
IDN support: no (--with-{libidn,winidn})
Build libcurl: Shared=yes, Static=yes
Built-in manual: enabled
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
SSPI support: no (--enable-sspi)
ca cert bundle: no
ca cert path: no
LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS support: no (--enable-ldaps)
RTSP support: enabled
RTMP support: no (--with-librtmp)
metalink support: no (--with-libmetalink)
PSL support: no (libpsl not found)
HTTP2 support: disabled (--with-nghttp2)
Protocols: DICT FILE FTP GOPHER HTTP IMAP POP3 RTSP SMTP TELNET TFTP
My Server cpuinfo:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 44
model name : Intel(R) Xeon(R) CPU E5649 # 2.53GHz
stepping : 2
microcode : 0x15
cpu MHz : 2533.423
cache size : 12288 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat dtherm
bogomips : 5066.84
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:
And my controller:
Processor : ARMv7 Processor rev 2 (v7l)
BogoMIPS : 298.80
Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x3
CPU part : 0xc08
CPU revision : 2
Using for example gcc hello_world.c -o hello_world it compile it for the amd processor architecture and not arm. It seems I'm missing the linking to the library for libcURL? I appreciate every help. And sorry my english, it's not my native language.
Linking with L/home/nevadmin/dev/gcc -lcurl is working an I can compile a c-code with libcURL but it still compiling it for amd64 and not arm. :/

You need to set the proper compiler to use when you configure curl. If you look at curl's configure output from
./configure --help
You'll see this at the end:
...
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
You can set these variables with a command line like:
CC=arm-linux-gnueabihf-gcc ./configure --build=i586-pc-linux-gnu --host=arm-linux --target=arm-linux --prefix=/home/nevadmin/dev/gcc
(You don't need the "sudo" to configure.)
gcc by itself will give you an AMD executable. You need to use arm-linux-gnueabihf-gcc to get an ARM executable.
Notice that in your curl configuration output it says
Compiler: gcc
That's why your getting a curl library built for your AMD. Bibliothek is called "library" in English. ;-)
If you continue to have problems cross compiling for ARM you could take a look at the binary releases of the cross compilation tool chain ELLCC. As of version 0.1.21 it comes with several pre-compiled libraries, including curl. Here's the ChangeLog.

Related

How to emulate cortex-m linux with qemu?

this is my code and I want to run it on a cortex-m4 linux based board (stm32f429) but before that I want to test my program on my pc using qemu.
#include <iostream>
int main()
{
std::cout << "Hello, World!" << std::endl;
return 0;
}
I have compiled it with this command : arm-linux-gnueabi-g++ -static -mcpu=cortex-m4 hello.cpp -o hello and I checked the generated elf file with readelf and this is the output:
$ readelf -A hello
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7E-M"
Tag_CPU_arch: v7E-M
Tag_CPU_arch_profile: Microcontroller
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_CPU_unaligned_access: v6
this is how I'm trying to emulate it: qemu-arm -cpu cortex-m4 hello
but it throws this error:
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction
even when I tryied to run it on my physical board, my kernel throwed error -8 which is a ENOEXEC error or basicaly: Exec format error
I tryed it with all cortex-m CPUs but none of them worked (cortex m0, m3, m4, m7)
what is wrong with my elf file? why qemu and my physical board throws this error?

Running ARM binaries on x86_64

I'm not sure if SO is the best place to ask this question but...
I've compiled my C program on, Linux Ubuntu (16.04), using
gcc -o MM1.x86 -O3 -static -mavx2 -g -Wall MM1.c
Running the file command
file MM1.x86
MM1.x86: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=078be440b466ba97bd4bf468b24eee35f8c6a01f, not stripped
But I've also cross compiled the same source file for ARM using
arm-linux-gnueabi-gcc -o MM1.ARM -O3 -static -g -Wall MM1.c
Running file
file MM1.ARM
MM1.ARM: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=b6582e1073682d41eb5262ad5393cebb8578e05d, not stripped
But after running the ARM compiled program, I was wondering how does it even run on x86_64 if it was compiled for ARM architecture?
lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 60
Model name: Intel(R) Core(TM) i7-4790 CPU # 3.60GHz
Stepping: 3
CPU MHz: 886.640
CPU max MHz: 4000.0000
CPU min MHz: 800.0000
BogoMIPS: 7183.90
Virtualisation: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
NUMA node0 CPU(s): 0-7
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts
I did notice that the ARM version runs slightly slower, why is this so?

PROS + Vex Cortex: No response when requesting system info

Using Purdue Robotics Operating System with a Vex Cortex on OS X. Attempting to flash it with the included uniflash program, but it is throwing an error during the flash process. Here is the logs.
CC -I../include -I../src init.c
LN ./bin/auto.o ./bin/init.o ./bin/opcontrol.o ./firmware/libccos.a -lgcc -lm to bin/output.elf
text data bss dec hex filename
12108 0 3840 15948 3e4c ./bin/output.elf
arm-none-eabi-objcopy ./bin/output.elf -O binary ./bin/output.bin
UniFlash v0.7 by Stephen Carlson
Using serial port /dev/tty.usbmodem1411 (USB Serial)
Stopping user code... done.
Error: No response when requesting system info
Interrogating VEX system...
Judging by the output from your shell you are running PROS 1.6 or older which is now out of date as of September. Try upgrading to the latest version found here and see if the problem persists.

Selecting appropriate ARM -mfpu option in gcc based on CPU features

My CPU has following CPU features
cat /proc/cpuinfo
Processor : ARMv7 Processor rev 4 (v7l)
processor : 0
BogoMIPS : 1192.96
processor : 1
BogoMIPS : 1197.05
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 4
Hardware : sun7i
Revision : 0000
And gcc sets
-march=armv7ve -mfloat-abi=hard -mfpu=vfpv3-d16 -meabi=5
options for
cat main.c
#include <stdio.h>
void main()
{
printf("Hello World!\n");
}
compiled with
gcc -march=native -mtune=native -Q -v main.c
Isn't neon-vfpv4, which seems to be supported by CPU features, is superior to vfpv3-d16, which gcc sets?
I got only vague explanation of what vfpv3-d16 is from ARM's documentation and nothing on neon-vfpv4.
I'm using gcc 4.9.1
-march and -mtune (or -mcpu as a shorthand for both) only control the CPU options for instruction selection and scheduling. As an example, with a GCC 4.8-based cross-toolchain, when I do this:
arm-linux-gnueabihf-gcc -mcpu=arm250 -v -c test.c
I get this:
...
COLLECT_GCC_OPTIONS='-mcpu=arm250' '-v' '-c' '-mfloat-abi=hard'
'-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
...
which is clearly nonsense - the ARM250 predates VFP (and even Thumb) by a long way - because for any unspecified options it's just passing through whatever was configured as the default:
...
Configured with:
... --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 ...
... --with-mode=thumb --with-float=hard
Your Cortex-A7 indeed supports full VFPv4 and NEON, so passing -mfpu=neon-vfpv4 to override the default would be the right thing to do. Unfortunately there doesn't seem to be an equivalent -mfpu=native option (at least documented - I don't have a native toolchain handy to check).

Error: selected processor does not support ARM mode `wfi'

I'm getting the following errors while trying to compile an ARM embedded C program (I'm using YAGARTO as my cross compiler). I'm trying to work out what this error means and what are the steps to correct it. From the research I've done so far, the issue it seems to be wfi, and wfe are not ASM instruction. How could I fix this?
\cc9e5oJe.s: Assembler messages:
\cc9e5oJe.s:404: Error: selected processor does not support ARM mode `wfi'
\cc9e5oJe.s:414: Error: selected processor does not support ARM mode `wfe'
\cc9e5oJe.s:477: Error: selected processor does not support ARM mode `wfi'
make: *** [STM32F10x_StdPeriph_Driver/src/stm32f10x_pwr.o] Error 1
You might miss some vital compiler options for your STM32F10x - which is a Cortex M3:
-mcpu=cortex-m3 -mthumb -mno-thumb-interwork -mfpu=vfp -msoft-float -mfix-cortex-m3-ldrd

Resources