uboot extlinux.conf介绍
创始人
2024-05-30 00:57:43

uboot extlinux.conf介绍

上面一小节我们介绍了uboot的启动流程,里面最终走到了查看extlinx文件,并根据此文件来选择后续的启动镜像、设备树和内核参数。本章节详细分析一下extlinux相关的内容。首先我们看下ST官方的开发板uboot启动时使用的extlinux.conf文件长什么样:
在这里插入图片描述粗看上面的配置可以盲猜里面内容的意思:

MENU: 从配置可以看到是一张bmp的照片,应该是进入此阶段选择的splansh图片
TIMEOUT: 选择超时配置
DEFAULT: 默认启动的目标选项,应该是下面LABEL中的一种
LABEL: 一个启动项,每一个LABLE下面有三个子配置
KERNEL: 该启动项选择的DTB文件
INITRD: 该启动项支持的ramdisk
APPEND:该启动项传递的内核参数

下面我们详细分析一下ST官方是怎么生成上面这个配置文件的,涉及到的相关文件如下:
conf/machine/include/st-machine-extlinux-config-stm32mp.inc
conf/machine/stm32mp15-robot.conf
class/extlinuxconf-stm32mp.bbclass
recipes-bsp/u-boot/u-boot-stm32mp-extlinux.bb
这些文件的大致关系如图所示:
在这里插入图片描述
其中st-machine-extlinux-config-stm32mp.inc里面填充了非常多EXTLINUX相关的配置项目,然后stm32mp15-robot.conf这个machine的配置文件会引用st-machine-extlinux-config-stm32mp.inc同时部分配置项目可能会覆写,这些配置会最终控制配置文件里面的具体内容;extlinuxconf-stm32mp.bbclass里面提供了一个task 叫do_create_multiextlinux_config,里面会根据配置项目来生成extlinux的实际conf文件,u-boot-stm32mp-extlinux.bb引用了extlinuxconf-stm32mp.bbclass并且完善整个生成配置文件、编译和安装等工作,这就是大概完整的流程图。

下面的重点就是看一下do_create_multiextlinux_config里面具体是怎么根据一系列的配置来生成具体的extlinux.conf文件了。
从最后看可以知道create_multiextlinux_config task是在compile之前运行。

addtask create_multiextlinux_config before do_compile

下面是 do_create_multiextlinux_config的主体内容,部分删减


