当前位置:网站首页>Hongmeng porting i.mx6ull (VI) kconfig_ GCC_ Mkefile
Hongmeng porting i.mx6ull (VI) kconfig_ GCC_ Mkefile
2022-06-09 14:50:00 【da..】
List of articles
- 1.Kconfig Introduce
- 2. preparation
- 3.gcc Detailed explanation of compilation process
- 4.makefile
1.Kconfig Introduce

Reference documents :
Any one Linux Kernel Documentation\kbuild\kconfig-language.rst
https://www.rt-thread.org/document/site/programming-manual/kconfig/kconfig/
For all kinds of kernels , Just support
menuconfigConfiguration interface , Is to useKconfig.
In the configuration interface , You can choose 、 set an option , These settings will be saved in.configIn the document .MakefileWill contain.config, Determine which files to compile according to the values inside 、 How to compile files .
1.1 Configuration interface example

problem :
- In this interface , Where do the configuration items come from
- In this interface , How are these configuration items organized
- In this interface , Our choice 、 Set up , Where to save the results
1.2 Save the configuration results
1.2.1 Example
The operation results in the configuration interface are saved in
.configIn file , Examples are as follows :
# LOSCFG_COMPILER_HIMIX_32 is not set
LOSCFG_COMPILER_CLANG_LLVM=y
#
# Platform
#
LOSCFG_PLATFORM="stm32mp157"
# LOSCFG_PLATFORM_HI3516DV300 is not set
# LOSCFG_PLATFORM_HI3518EV300 is not set
LOSCFG_PLATFORM_STM32MP157=y
# LOSCFG_PLATFORM_IMX6ULL is not set
LOSCFG_PLATFORM_BSP_GIC_V2=y
LOSCFG_ARCH_ARM=y
LOSCFG_ARCH_ARM_AARCH32=y
LOSCFG_ARCH_ARM_V7A=y
LOSCFG_ARCH_ARM_VER="armv7-a"
LOSCFG_ARCH_FPU_VFP_V4=y
LOSCFG_ARCH_FPU_VFP_D32=y
LOSCFG_ARCH_FPU_VFP_NEON=y
LOSCFG_ARCH_FPU="neon-vfpv4"
LOSCFG_ARCH_CORTEX_A7=y
LOSCFG_ARCH_CPU="cortex-a7"
MakefileWill contain.configfile , It will be based on variables such asLOSCFG_PLATFORM_STM32MP157Select a board related file .
1.2.2 Prefix of configuration item
stay
KconfigIn file , Suppose the name of the configuration item isXXX, stay.configIn file :
- By default , Its corresponding variable name is
CONFIG_XXX- If the environment variable is set
CONFIG_=ABC, Then the corresponding variable name isABC_XXX- stay Liteos-a Medium Makefile in
export CONFIG_=LOSCFG_, So the corresponding variable name isLOSCFG_XXX

1.3 Describe a single configuration item config
1.3.1 Example
stay
make menuconfigInterface , You can see this configuration item :

In the configuration interface , Use the direction arrow to swim to
Enable FAT Cache Sync Threadafter , Sure :
Input Y, Select configuration item , stay .config In the corresponding
LOSCFG_FS_FAT_CACHE_SYNC_THREAD=yInput N, Do not select configuration item , stay .config In the corresponding
# LOSCFG_FS_FAT_CACHE_SYNC_THREAD is not set
How to implement the configuration items in the figure above ? ( Here is help . We can find through this
kconfigfile )

grep "FS_FAT_CACHE_SYNC_THREAD" * -nr | grep Kconfig

stay
KconfigIn file , It corresponds to the following code :

1.3.2 grammar

Explain the following :
- config Express
config option, This is aKconfigBasicentry; otherentryIs to manageconfigOf .configRepresents the beginning of a configuration option , Next to itFS_FAT_CACHE_SYNC_THREADIs the name of the configuration option .
configThe following lines define the properties of this configuration option .
The property can be a property of the configuration option : type 、 Input prompt 、 Dependency relationship 、 The default value is 、 Help information .
boolIndicates the type of configuration option , EveryconfigMenu items should have type definitions , The variables are 5 Types
boolBoolean typetristateTristate typestringcharacter stringhexHexadecimalintinteger"
Enable FAT Cache Sync Thread": Prompt information
depends on: Show dependency , OnlyFS_FAT_CACHETo be selected , You can chooseFS_FAT_CACHE_SYNC_THREAD
select XXX: Indicates a reverse dependency , That is, after the current configuration option is selected ,XXXThe option will be selected .
defaultIndicates the default value of configuration options ,boolThe default value of type can bey/n.
helpHelp information , staymake menuconfigInterface input H Key time , You will be prompted with help information .
1.4 Implementation menu menu/endmenu
1.4.1 Example



