PXE导致bootargs未生效-stm32mp157 uboot

news/2025/3/3 18:23:46/文章来源:https://www.cnblogs.com/yuewusayuri/p/18748942

PXE导致bootargs未生效-stm32mp157 uboot

看过我文章的应该知道上次遇到了一个问题

stm32mp157c-100ask-512d-v1_extlinux.conf 这个extlinux的配置文件内容修改了我的bootargs导致我自己设定的内核参数并未成功生效
也就是我的自定义参数被覆盖了

经过一番查找,发现原因在STM32MP157在启动时使用PXE(预启动执行环境)从SD卡启动,而像i.MX6ULL这样的处理器却没有使用PXE。PXE的全称是Preboot Execution Environment,PXE通常用于网络引导,允许计算机通过网络下载启动镜像,而不是从本地存储设备启动。

可以看到uboot的配置里确实用到了PXE,于是我就打开了uboot/cmd/pxe_utils.c,可以看到以下代码:

 329 /*330  * Boot according to the contents of a pxe_label.331  *332  * If we can't boot for any reason, we return.  A successful boot never333  * returns.334  *335  * The kernel will be stored in the location given by the 'kernel_addr_r'336  * environment variable.337  *338  * If the label specifies an initrd file, it will be stored in the location339  * given by the 'ramdisk_addr_r' environment variable.340  *341  * If the label specifies an 'append' line, its contents will overwrite that342  * of the 'bootargs' environment variable.343  */344 static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)345 {346     char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL };347     char initrd_str[28];348     char mac_str[29] = "";349     char ip_str[68] = "";350     char *fit_addr = NULL;351     int bootm_argc = 2;352     int len = 0;353     ulong kernel_addr;354     void *buf;...

这一句解释了原因,如果conf文件中存在APPEND字段,其内容会强制覆盖bootargs

If the label specifies an 'append' line, its contents will overwrite that of the 'bootargs' environment variable.

到此已经水落石出,但是还有一个问题,它是如何解析APPEND字段的,使用grep搜索”APPEND“得到如下代码段

 597 /*598  * Keywords recognized.599  */600 static const struct token keywords[] = {601     {"menu", T_MENU},602     {"title", T_TITLE},603     {"timeout", T_TIMEOUT},604     {"default", T_DEFAULT},605     {"prompt", T_PROMPT},606     {"label", T_LABEL},607     {"kernel", T_KERNEL},608     {"linux", T_LINUX},609     {"localboot", T_LOCALBOOT},610     {"append", T_APPEND},611     {"initrd", T_INITRD},612     {"include", T_INCLUDE},613     {"devicetree", T_FDT},614     {"fdt", T_FDT},615     {"devicetreedir", T_FDTDIR},616     {"fdtdir", T_FDTDIR},617     {"ontimeout", T_ONTIMEOUT,},618     {"ipappend", T_IPAPPEND,},619     {"background", T_BACKGROUND,},620     {NULL, T_INVALID}621 };

其中关键字为token类型,但是这里是小写,实际上的conf文件为了格式工整和关键字区分使用全大写,那大小写转换的代码又在哪?
继续寻找,找到720行

 719 /*720  * Get the next token.  We have to keep track of which state we're in to know721  * if we're looking to get a string literal or a keyword.722  *723  * *p is updated to point at the first character after the current token.724  */725 static void get_token(char **p, struct token *t, enum lex_state state)726 {727     char *c = *p;728729     t->type = T_INVALID;730731     /* eat non EOL whitespace */732     while (isblank(*c))733         c++;734735     /*736      * eat comments. note that string literals can't begin with #, but737      * can contain a # after their first character.738      */739     if (*c == '#') {740         while (*c && *c != '\n')741             c++;742     }743744     if (*c == '\n') {745         t->type = T_EOL;746         c++;747     } else if (*c == '\0') {748         t->type = T_EOF;749         c++;750     } else if (state == L_SLITERAL) {751         get_string(&c, t, '\n', 0);752     } else if (state == L_KEYWORD) {753         /*754          * when we expect a keyword, we first get the next string755          * token delimited by whitespace, and then check if it756          * matches a keyword in our keyword list. if it does, it's757          * converted to a keyword token of the appropriate type, and758          * if not, it remains a string token.759          */760         get_string(&c, t, ' ', 1);761         get_keyword(t);762     }763764     *p = c;765 }

其中get_string函数原型如下

  634 /*635  * get_string retrieves a string from *p and stores it as a token in636  * *t.637  *638  * get_string used for scanning both string literals and keywords.639  *640  * Characters from *p are copied into t-val until a character equal to641  * delim is found, or a NUL byte is reached. If delim has the special value of642  * ' ', any whitespace character will be used as a delimiter.643  *644  * If lower is unequal to 0, uppercase characters will be converted to645  * lowercase in the result. This is useful to make keywords case646  * insensitive.647  *648  * The location of *p is updated to point to the first character after the end649  * of the token - the ending delimiter.650  *651  * On success, the new value of t->val is returned. Memory for t->val is652  * allocated using malloc and must be free()'d to reclaim it.  If insufficient653  * memory is available, NULL is returned.654  */655 static char *get_string(char **p, struct token *t, char delim, int lower)656 {657     char *b, *e;658     size_t len, i;659660     /*661      * b and e both start at the beginning of the input stream.662      *663      * e is incremented until we find the ending delimiter, or a NUL byte664      * is reached. Then, we take e - b to find the length of the token.665      */666     b = *p;667     e = *p;668669     while (*e) {670         if ((delim == ' ' && isspace(*e)) || delim == *e)671             break;672         e++;673     }674675     len = e - b;676677     /*678      * Allocate memory to hold the string, and copy it in, converting679      * characters to lowercase if lower is != 0.680      */681     t->val = malloc(len + 1);682     if (!t->val)683         return NULL;684685     for (i = 0; i < len; i++, b++) {686         if (lower)687             t->val[i] = tolower(*b);688         else689             t->val[i] = *b;690     }691692     t->val[len] = '\0';693694     /*695      * Update *p so the caller knows where to continue scanning.696      */697     *p = e;698699     t->type = T_STRING;700701     return t->val;702 }

