当前位置:网站首页>Embedded system transplantation [5] - Cross compilation tool chain
Embedded system transplantation [5] - Cross compilation tool chain
2022-07-24 03:22:00 【imysy_ 22_】
Before that, we learned Linux How to transplant , But the Linux kernel 、 The files of the device tree and the root file system are directly provided to us , Later we will learn “uImage”、“exynos4412-fs4412.dtb” and “ramdisk.img” The origin of .
Compiler principle
First , Let's review the principle of compilation , If you don't understand the compilation principle , The follow-up study will be very difficult .

Machine code ( Binary system ):
CPU Language that can be recognized directly , Different machine codes represent different operation instructions . The processor can identify which machine codes are determined by the hardware design of the processor , Different processors have different machine codes , So the machine code is not portable . The original program is machine code .
assembly :
Assembly language , Is the symbolization of machine code , To put it bluntly, it is to use a symbol one One correspondingly replaces a machine code . Different processor assemblies are also different , Even assembly language is not portable .
C Language :
When compiling, we can use different compilers to translate C Compile the source code into a compilation of processors with different architectures , therefore C Languages can be transplanted .
stay Ubuntu Next , The most commonly used compiler is GCC.

Cross compilation
Cross compilation is actually a big category , In our case, cross compilation means that the compilation and operation of programs are not on the same machine

notes : Need to be in advance Ubuntu Put one on top ARM The compiler .
Cross compile toolchain
1) Official website acquisition ( Not recommended , You need to configure and compile yourself )
http://ftp.gnu.org/gnu/gcc/
2) BSP Board level development support package ( Configured by the manufacturer , recommend )
samsung、 Full ambition ...
1) Cross compiler tool
gcc/readelf/size/nm/strip/objcopy/objdump/addr2line

2) library
ARM Architecture Library

ELF File format
ELF The format is Linux On the platform One of the most widely used binary Industrial Standards
We are linux The generated executable file is ELF Format .ELF The format file contains many segments, and different segments store different information ; because ELF The format of the file should be through Linux The loading and management of the system can run , So in addition to the most basic code and data segments , It also stores a lot of other information , Such as the symbol table 、 Debugging information, etc .

ELF File related commands :
file
file + file name View file details
readelf
readelf -h + file name List elf The header information of the file
readelf -a + file name List elf All the information in the file
BIN File format

BIN The file is usually Run directly at CPU above The executable of , The file contains only CPU Instructions and data that can be directly identified and run , It does not contain information related to other systems .
Cross compilation tool chain common tools
size List the size of each segment of the target file and the overall size
size + file name
The machine code generated by the assembly instruction is in text paragraph ; The initialized variables are data paragraph ; The initialized variable exists bass paragraph .


nm List the symbol table in the target file ( Identifier )
nm + file name

notes : It can be used nm Command to see the functions in the Library
strip Discard symbols in the target file ( Slimming order )
strip + file name
The symbol table has no meaning for the execution of the program , Delete the symbol table , Reduce the memory space required .
![]()
notes : For embedded development , This order is very important
①file + The file name command can see whether the file has been executed strip command .
②arm-none-linux-gnueabi-gcc To compile executable files arm-none-linux-gnueabi-strip Slimming .
objdump Display information from the target file
eg:
objdump -d + file name Put the target file Disassembly ( Machine code -> assembly )
notes : Although you can use machine code to disassemble , But you can't reverse it with assembly C Language , because C Language and assembly instructions are not one-to-one correspondence
objcopy Copy and convert the target file
eg:
objcopy --gap-fill=0xff -O binary a.out a.bin
take Target file conversion by bin Format , Used to run programs on bare metal . The principle is to combine the code segment and data segment of the object file copy Come out and generate bin File format .
expand : Bare metal development generation .bin Format object file Makefile Code reference
led.bin:led.s
arm-linux-gnueabihf-gcc -g -c led.s -o led.o
arm-linux-gnueabihf-ld -Ttext 0X87800000 led.o -o led.elf
arm-linux-gnueabihf-objcopy -O binary -S -g led.elf led.bin
arm-linux-gnueabihf-objdump -D led.elf > led.dis
clean:
rm -rf *.o led.bin led.elf led.dis边栏推荐
- SolidWorks cannot reference references
- Data Lake: comparative analysis of open source data Lake schemes deltalake, Hudi and iceberg
- JS 数组 isAarray() typeof
- JS small game running bear and cat source code
- Exttestngireporterlistener all codes
- A simple and perfect WPF management system framework source code
- Cannot resolve symbol 'override' of idea clone‘
- MySql的DDL和DML和DQL的基本语法
- Services et configurations FTP
- FTP服務與配置
猜你喜欢

Qt自定义类使用自定义含参信号与槽

322. Change

MySQL learning - MySQL software installation and environment configuration (Windows) details!

The simple use of ADB command combined with monkey is super detailed

openEuler 资源利用率提升之道 01:概论
![[MySQL learning] install and use multiple versions of MySQL, MySQL 8 and MySQL 5.7 at the same time, compressed version](/img/08/3765b34809cc4c723608f5d2e86ed4.png)
[MySQL learning] install and use multiple versions of MySQL, MySQL 8 and MySQL 5.7 at the same time, compressed version

Genesis public chain: Tamp the foundation of Web 3.0 development

JS 数组 isAarray() typeof

Write code, and multiple characters move from both ends to converge in the middle

Ways to improve the utilization of openeuler resources 01: Introduction
随机推荐
Data Lake: introduction to Apache Hudi
Binary tree traversal
Secondary development of ArcGIS JS API -- loading national sky map
All codes of selenium
Programmers may still be programmers, and coders may only be coders
leetcode hot 100(刷题篇8)(232/88/451/offer10/offer22/344/)
The error of van swipe in the rotation chart: cannot read a properties of null (reading width)
SSM based blog system [with background management]
[C language] file operation
Insist on accompanying study
Open source embedded sig in the openeuler community. Let's talk about its multi OS hybrid deployment framework
Unity message push
Exttestngireporterlistener all codes
4.合宙Air32F103_LCD
Generate 13 bit barcode
Binary tree traversal (day 74)
MariaDB related instructions
322. Change
Error code 0x80004005
C自定义类型详解