I'm new to arm development. There was the following problem. There is a board on the arm920t processor (AT91RM9200), here is such a Linux spinning
root@test-device:/home/andy # uname -a Linux test-device 2.6.21.201509.01 #13 Wed Jun 22 11:06:51 EEST 2016 armv4tl unknown
On a virtual machine, I have Ubutu 18.04 as a cross-compilation machine. There are packages installed for cross-compiling from the Ubuntu 1 repository. Arm-linux-gnueabi 2. arm-none-eabi
I collect the simplest hello world
#include <stdio.h> int main() { printf("Hello world\n"); return 0; }
Build and compile perform each of the packages.
supersonic@ubuntu-vBox:~$ arm-linux-gnueabi-gcc -o hello_arm hello.c -static supersonic@ubuntu-vBox:~$ arm-none-eabi-gcc -o hello_arm_none-eabi hello.c --specs=nosys.specs
In both cases, a binary executable file is created. The readelf and file utilities say the following about them:
1. (собран пакетом arm-linux-gnueabi) supersonic@ubuntu-vBox:~$ readelf -h hello_arm 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: 0x101a0 Start of program headers: 52 (bytes into file) Start of section headers: 501788 (bytes into file) Flags: 0x5000200, Version5 EABI, soft-float ABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 7 Size of section headers: 40 (bytes) Number of section headers: 30 Section header string table index: 29 supersonic@ubuntu-vBox:~$ supersonic@ubuntu-vBox:~$ file hello_arm hello_arm: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=15d06e43de8c8d13d7e0110e311532a9187ca9e5, not stripped 2. (собран пакетом arm-none-eabi) supersonic@ubuntu-vBox:~$ readelf -h hello_arm_none-eabi 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: 0x8148 Start of program headers: 52 (bytes into file) Start of section headers: 186056 (bytes into file) Flags: 0x5000200, Version5 EABI, soft-float ABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 3 Size of section headers: 40 (bytes) Number of section headers: 27 Section header string table index: 24 supersonic@ubuntu-vBox:~$ file hello_arm_none-eabi hello_arm_none-eabi: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
I upload these files via sftp to the target machine, I give them the right to execute
root@test-device:/home/andy # chmod +x hello_arm root@test-device:/home/andy # chmod +x hello_arm_none-eabi
When I try to run both binaries on the target platform, I get the following results
1. (собран пакетом arm-linux-gnueabi) root@test-device:/home/andy # ./hello_arm Illegal instruction 2. (собран пакетом arm-none-eabi) root@test-device:/home/andy # ./hello_arm_none-eabi Segmentation fault
On the target machine, there are binaries that run and work there, but the person who collected them did this 5 years ago and since then in 1x no one supported anything there and in 2x there was no connection or any other contact with it.
This is what the readelf and file utilities say about the binary that runs correctly there
supersonic@ubuntu-vBox:~$ readelf -h /media/share_rw/MTXReader ELF Header: Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: ARM ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0xab1c Start of program headers: 52 (bytes into file) Start of section headers: 681968 (bytes into file) Flags: 0x2, GNU EABI, <unknown> 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 supersonic@ubuntu-vBox:~$ file /media/share_rw/MTXReader /media/share_rw/MTXReader: ELF 32-bit LSB executable, ARM, version 1 (ARM), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.0.10, with debug_info, not stripped
Clearly visible differences between them in the headers and their characteristics, but no matter how I tried to play with the options, the same result comes out
I tried to collect with the transfer of options in both the assembly package info about the processor and its architecture
1. supersonic@ubuntu-vBox:~$ arm-linux-gnueabi-gcc -o hello_arm hello.c -static -mcpu=arm920t -march=armv4t 2. supersonic@ubuntu-vBox:~$ arm-none-eabi-gcc -o hello_arm_none-eabi hello.c --specs=nosys.specs -mcpu=arm920t -march=armv4t
Exactly the same results.
I would be happy for any help in this matter, I am just starting to master this world of embedded systems. With respect!