可以看到当lower参数为1,也就是解析L_KEYWORD 关键字的时候(例如APPEND KERNEL)会转换为小写,若解析L_SLITERAL ,输入的字符串(如 /uImage/UIMAGE)保留原始大小写,区分大小写。

到这里,bootargs设置和解析的根源终于弄懂了

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/893065.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【硬件测试】基于FPGA的1024QAM基带通信系统开发与硬件片内测试,包含信道模块,误码统计模块,可设置SNR

1.算法仿真效果 本文是之前写的文章:《基于FPGA的1024QAM基带通信系统,包含testbench,高斯信道模块,误码率统计模块,可以设置不同SNR》的硬件测试版本。在系统在仿真版本基础上增加了ila在线数据采集模块,vio在线SNR设置模块,数据源模块。硬件ila测试结果如下:(完整代码运行…

Codes 项目管理创新之以众不同的缺陷管理工作流配置方式,专为懒人打造,弹指间完成配置

Codes 是国内首款重新定义 SaaS 模式的开源项目管理平台,支持云端认证、本地部署、全部功能开放,并且对 30 人以下团队免费.... 肯定会有人说,不就缺陷管理嘛!几个状态完事,爱咋整就咋整,没必要搞流程化,搞流程就是把简单事情复杂化。 正是基于上述看法,市面上其他的研…

通义灵码上新推理模型,快来体验数学编程双冠王 Qwen2.5-Max

近日,通义灵码上新模型选择功能,除新增 DeepSeek 满血版 V3 和 R1 外,Qwen2.5-Max 也正式上线,它使用了超过 20 万亿 token 的预训练数据及精心设计的后训练方案进行训练。 在通义灵码智能问答、AI 程序员窗口的输入框中,单击模型选择的下拉菜单即可选择所需模型。将 Qwen…

寒假结训总结

首先是这周的各种比赛结果: 个人赛8:(这场比赛感觉运气比较好 首先是前面的题做得很快,然后有一道正解需要KMP或者哈希的题被我用假做法过去了(数据太水),还有一道本来是数位DP的题目假贪心也过去了(好像大部分人都是这么做的),总的来说本来应该排第八,没做出来的那…

Git报错:remote: HTTP Basic: Access denied的解决方法

问题原因: 账号密码验证不通过,密码或者权限不对,导致 Git 操作失败。 解决方案: 输入:git config --system --unset credential.helper 再次进行 Git 操作,输入正确的用户名,密码即可。

wsl2(win11)启用图形界面

WSLg WSLg 是Windows Subsystem for Linux GUI的缩写,意图在WSL中支持直接运行Linux GUI程序,界面和Windows桌面环境无缝集成。 开启WSLg 按下 Win + R,调出命令输入窗口。输入指令 appwiz.cpl。 点击左侧的 【启动或关闭 Windows 功能】:需要勾选【适用于 Linux 的 Window…

鸿蒙安装HAP时提示“code:9568344 error: install parse profile prop check error” 问题现象

在启动调试或运行应用/服务时,安装HAP出现错误,提示“error: install parse profile prop check error”错误信息。解决措施 该问题可能是由于应用使用了应用特权,但应用的签名文件发生变化后未将新的签名指纹重新配置到设备的特权管控白名单文件install_list_capability.js…

windows11使用命令行删除文件夹

是否遇到登录账户是管理员,但是仍然提示需要管理员才能删除文件夹,使用windos11自带的命令行工具可以解决。 搜索终端,右键,使用管理员运行复制要删除文件夹的路径比如,要删除桌面的 test-del 文件夹 执行命令 rmdir 路径文件夹内容多,可能提示,按Y就删除了

前端中级面试知识点总结(个人总结自用,不具有普适性,请自行斟酌使用)

25年三月面试前端中高级开发时所作的知识点总结,以应对面试提问Mapbox 基础示例 其中style是重点,可以是url,可以是json配置对象,主要配置图层、图标、数据源等 mapboxgl.accessToken = <输入你的token>;const map = new mapboxgl.Map({container: map, // 地图容器 …

世界第一!阿里云PolarDB刷新全球数据库性能及性价比记录

2月26日,在2025阿里云PolarDB开发者大会上,阿里云宣布PolarDB登顶全球数据库性能及性价比排行榜。根据国际数据库事务处理性能委员会(TPC,Transaction Processing Performance Council)官网披露,阿里云PolarDB云原生数据库以超越原记录2.5倍的性能一举登顶TPC-C基准测试排…

vue学习--创建项目

nvm:nodejs版本管理器 彻底卸载nodejs, .nmprc npm https://blog.csdn.net/weixin_38383877/article/details/143077797 配置好vue,cmd 出现页面 创建

记录---纯前端也能实现 OCR?

🧑‍💻 写在开头 点赞 + 收藏 === 学会🤣🤣🤣 前言前端时间有一个 OCR 的需求,原本考虑调用现成的 OCR 接口,但由于只是做一个我个人使用的工具,花钱购买 OCR 接口显得有些奢侈。于是就想着找找是否有现成的库可以自己部署或直接使用,结果发现了一个可以在纯前端…