当前位置:网站首页>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边栏推荐
- Bingbing learning notes: basic operation of vim tool
- JS array isaarray() typeof
- B. Eastern Exhibition- Codeforces Round #703 (Div. 2)
- Basic syntax of MySQL DDL and DML and DQL
- 4.合宙Air32F103_LCD
- The simple use of ADB command combined with monkey is super detailed
- Secondary development of ArcGIS JS API -- loading national sky map
- Redux Usage Summary
- 实现两个页面之前的通信(使用localStorage)
- 移动通信的新定义:R&SCMX500 将提高5G设备的IP数据吞吐量
猜你喜欢

OSPF comprehensive experimental configuration

C动态内存管理详解

1. Learn to understand web pages

What is the experience of writing concurrent tool classes (semaphore, cyclicbarrier, countdownlatch) by yourself in line 30?

轮播图van-swipe的报错:cannot read a properties of null(reading width)

Genesis public chain: Tamp the foundation of Web 3.0 development

Data Lake: introduction to Apache Hudi

A simple and perfect WPF management system framework source code

The first edition of Niuke brush question series (automorphic number, return the number of prime numbers less than N, and the first character only appears once)

Outlook client outlook.com mailbox setting method
随机推荐
21st day of written test mandatory training
Water topic: connect rainwater
Okaleido tiger NFT is about to log in to the binance NFT platform. Are you looking forward to it?
Simulink code generation: variable subsystem and its code
It's solved with a cry
Unity 消息推送
FTP服務與配置
SolidWorks CAM data cannot be recovered because a processed part has been detected.
Genesis public chain: Tamp the foundation of Web 3.0 development
idea写web项目时报错Failed to load resource: the server responded with a status of 404 (Not Found)
SolidWorks cannot reference references
Some properties of differential array operation
String.split() the most detailed source code interpretation and precautions
OSPF routing control
Keras deep learning practice (15) -- realize Yolo target detection from scratch
B. Eastern Exhibition- Codeforces Round #703 (Div. 2)
SkyWalking分布式系统应用程序性能监控工具-上
322. Change
Talk about the application of FIFO
Android Development - lambda expression of kotlin syntax