python do_create_multiextlinux_config() {targets = d.getVar('UBOOT_EXTLINUX_TARGETS')# Need to deconflict the targets with existing overridestarget_overrides = targets.split()default_overrides = d.getVar('OVERRIDES').split(':')# We're keeping all the existing overrides that aren't used as a target# an override for that target will be added back in while we're processing that targetkeep_overrides = list(filter(lambda x: x not in target_overrides, default_overrides))# Init FIT parameterfit_config = d.getVar('UBOOT_EXTLINUX_FIT')for target in targets.split():bb.note("Loop for '%s' target" % target)# Append target as OVERRIDESd.setVar('OVERRIDES', ':'.join(keep_overrides + [target]))# Initialize labelslabels = d.getVar('UBOOT_EXTLINUX_LABELS')if not labels:bb.fatal("UBOOT_EXTLINUX_LABELS not defined, nothing to do")if not labels.strip():bb.fatal("No labels, nothing to do")# Initialize extra target configsextra_extlinuxtargetconfig = d.getVar('UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG') or ""# Initialize subdir for config file locationif len(targets.split()) > 1 or len(extra_extlinuxtargetconfig.split()) > 0:bootprefix = d.getVar('UBOOT_EXTLINUX_BOOTPREFIXES') or ""subdir = bootprefix + 'extlinux'else:subdir = 'extlinux'# Initialize config filecfile = os.path.join(d.getVar('B'), subdir , 'extlinux.conf')# Create extlinux folderbb.utils.mkdirhier(os.path.dirname(cfile))# Standard extlinux file creationif fit_config == '1':bb.note("UBOOT_EXTLINUX_FIT set to '1'. Skip standard extlinux file creation")else:bb.note("Create %s/extlinux.conf file for %s labels" % (subdir, labels))create_extlinux_file(cfile, labels, d)# Manage UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIGextra_extlinuxtargetconfigflag = d.getVarFlags('UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG')# The "doc" varflag is special, we don't want to see it hereextra_extlinuxtargetconfigflag.pop('doc', None)# Handle new targets and labels appendif len(extra_extlinuxtargetconfig.split()) > 0:bb.note("Manage EXTRA target configuration:")for config in extra_extlinuxtargetconfig.split():# Init extra config vars:extra_extlinuxlabels = ""extra_cfile = ""# Specific case for 'fit' to automate configuration with device tree nameif fit_config == '1':# Override current 'labels' with 'config' from UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG# Under such configuration, UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG should contain the# list of supported device tree file (without '.dtb' suffix) to allow proper extlinux# file creation for each device tree file.bb.note(">>> Override default init to allow default extlinux file creation with %s config as extra label." % config)labels = config# Update extra config vars for this specific case:extra_extlinuxlabels = labelsextra_cfile = os.path.join(d.getVar('B'), subdir , config + '_' + 'extlinux.conf')# Configure dynamically the default menu configuration if there is no specific one configuredif d.getVar('UBOOT_EXTLINUX_DEFAULT_LABEL_%s' % config):bb.warn(">>> Specific configuration for UBOOT_EXTLINUX_DEFAULT_LABEL var detected for %s label: %s" % (config, d.getVar('UBOOT_EXTLINUX_DEFAULT_LABEL_%s' % config)))else:bb.warn(">>> Set UBOOT_EXTLINUX_DEFAULT_LABEL to %s" % config)d.setVar('UBOOT_EXTLINUX_DEFAULT_LABEL', config)# Append extra configuration if anyfor f, v in extra_extlinuxtargetconfigflag.items():if config == f:bb.note(">>> Loop for '%s' extra target config." % config)if len(v.split()) > 0:bb.note(">>> Set '%s' to extra_extlinuxlabels." % v)extra_extlinuxlabels = labels + ' ' + vextra_cfile = os.path.join(d.getVar('B'), subdir , config + '_' + 'extlinux.conf')else:bb.note(">>> No extra labels defined, no new config file to create")break# Manage new config file creationif extra_extlinuxlabels != "":socname_list =  d.getVar('STM32MP_SOC_NAME')if socname_list and len(socname_list.split()) > 0:for soc in socname_list.split():if config.find(soc) > -1:if d.getVar('UBOOT_EXTLINUX_SPLASH_%s' % soc):splash = d.getVar('UBOOT_EXTLINUX_SPLASH_%s' % soc)bb.note(">>> Specific configuration for SPLASH Screen detected with configuration: %s" % config)bb.note(">>> Set UBOOT_EXTLINUX_SPLASH to %s" % splash)d.setVar('UBOOT_EXTLINUX_SPLASH', splash)bb.note(">>> Create %s/%s_extlinux.conf file for %s labels" % (subdir, config, extra_extlinuxlabels))create_extlinux_file(extra_cfile, extra_extlinuxlabels, d)
}

上面主要就是就跟环境变量来生成,我修改的stm32mp15-robot.conf和extlinux相关的配置如下:
UBOOT_SPLASH_TTROBOT_IMAGE ?= “splash_ttrobot”
UBOOT_EXTLINUX_SPLASH_stm32mp15 = “KaTeX parse error: Expected 'EOF', got '#' at position 31: …TROBOT_IMAGE}" #̲UBOOT_EXTLINUX_…{STM32MP_DT_FILES_ROBOT}”

相关内容

热门资讯

苗族的传统节日 贵州苗族节日有... 【岜沙苗族芦笙节】岜沙,苗语叫“分送”,距从江县城7.5公里,是世界上最崇拜树木并以树为神的枪手部落...
北京的名胜古迹 北京最著名的景... 北京从元代开始,逐渐走上帝国首都的道路,先是成为大辽朝五大首都之一的南京城,随着金灭辽,金代从海陵王...
世界上最漂亮的人 世界上最漂亮... 此前在某网上,选出了全球265万颜值姣好的女性。从这些数量庞大的女性群体中,人们投票选出了心目中最美...
长白山自助游攻略 吉林长白山游... 昨天介绍了西坡的景点详细请看链接:一个人的旅行,据说能看到长白山天池全凭运气,您的运气如何?今日介绍...
猫咪吃了塑料袋怎么办 猫咪误食... 你知道吗?塑料袋放久了会长猫哦!要说猫咪对塑料袋的喜爱程度完完全全可以媲美纸箱家里只要一有塑料袋的响...