stay
Kconfigin , The code is as follows :
menu "Lib"
config LIB_LIBC
bool "Enable Libc"
default y
help
Answer Y to enable libc for full code.
config LIB_ZLIB
bool "Enable Zlib"
default y
depends on LIB_LIBC
help
Answer Y to enable LiteOS support compress file library.
endmenu
1.4.2 grammar
Explain the following :
menu "xxx"Represents a menu , Menu name is "xxx"
menuandendmenuBetweenentryAll are "xxx" Menu optionsIn the example above, the submenu has 2 An option :“
Enable Libc”、“Enable Zlib”Because the second menu item depends on the first menu item , So the second menu item is indented one space
1.5 Achieve radio choice/endchoice
1.5.1 Example

In the above interface , about
LiteOS_Compiler_Type, Yes 2 A choice :arm-linux-ohoseabi、clang-llvm.
stayKconfigHow to describe in the document ? as follows :
menu "Compiler"
choice
prompt "LiteOS_Compiler_Type"
default COMPILER_CLANG_LLVM
help
Enable arm-himix100 or aarch64-himix100 or compiler.
config COMPILER_HIMIX_32
bool "arm-linux-ohoseabi"
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_IMX6ULL || PLATFORM_STM32MP157
config COMPILER_CLANG_LLVM
bool "clang-llvm"
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_IMX6ULL || PLATFORM_STM32MP157
endchoice
endmenu
1.5.2 grammar
Explain the following :
choiceExpress " choice "choiceandendchoiceBetweenentryAre optional items- Between them , Only one can be set to "y": Means to program into the kernel
- Between them , Multiple can be set to "
m": Means to compile as a module- For example, a hardware has multiple drivers
- Only one driver can be programmed into the kernel at a time
- But multiple drivers can be compiled into modules separately
1.6 menuconfig
menuconfig XXXandconfig XXXsimilar , The only difference is that this option can be set excepty/m/nOutside , You can also implement menu effects ( Enter the item by pressing enter ).
1.6.1 Example

For the above interface ,
KconfigThe code in the file is as follows :
menuconfig OF
bool "Device Tree and Open Firmware support"
help
This option enables the device tree infrastructure.
It is automatically selected by platforms that need it or can
be enabled manually for unittests, overlays or
compile-coverage.
if OF
config OF_UNITTEST
bool "Device Tree runtime unit tests"
depends on OF_IRQ
select OF_EARLY_FLATTREE
select OF_RESOLVE
help
This option builds in test cases for the device tree infrastructure
that are executed once at boot time, and the results dumped to the
console.
If unsure, say N here, but this option is safe to enable.
config OF_OVERLAY
bool "Device Tree overlays"
select OF_DYNAMIC
select OF_RESOLVE
help
Overlays are a method to dynamically modify part of the kernel's
device tree with dynamically loaded data.
While this option is selected automatically when needed, you can
enable it manually to improve device tree unit test coverage.
endif # OF
1.6.2 grammar
menuconfigCommon formats are 2 Kind of :
menuconfig M
if M
config C1
config C2
endif
or :
menuconfig M
config C1
depends on M
config C2
depends on M
The first 1 term
menuconfig MFollowconfig MThe grammar is the same , The difference ismenuocnfig MIt can be followed by several dependencies M Ofconfig C1、config C2And other sub configuration items .
1.7 if/endif
1.7.1 grammar
Above
menuconfiginif/endifUse , Its syntax is as follows :
"if" <expr>
<if block>
"endif"
1.7.2 Example
Examples are as follows , Only defined
OFterm ,OF_UNITTESTandOF_OVERLAYWill be displayed :
if OF
config OF_UNITTEST
bool "Device Tree runtime unit tests"
depends on OF_IRQ
select OF_EARLY_FLATTREE
select OF_RESOLVE
help
This option builds in test cases for the device tree infrastructure
that are executed once at boot time, and the results dumped to the
console.
If unsure, say N here, but this option is safe to enable.
config OF_OVERLAY
bool "Device Tree overlays"
select OF_DYNAMIC
select OF_RESOLVE
help
Overlays are a method to dynamically modify part of the kernel's
device tree with dynamically loaded data.
While this option is selected automatically when needed, you can
enable it manually to improve device tree unit test coverage.
endif # OF
1.8 source
sourceStatement is used to read from another fileKconfigfile , Such as :
source "../../kernel/liteos_a/platform/Kconfig"
1.9 comment
commentThe statement appears in the first line of the interface , Used to define some prompt messages , Such as :
config ARCH_ARM
bool
source "arch/arm/Kconfig"
comment "Extra Configurations"
config ARCH_FPU_DISABLE
bool "Disable Floating Pointer Unit"
default n
help
This option will bypass floating procedure in system.
The interface is as follows :

