uboot传入的linux启动参数解析。命令行

linux内核链接脚本vmlinux.lds分析续篇之---* (.proc.info.init)、* (.arch.info.init)、*(.taglist.init)段的分析(十二) 为什么这里又单独写一篇关于内核连接脚本中各种段的分析。因为在内核启动中有如下两个比较重要的步骤: 校验处理器ID,检验内核是否支持该处理器;若不支持,则停止启动内核。 - - -> *(.proc.info.init)段 校验机器码,检验内核是否支持该机器;若不支持,则停止启动内核 - - -> *(.arch.info.init)段 一. * (.proc.info.init)段 在vmlinux的构建过程中,有提到过一个依赖 vmlinux-main,这里我们重点 阅读详情

Bootloader与内核的交互
Bootloader与内核的交互是单向的,Bootloader将各类参数传给内核。由于它们不能同时运行,传递办法只有一个:Bootloader将参数放在某个约定的地方之后,再启动内核,内核启动后从这个地方获得参数。

除了约定好参数存放的地址外,还要规定参数的结构。Linux 2.4.x 以后的内核都期望以标记列表(tagged list)的形式来传递启动参数。标记,就是一种数据结构;标记列表,就是挨着存放的多个标记。标记列表以标记ATAG_CORE 开始,以标记ATAG_NONE 结束。标记的数据结构为tag,它由一个tag_header结构和一个联合(union)组成。tag_header结构表示标记的类型及长度,比如是 表示内存还是表示命令行参数等。对于不同类型的标记使用不同的联合(union),比如表示内存时使用tag_mem32,表示命令行时使用 tag_cmdline。数据结构tag和tag_header定义在Linux内核源码的include/asm/setup.h头文件中:

struct tag_header {

u32 size;

u32 tag;

};

<br>struct tag {

struct tag_header hdr;

union {

struct tag_corecore;

struct tag_mem32mem;

struct tag_videotextvideotext;

struct tag_ramdiskramdisk;

struct tag_initrdinitrd;

struct tag_serialnrserialnr;

struct tag_revisionrevision;

struct tag_videolfbvideolfb;

struct tag_cmdlinecmdline;

<br>/*

 * Acorn specific

 */

struct tag_acornacorn;

<br>/*

 * DC21285 specific

 */

struct tag_memclkmemclk;

} u;

};

下面以设置内存标记、命令行标记为例说明参数的传递:

(1)设置标记 ATAG_CORE。

标记列表以标记 ATAG_CORE开始,假设Bootloader与内核约定的参数存放地址为0x30000100,则可以以如下代码设置标记 ATAG_CORE:

params = (struct tag *) 0x30000100;

<br>params->hdr.tag = ATAG_CORE;

params->hdr.size = tag_size (tag_core);

<br>params->u.core.flags = 0;

params->u.core.pagesize = 0;

params->u.core.rootdev = 0;

<br>params = tag_next (params); 其中,tag_next定义如下,它指向当前标记的末尾:

#define tag_next(t)((struct tag *)((u32 *)(t) + (t)->hdr.size))


(2)设置内存标记。

假设开发板使用的内存起始地址为0x30000000,大小为0x4000000,则内存标记可以如下设置:

params->hdr.tag = ATAG_MEM;

params->hdr.size = tag_size (tag_mem32);


params->u.mem.start = 0x30000000;

params->u.mem.size = 0x4000000;


params = tag_next (params);


(3)设置命令行标记。

命令行就是一个字符串,它被用来控制内核的一些行为。比如"root=/dev/mtdblock2 init="/linuxrc" console="ttySAC0""表示根文件系统在MTD2分区上,系统启动后执行的第一个程序为/linuxrc,控制台为ttySAC0(即第一 个串口)。

命令行可以在Bootloader中通过命令设置好,然后如下构造标记传给内核:

char *p = "root=/dev/mtdblock2 init="/linuxrc" console="ttySAC0"";

params->hdr.tag = ATAG_CMDLINE;

