慢慢欣赏linux make uImage流程

本文深入探讨了Linux内核的编译流程,包括makefile的解析,auto.conf与autoconf.h的生成过程,以及vmlinux.o的构建细节。通过对内核编译系统的探秘,读者将了解到从配置到编译的各个环节。
# The all: target is the default when no target is given on the
# command line.
# This allow a user to issue only 'make' to build a kernel including modules
# Defaults vmlinux but it is usually overridden in the arch makefile
all: vmlinux

include $(srctree)/arch/$(SRCARCH)/Makefile
=>include arch/x86/Makefile
里面有重新定义的目标,会产生覆盖
# Default kernel to build
all: bzImage

# KBUILD_IMAGE specify target image being built
KBUILD_IMAGE := $(boot)/bzImage

bzImage: vmlinux
	$(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE)
	$(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot
	$(Q)ln -fsn ../../x86/boot/bzImage $(objtree)/arch/$(UTS_MACHINE)/boot/$@
	
	依赖1
	# vmlinux image - including updated kernel symbols
	vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o) FORCE
		$(call vmlinux-modpost)
		$(call if_changed_rule,vmlinux__)

		依赖1.4 
		modpost-init := $(filter-out init/built-in.o, $(vmlinux-init))
		vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE
			$(call if_changed_rule,vmlinux-modpost)
		
		依赖1.1
		vmlinux-lds  := arch/$(SRCARCH)/kernel/vmlinux.lds
		
			依赖1.x.1,  $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) 都依赖 $(vmlinux-dirs)
			# The actual objects are generated when descending, 
			# make sure no implicit rule kicks in
			$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
				
			vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
				 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
				 $(net-y) $(net-m) $(libs-y) $(libs-m)))
				 
			$(vmlinux-dirs): prepare scripts
				$(Q)$(MAKE) $(build)=$@

prepare的东西不少

prepare 的依赖 prepare0 => prepare1 => prepare2 => prepare3
include/config/kernel.release: include/config/auto.conf FORCE
	$(Q)rm -f $@
	$(Q)echo $(kernelrelease) > $@
	
	依赖2.1
	include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
		$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
		
	注:$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
	的作用如下:防止 include/config/%.conf 找不到定义
		依赖2.1.1
		silentoldconfig: $(obj)/conf
			$(Q)mkdir -p include/generated
			$< -s $(Kconfig)
			# $(obj)/conf -s 
			# KCONFIG_CONFIG 指代的就是配置文件 .config
			#生成auto.conf、auto.conf.cmd以及autoconf.h
			main //conf.c
			{
				conf_write_autoconf();
				=>int conf_write_autoconf(void)
				{
					file_write_dep("include/config/auto.conf.cmd");
					name = getenv("KCONFIG_AUTOHEADER");
					if (!name)
						name = "include/generated/autoconf.h"; // autoconf.h
					if (rename(".tmpconfig.h", name))
						return 1;
					name = getenv("KCONFIG_TRISTATE");
					if (!name)
						name = "include/config/tristate.conf";
					if (rename(".tmpconfig_tristate", name))
						return 1;
					name = conf_get_autoconfig_name();
					=>char *conf_get_autoconfig_name(void)
					{
						char *name = getenv("KCONFIG_AUTOCONFIG");

						return name ? name : "include/config/auto.conf"; // auto.conf
					}
					/*
					 * This must be the last step, kbuild has a dependency on auto.conf
					 * and this marks the successful completion of the previous steps.
					 */
					if (rename(".tmpconfig", name))
						return 1;
				}
			}

对linux内核makefile的一点点研究
http://blog.chinaunix.net/uid-20564848-id-225177.html

9.关于内核编译及配置总结:①auto.conf与②autoconf.h的‘自动’生成 
http://blog.sina.com.cn/s/blog_87c063060101klau.html

配置Linux Kernel时make menuconfig执行流程分析
https://www.cnblogs.com/LoTGu/p/5968042.html

Linux移植之make uImage编译过程分析
https://www.cnblogs.com/andyfly/p/9396423.html

Linux移植之auto.conf、autoconf.h、Mach-types.h的生成过程简析
https://www.cnblogs.com/andyfly/p/9399926.html

$(srctree) is not clean, please run 'make mrproper'
https://www.cnblogs.com/senior-engineer/p/4932559.html

makefile中的patsubst
https://blog.csdn.net/srw11/article/details/7516712

Makefile中patsubst函数使用方法
https://blog.csdn.net/yanlaifan/article/details/71402787

linux源码Makefile的详细分析
https://www.cnblogs.com/amanlikethis/p/3675486.html

arm-linux内核编译过程小结
https://www.cnblogs.com/liang123/p/6325170.html

linux内核vmlinux的编译过程之 --- vmlinux.o详解(八)
https://blog.csdn.net/m0_47799526/article/details/106202822?utm_source=blogxgwz7

3.2.5 setup.bin的构建过程
http://book.2cto.com/201309/33427.html

《Linux内核Makefile分析》之 if_changed_rule/cc_o_c/any-prereq/arg-check
http://blog.sina.com.cn/s/blog_87c063060101l25q.html

内核编译系统探秘之一 if_changed_rule
http://blog.sina.com.cn/s/blog_61c81f910100phiq.html


linux 2.6内核makefile分析
https://blog.51cto.com/19880512/453691

Linux内核makefile解析
https://blog.51cto.com/19880512/303544

内容概要:本文提出了一种面向通信优化的微电网分布式二次电压频率调控与功率均分方法,结合Simulink仿真实现,旨在解决微电网中电压频率恢复与有功/无功功率精确分配的关键问题。通过引入混合动态事件触发机制,在确保控制精度的同时显著降低通信频率,有效缓解通信资源紧张问题,提升系统实时性与运行效率。该方法采用完全分布式的协同控制架构,摆脱对中央控制器的依赖,避免单点故障风险,增强系统的鲁棒性与可扩展性。仿真模型构建了包含多个分布式发电单元(DG)的微电网系统,详细模拟其动态响应过程,验证了所提策略在不同负载扰动、通信延迟及网络拓扑变化等复杂工况下的有效性,成功实现了电压频率的快速无静差恢复与功率的精确均分,兼顾了控制性能与通信成本的双重优化。; 适合人群:具备电力系统、自动控制理论或新能源并网技术等相关专业背景,熟悉Matlab/Simulink仿真环境,从事微电网控制、分布式能源系统、智能配电网或电力电子控制等领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①作为微电网二次控制算法的教学案例与科研仿真平台;②为分布式能源系统的电压频率稳定控制与功率均衡分配提供先进的算法设计与性能验证方案;③支持对事件触发控制、通信优化策略在实际电力系统中的应用效果进行评估、改进与推广。; 阅读建议:建议结合提供的Simulink模型与配套代码进行动手实践,重点剖析控制器的设计逻辑、事件触发条件的设定原则以及通信机制的实现方式,通过主动修改负载参数、调整通信拓扑结构等方式,深入探究系统在不同运行条件下的动态特性与鲁棒性表现。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值