2. preparation
Install the software in
GITWarehouse :
doc_and_source_for_openharmony\ Tools \
codeblocks-20.03mingw-setup.exe
make-3.81.exe
2.1. arm-linux-gcc and gcc It's similar
- arm-linux-gcc
- to ARM Chip compiler
- gcc
- stay
x86compiler- The usage is basically the same
- For the convenience of demonstration , We use gcc
- For convenience in windows Next presentation , We use
Code::Blocks- Its installation program comes with
gcc
2.2. Code::Blocks
It is based on GCC Of
windows IDE, Can be used for developmentC/C++/Fortran.
Official website address :http://www.codeblocks.org/In what we offer GIT There are also... In the warehouse :
git clone https://e.coding.net/weidongshan/openharmony/doc_and_source_for_openharmony.git
download GIT after , stayToolsUnder the table of contents .
2.2.1 install
Follow the instructions to install .
2.2.2 Set up windows environment variable
stay Path Add... To the environment variable :
C:\Program Files\CodeBlocks\MinGW\bin
2.2.3 Command line example
start-up
Git Bash, compilerhello.c:
#include <stdio.h>
int main(void)
{
printf("hello, world!\n");
return 0;
}
compile 、 Run the command as follows :
gcc -o hello hello.c
./hello.exe
2.3. Make
install
make-3.81.exeafter , stay Path Add... To the environment variable :C:\Program Files (x86)\GnuWin32\bin
3.gcc Detailed explanation of compilation process
The supporting source code is in GIT Of all the boards in the warehouse
source\02_ Source code written when recording video \01_gcc_optionsin .
3.1. Program compilation 4 step