params->hdr.size = (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2;


strcpy (params->u.cmdline.cmdline, p);


params = tag_next (params);


(4)设置标记ATAG_NONE。

标记列表以标记ATAG_NONE结束,如下设置:

params->hdr.tag = ATAG_NONE;

params->hdr.size = 0;

Uboot命令和内核启动参数的设置方法 Uboot命令和内核启动参数的设置方法 Uboot命令和内核启动参数的设置方法 立即下载

相关推荐

Cadence Allegro PCB文件对比实战:3分钟搞定两份设计差异(附颜色标注技巧)

本文详细介绍了如何高效使用Cadence Allegro的Design Compare功能进行PCB文件差异对比。通过实战工作流,可在3分钟内精准定位并理解两份设计在布局、布线、元件等方面的关键差异,并分享了自定义颜色标注技巧,帮助工程师快速聚焦重要修改,提升设计评审与团队协作效率。

weixin_29248653的博客 379

Linux下bootargs引导参数说明

本文是学习hisi芯片启动过程,不同的芯片启动方式不一样,但都大同小异。   ========================================= 设置系统启动参数 =========================================    必须正确设置bootargs参数或者烧写bootargs镜像才能保证系统正常启动               这个参数

peng_fp的博客 1万+

终端效率神器:Tmux 安装与使用全指南

终端效率神器:Tmux 安装与使用全指南

身在被窝_心在编程 1358

u_boot和Linux内核之间的参数传递

今天学了U_boot和Linux内核之间的参数传递,分享一下,写得不好勿怪...... u_boot完成的硬件的相关初始化,是知道Linux内核的相关信息的,但是Linux是直接被加载到内存中去的,刚开始对u_boot是一脸懵逼的,那怎么办呢?当然是u_boot告诉Linux内核一些信息,这就是所谓的参数传递。 u_boot主要传递给Linux内核3个参数: r0:0x0    r1 :

想挣五斗米的博客 767

电子技术——共栅和共源共栅放大器的高频响应

我们在之前学过无论是是CS放大器还是CE放大器,都可以看做是一个带通(IC低通)滤波器。在高频处的响应收到输入电容 $C_{in}$ 的限制(主要是米勒效应)。因此,若想扩大放大器的带宽,我们必须减小米勒效应,一种方案就是共栅放大器。

jiahonghao2002的博客 4183

原形网络(Prototypical Networks)基于PyTorch的实现

我在Jay2coomzz的基础上修改了数据处理方式和evaluation_model()方法,作为初学者若有不当之处恳请大家批评指正,原文链接如下: https://blog.youkuaiyun.com/weixin_38471579/article/details/102631018 数据集和源码链接将放到评论区 文章目录1 数据集一个简单的数据集介绍数据集处理2 搭建网络CNNProtonets 1 数据集 一个简单的数据集介绍 Omniglot数据集一共包含1623 类手写体,每一类中包含20 个样本。其中.

weixin_43872532的博客 6636

u-boot分析五 向linux内核传递启动参数(详细)

u-boot 向linux 内核传递启动参数(详细) U-BOOT 在启动内核时,会向内核传递一些参数.BootLoader 可以通过两种方法传递参数给内核,一种是旧 的参数结构方式(parameter_struct),主要是 2.6 之前的内核使用的方式。另外一种就是现在的 2.6 内核 在用的参数链表 (tagged list) 方式。这些参数主要包括,系统的根设备标志,页面大小,内存的...

heart18335101121的博客 763

TCGA之GDC-client工具下载安装与使用

文章主要是对GDC-client工具下载TCGA数据库数据整个过程的一个记录 1.下载GDC-client工具 GDC-client工具网址:GDC Data Transfer Tool | NCI Genomic Data Commons (cancer.gov) 我这里下的是上图中红圈中的版本, 2.解压安装 从网上了解的是不能解压到带中文的路径里,解压后是一个.exe文件,为了能直接在cmd命令行下使用,将其加入系统环境: 点击新建之后,输入将文件解压到的路径,然后...

better_strong的博客 1万+

u-boot向linux内核传递启动参数(详细)

U-BOOT 在启动内核时,会向内核传递一些参数.BootLoader 可以通过两种方法传递参数给内核,一种是旧的参数结构方式(parameter_struct),主要是 2.6 之前的内核使用的方式。另外一种就是现在的 2.6内核在用的参数链表 (tagged list) 方式。这些参数主要包括,系统的根设备标志,页面大小,内存的起始地址和大小,RAMDISK的起始地址和大小,压缩的RAMDISK根文件系统的起始地址和大小,当前内核命令参数等而这些参数是通过 struct tag来传递的。U-boot

I15902020106的博客 2960

全国充电站分布数据

CnOpenData推出的充电站数据覆盖全国34个省份的3万条数据,包含充电站名称、省份名称、省份代码、商圈、经纬度等地理信息以及商业类型、评分、消费等衍生信息,能为城市规划、环境科学、市场分析、技术发展和社会经济研究等多个领域提供宝贵的数据支持。

Sunny9qx的博客 4024

智能硬件产品 App 全球发布 第 1 章:全球 App 发布战略设计

本章阐述智能硬件 App 全球发布战略,涵盖市场分析、竞争格局、用户画像及资源配置。通过制定可执行的全球化推广路径,整合地区法规合规、渠道分发策略与营销活动设计,助力团队快速进入主流商店并确立品牌影响力。同时构建可量化的 KPI 监控体系,指导项目进度追踪与效果复盘,确保产品迭代持续优化,降低运营总成本。

moton2017的博客 156

uboot启动参数详解和一些细节

dev/nfs nfsroot=192.168.1.105:/home/hawen/zyp_linux/nfs/rootfs ip=192.168.1.20:192.168.1.105:192.168.1.1:255.255.255.0::eth0:off 这里的参数表示根文件系统通过nfs的方式进行挂载,这里的/home/hawen/zyp_linux/nfs/rootfs 是我们主机下通过busybox挂载根文件系统的挂载点。init=/linuxrc 表示内核启动后执行的第一个程序。

hwf1877655的博客 2854

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

uboot传入的linux启动参数解析----命令行

原文地址::http://blogt.chinaunix.net/link.php?url=http://blog.youkuaiyun.com%2Flanmanck%2Farchive%2F2009%2F05%2F15%2F4187389.aspx     Bootloader与内核的交互 Bootloader与内核的交互是单向的,Bootloader将各类参数传给内核。由于它们不能同时运行,

xqhrs232的专栏 739

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

uboot传入的linux启动参数解析

Bootloader与内核的交互 Bootloader与内核的交互是单向的,Bootloader将各类参数传给内核。由于它们不能同时运行,传递办法只有一个:Bootloader将参数放在某个约定的地方之后,再启动内核,内核启动后从这个地方获得参数。 除了约定好参数存放的地址外,还要规定参数的结构。Linux 2.4.x 以后的内核都期望以标记列表(tagged list)的形式来传递启动...

编程资料大全 257

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

B:LINUX解析UBOOT传入参数的原理

 (会把传入的参数存一个字符串中) LINUX内核源码版本:linux-3.0.86     kernel_entry(0, machid, bd->bi_boot_params);bd->bi_boot_params=0x40000100 R0=0,r1=machid,r2=0x40000100.由上节的此函数从UBOOT转入LINUX代继续执行,转入的首地址由vmlinux.ld

YACHL882828的博客 963

Linux设备树4

Linux设备树4(基于Linux6.6)---内核head.S对uboot传参的处理

ListQ的博客 827

devicetree和启动参数解析流程

AARCH64架构下内核可以通过设备树或acpi方式获取设备信息,其中acpi主要用于服务器领域,而设备树用于嵌入式领域。在设备树方式中,bootloader启动之前将设备树拷贝到内存中,并将地址通过x2寄存器传递给kernel,kernel启动时从设备树中读取启动参数和设备配置节点。由于内存配置信息是由device tree传入的,而将device tree解析为device node的流程中需要为node和property分配内存。

jia_weihui的博客 1310

将自定义参数从uboot传入kernel的并读取的方法【转】

本文转载自:http://blog.youkuaiyun.com/qq_29729577/article/details/50580727 希望朋友们多多指点,好的技术或心得一起分享: uboot向kernel传参机制以及kernel如何解析cmdline参数大家可以参考其他前辈的博文,这方面的讲解十分详尽。 在这里我总结以下自己在uboot自定义一个参数并从kernel中取得的方法: 一....

zzb2760715357的博客 153

Linux源码分析-内核启动过程

1. 启动入口 通过链接脚本arch/arm/kernel/vmlinux.lds可以找到内核的入口函数,通过ENTRY(stext)可以知道内核进入的第一个接口为stext接口,由于初始化部分的代码是与架构相关的,所以在不同架构中都有对stext接口的实现,例如查看arm64架构的初始化流程,则进入arch/arm64/kernel/head.S文件,stext接口的实现如下: ![在这里插入图片描述](https://img-blog.csdnimg.cn/3086824ac98b48ee8

weixin_43338497的博客 640

如何实现uboot和linux之间的参数传递

参考http://cgxcn.blog.163.com/blog/static/132312422009101133251202/ 参考:http://blog.chinaunix.net/uid-14833587-id-76499.html 参考:http://lixuefeng26.blog.sohu.com/204383842.html 原理就是:uboot将要传递的参数,保存到一个指...

weixin_30877227的博客 265

uboot-->kernel

BootLoader可以向Linux传递参数,编译内核时也可以配置boot options。 调试中使用的U-Boot bootargs如下: noinitrd root=/dev/mtdblock3 rw console=ttySAC0,115200 init=/linuxrc mem=64M

cupidove的专栏 672

uboot向kernel的传参机制——bootm与tags

U-boot版本:2014.4 Kernel版本:3.4.55 一 uboot 如何启动 kernel 1 do_bootm uboot下使用bootm命令启动内核镜像文件uImage,uImage是在zImage头添加了64字节的镜像信息供uboot解析使用,具体这64字节头的内容,我们在分析bootm命令的时候就会一一说到,那直接来看bootm命令。

tangdichao的专栏 716

Linux移植之tag参数列表解析过程分析

在Linux移植之内核启动过程start_kernel函数简析中已经指出了start_kernel函数的调用层次,这篇主要是对具体的tag参数列表进行解析。 1、内存参数ATAG_MEM参数解析 2、命令行参数ATAG_CMDLINE解析,以传入的命令参数bootargs=noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0为列:...

weixin_30273931的博客 320
上一篇: 如何使用CToolTip CToolTipCtrl
下一篇: uboot 中的 config ,make config是怎么来的。
#Page#
博客等级 码龄23年 1691粉丝 360原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值