Basic knowledge of embedded Linux

Source: Internet
Author: User

First, build the embedded development environment
1, compile bootloader and write to the board---uboot, you can customize bootloader and logo
2. Compile the file system and burn it--embed app
3. Compiling Linux kernel----custom drivers and logo
4. Compiling the app
5. Compile the file system backup---embedded app
6. Install the cross-compilation tool
7. Installation and Debugging Tools

Ii. basic knowledge of embedded programming

General C + + files to become executable files need to be preprocessed, compiled, compiled, and connected 4 steps
1) pretreatment
The pre-processing command begins with #, such as include command # #, macro definition # define, conditional compilation # If #ifdef, which is intended to insert all include files into the source file, expand the macro definition,
Conditional compilation of the selected code used, and finally input all code into the. I file for processing, preprocessing needs to use the Arm-linux-cpp tool

2) compiling
Translate all C + + code (the. I file above) into assembly code, using the tool as CCL

3) Assembly
The previous assembly code is translated into a certain format of the machine code, Linux is generally the elf target file, using the tool for Arm-linux-as

4) connection
Connection is the obj file generated above and the system library of the obj file, the library file connection, the final generation on the platform executable file, using the tool as Arm-linux-ld

ARM-LINUX-GCC Options
1)-C
Preprocess, compile, and assemble source files, do not connect, compiler generates obj files, gcc passes. o Replace. C. I. S etc.
2)-S
After compiling, it stops, does not assemble, and GCC uses. s to replace. C. I etc.
3)-E
Stop after preprocessing, do not compile, preprocess code to standard output
4)-O file
Specifying output file files
5)-V
Show gcc version, compile details
6)-wall
Turn on warning options
7)-G
Turn on debugging options and use GDB to debug
8)-llibrary
Connect a library file named libraries, the real name is LIBLIBRARY.A
9)-static
Static compilation
)-shared
Generating a shared obj file
One)-idir
Specify dir to search the directory for the header file
)-ldir.
Specify DIR to search directories for library files

ARM-LINUX-LD Options
1)-T
Specify the starting address of the code snippet (-ttext), data Segment (-tdate), BSS segment (-TBSS)
Using connection scripts (-txxx.lds)

Cases:
SECTIONS {
. = 0x30000000;
. Text: {* (. text)}
. Rodata ALIGN (4): {* (. rodate)}
. Data ALIGN (4): {* (. data)}
. BSS ALIGN (4): {* (. BSS) * (COMMON)}
}

The second line indicates that the current run address is 0x30000000, and the third line defines the. Text segment, with the contents of * (. text), which represents the code snippet for all input files, starting with a run address of 0x30000000
Line four defines the. Rodata segment with the code close to the. Text,align (4) represents the start Address 4 byte alignment if the. Text is 0x30000000-0x300003f1, the. Rodata address is 0X300003F4

arm-linux-objcopy option, this command is used to copy the contents of a target file into another file for format conversion
Example: Converting an elf format to a binary file
Arm-linux-objcopy-o binary-s Elf_file Bin_file

Arm-linux-objdump option, used to view disassembly code
Elf Turn Back compilation
arm-linux-objdump-d elf_file > Dis_file
Binary Turn Disassembly
arm-linux-objdump-d-B binary-m arm bin_file > Dis_file

Third, Makefile compile file------later supplement

Makefile Introduction
1) Format:
Goal: Reliance
<tab> command
Cases:
Hello:hello.c
Gcc-o Hello hello.c
Clean
Rm-f Hello

2) Assignment method
Delay variable: expands when used
var = value
var = value (the variable is not defined to be valid, that is, the first occurrence of the time delay variable is defined)
Immediate variable: Define the value to determine
var: = value
for var + = value The right variable if used previously: = is defined as an immediate variable, it is an immediate variable, otherwise it is a delay variable
3) Makefile Common functions
A function call begins with "$", enclosing the function name and arguments in parentheses or curly braces. It feels like a variable, doesn't it? Arguments in a function can use variables,
For the unification of style, the parentheses of functions and variables

Basic knowledge of embedded Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.