We use it a lot “ compile ” Generally referring to the above 4 One of the first steps , Sometimes it even includes these four steps .
3.2. gcc How to use
gcc [ Options ] file name
3.2.1 gcc Examples of use
gcc hello.c // Output a file called a.out Executable program of , Then you can execute ./a.out
gcc -o hello hello.c // The output name is hello Executable program of , Then you can execute ./hello
gcc -o hello hello.c -static // Static links
gcc -c -o hello.o hello.c // To compile the first ( Don't link )
gcc -o hello hello.o // Link again
3.2.2 gcc Common options
3.2.2.1 Manually control the compilation process
| Options | function |
|---|---|
| -v | see gcc The version of the compiler , Show gcc Detailed process of execution |
| -o | Specify the output file name as file, This name cannot have the same name as the source file name |
| -E | Just preprocessing , I can't compile 、 assembly 、 link t |
| -S | Compile only , I can't compile 、 link |
| -c | Compile and assemble , Will not link |
One c/c++ The document has to be preprocessed 、 compile 、 Assembly and linking can become executable files .
(1) PreprocessingC/C++In the source file , With “#” The first command is called a preprocessing command , If it contains a command “#include”、 Macro definition command “#define”、 Conditional compilation command “#if”、“#ifdef” etc. . Preprocessing is about to include (include) Insert the file into the original file 、 Expand the macro definition 、 Select the code to use according to the conditional compilation command , Finally, output these things to a “.i” Waiting for further processing in the file .
(2) compile
Compiling is to putC/C++Code ( Such as the above “.i” file )“ translate ” Into assembly code .
(3) assembly
Assembly is to translate the assembly code output in the second step into machine code in a certain format , stayLinuxThe general performance of the system isELFTarget file (OBJfile ).“ Disassembly ” It refers to converting machine code into assembly code , This is often used in debugging programs .
(4) link
The link will be generated in the previous stepOBJOf file and system librariesOBJfile 、 Linking library files , Finally, an executable file that can run on a specific platform is generated .
hello.c( Preprocessing )->hello.i( compile )->hello.s( assembly )->hello.o( link )->helloThe detailed commands for each step are as follows :
gcc -E -o hello.i hello.c
gcc -S -o hello.s hello.i
gcc -c -o hello.o hello.s
gcc -o hello hello.o
The above series of commands are troublesome ,
gccWould be right .c The file is preprocessed by default , Use -c Let's go back to compilation 、 assembly , To get .o file , then .o File links , Get the executable application . Simplified as follows :
gcc -c -o hello.o hello.c// The first three steps
gcc -o hello hello.o
3.2.2.2 Use the suffix to determine the compilation process
Reference resources 《 The embedded Linux Application development complete manual 》:
- summary * The input file's suffix and options are jointly determined gcc What are the operations to be performed
- During the compilation process , The last step is to link
- Unless you use -E、-S、-c Options
- Or a compilation error prevents the complete compilation process
3.2.2.3 Specify the header directory
Where is the header file ?
- System catalog * Where is the system directory ? Somewhere in the tool chain include Catalog
- How to determine ?
```
echo 'main(){}'| gcc -E -v - // It lists the header file directory 、 The library catalog (LIBRARY_PATH)
```
- The system may not be used
includeCatalogue ? Sure , Specify parameters at compile time-nostdinc- You can specify your own header file directory
-I < Header Directory >
3.2.2.4 Specify the library file
Where are the library files ?
- System catalog * Where is the system directory ? Somewhere in the tool chain lib Catalog
- How to determine ?
```
echo 'main(){}'| gcc -E -v - // It lists the header file directory 、 The library catalog (LIBRARY_PATH)
```
- The system may not be used
libCatalogue ? Sure , Specify parameters at compile time-nostdlib- You can specify your own library file directory
-L < Library file directory >
- Specify the library file
-l <abc> // link libabc.so or lib.a
3.3 Development board program compilation example
Last link , Use
arm-linux-ldInstead of usingarm-linux-gcc
- The former can completely specify the connected file itself
- The latter will link some default startup files
3.4 Reference books
《 The embedded Linux Application development complete manual 》 Medium 《3.1 Description of cross compilation tool options 》
4.makefile
边栏推荐
- Rest API中PUT 与 PATCH 使用区别及幂等性分析
- Enter a line of characters (80 at most), start from the location, intercept number characters and output them.
- The panorama of yuancosmos industrial investment, fast step into the new era of yuancosmos!
- 临时全局变量和IRISTEMP数据库
- 知名网络安全硬件平台厂商铵泰克加入龙蜥社区
- 从刚入测试界到薪资翻倍:聊聊我的测试进阶历程,值得借鉴
- mysql不能update查询结果集的解决办法
- Su Tao: application of counter sample technology in the field of Internet Security
- Google installs the impression note clipping plug-in
- 鸿蒙移植i.mx6ull(十二) 根文件系统
猜你喜欢

Graphpad prism 9 for Mac

MySQL数据库的日志管理

Why do SQL statements use indexes but still slow queries?

《数字经济全景白皮书》银行财富管理篇 重磅发布

Best practices for WSL installation

4427 node sum in tree (greedy)

AE脚本-网格参考线黄金分割线生成工具 GuidesUp! 2.2激活版

Vscade markdown add, paste and import pictures

Occupying the smart home market, Schneider Electric only relies on a wiser system?

Interviewed a software tester for 7 years: 7 years for success and 7 years for failure
随机推荐
CVPR 2022 | 逆渲染中的⾼效间接光照建模
Pourquoi l'instruction SQL utilise - t - elle un index, mais la requête est - elle lente?
Is it safe to open an account in an external market or domestic futures?
Avenue to simplicity | how to configure self attention for vit is the most reasonable?
Award winning research
Rest API中PUT 与 PATCH 使用区别及幂等性分析
机器学习基础备忘录
CICC digital intelligence China II: five questions and five answers to database business market
智慧农业小麦室外病虫害防治规范,北斗农业
执行测试
IDEA复制方法的全路径
代码实现WordPress编写文章可以调整字体字号
鸿蒙移植i.mx6ull(十一) 存储设备驱动程序(基于IMX6ULL)
I haven't published a thesis for 5 years, and I want to give up my doctoral degree? Ten thousand words self narration of the doctoral director of the University of science and technology of China: he
知名网络安全硬件平台厂商铵泰克加入龙蜥社区
Docker-Compose实现Mysql主从
Cloud native essay kubernetes workload
Nerf neural radiation field eccv2020
Uniswapv2 peripheral contract learning (VIII) -- exampleswaptoprice sol
八股文天花板!(PDF高清下载)