WO2017177690A1 - 一种向Linux内核传递内存大小参数的方法及系统 - Google Patents

一种向Linux内核传递内存大小参数的方法及系统 Download PDF

Info

Publication number
WO2017177690A1
WO2017177690A1 PCT/CN2016/108169 CN2016108169W WO2017177690A1 WO 2017177690 A1 WO2017177690 A1 WO 2017177690A1 CN 2016108169 W CN2016108169 W CN 2016108169W WO 2017177690 A1 WO2017177690 A1 WO 2017177690A1
Authority
WO
WIPO (PCT)
Prior art keywords
size parameter
memory size
memory
dynamic
bootargs
Prior art date
Application number
PCT/CN2016/108169
Other languages
English (en)
French (fr)
Inventor
钟捷群
Original Assignee
上海斐讯数据通信技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海斐讯数据通信技术有限公司 filed Critical 上海斐讯数据通信技术有限公司
Publication of WO2017177690A1 publication Critical patent/WO2017177690A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/10Plc systems
    • G05B2219/15Plc structure of the system
    • G05B2219/15065Optimize program memory space

Definitions

  • the present invention relates to the field of operating systems, and in particular, to a method and system for transferring memory size parameters to a Linux kernel.
  • command line parameters are derived from the bootargs environment variable, and the bootargs usually contain the memory size parameter mem available to Linux.
  • the static configuration of bootargs has the following problems: (1) Statically configure different bootargs for different products (because mem is different), Maintenance troubles; (2) Once the bootargs are destroyed, the memory parameters are lost, which may cause the product to run incorrectly.
  • the memory size parameter is particularly important, if the memory size parameter can be better passed to the Linux kernel, the defects of the prior art will be well improved, and this goal is also the direction that those skilled in the art are studying.
  • the technical problem to be solved by the present invention is that it is troublesome to maintain and error-prone.
  • the present invention provides a method for passing a memory size parameter to a Linux kernel, including the steps of:
  • the dynamic memory size parameter is dynamically determined by using the maximum memory and the minimum memory as parameters.
  • the bootargs environment variable is dynamically generated based on the dynamic memory size parameter obtained by dynamic measurement.
  • the step of dynamically determining the memory size parameter by using the maximum memory and the minimum memory as parameters during the running of the U-Boot boot program includes:
  • the initial value of the memory size parameter is the minimum memory
  • the dynamic memory size parameter takes the current memory size parameter, and the measurement ends. This scheme is preferred in the dynamic measurement process, which limits the value range of the memory size parameter. If the minimum memory and maximum memory limit are exceeded, the dynamic memory size parameter will not be out of range and an exception will occur; Setting the magic word can make the measured dynamic memory size parameter meet the needs of the current product.
  • the memory size parameter is multiplied by 2;
  • the dynamic memory size parameter is equal to the maximum memory, and the measurement ends.
  • the warning of the memory size parameter is abnormal, and the measurement ends. If an abnormality occurs in the dynamic measurement step, the abnormality is fed back to the system to repair according to the abnormality, and help Good maintenance.
  • the step of dynamically generating the bootargs environment variable according to the dynamic memory size parameter obtained by the dynamic measurement includes:
  • Read the environment variable bootargs and parse the static memory size parameter in the static configuration.
  • the static memory size parameter does not exist, use the dynamic memory size parameter to regenerate the bootargs environment variable. Based on the dynamic memory size parameter, the regenerated bootargs environment variable can better use the needs of the current product.
  • the dynamic memory size parameter is used to regenerate the bootargs environment variable, and the static memory size parameter does not exist.
  • the existence of the dynamic memory size parameter makes the static memory size parameter not affect the normal operation of the system even if it is lost, and the detection and warning that the static memory size parameter does not exist can help the user to know the current abnormal situation, and better. Repair and maintenance, if this problem occurs, you can quickly get the problem without having to check the machine thoroughly, and then solve the problem, save time and improve work efficiency.
  • the maximum memory value is equal to the maximum memory supported by the used DDR memory controller
  • the method uses only one DDR memory controller
  • the method of the solution requires high continuity of memory addresses. Only one DDR memory controller can reduce the algorithm compensation between multiple memory controllers to perform corresponding steps and reduce the workload; of course, if multiple The memory address between the DDR memory controllers is continuous. You can also use this method directly. If the memory address is not continuous, you can use the method of this scheme to transfer the memory size parameters after compensation.
  • 256MByte is a relatively small memory, and the minimum memory value is 256MByte. Therefore, it is not necessary to set the minimum memory separately for each platform; of course, the minimum memory is no matter the minimum internal access value. Must be able to Guarantee the work of U-Boot.
  • the present invention also provides a system for passing memory size parameters to a Linux kernel, including:
  • the U-Boot bootloader includes:
  • a static configuration module for statically setting the maximum and minimum memory that can be supported according to the CPU platform, and statically configuring the bootargs environment variable;
  • a dynamic measurement module configured to dynamically determine a dynamic memory size parameter by using a maximum memory and a minimum memory as parameters during the running of the U-Boot boot program
  • the bootargs environment variable regeneration module is configured to re-generate the bootargs environment variable dynamically according to the dynamic memory size parameter obtained by the dynamic measurement module.
  • the dynamic measurement module is further configured to:
  • the dynamic memory size parameter takes the current memory size parameter, and the measurement ends; if not, then Multiply the memory size parameter by 2, and re-determine whether the memory size parameter is less than the maximum memory with the new memory size parameter;
  • the bootargs environment variable regeneration module is also used to:
  • Read the environment variable bootargs and parse the static memory size parameter in the static configuration.
  • the dynamic memory size parameter can also be used well for various product requirements without having to statically configure different bootargs for different products to avoid maintenance troubles.
  • the bootargs environment variable mainly relies on dynamic memory.
  • the size parameter is generated. The initial static configuration of the bootargs no longer plays a decisive role. In time, the bootargs are destroyed, the memory parameters are lost, and the product does not run wrong.
  • FIG. 2 is a flow chart of a method for transmitting a memory size parameter to a Linux kernel according to the present invention
  • FIG. 3 is a schematic flow chart of U-Boot booting Linux after the method of the present invention is applied;
  • FIG. 4 is a schematic diagram of a system for transferring memory size parameters to a Linux kernel according to Embodiment 2 of the present invention.
  • FIG. 1 is a schematic flow chart of U-Boot booting Linux in the prior art. Referring to FIG. 1, it is often used to pass a parameter to a Linux kernel U-Boot through a command line.
  • the command line parameter is derived from the bootargs environment variable. In bootargs, usually contains the memory size available for Linux. Number of mem;
  • Embodiment 1 is a diagrammatic representation of Embodiment 1:
  • the present invention provides a method for transferring a memory size parameter to a Linux kernel. As shown in FIG. 2, the method includes the following steps:
  • S1 statically set the maximum memory and minimum memory that can be supported according to the CPU platform
  • the dynamic memory size parameter is dynamically determined by using the maximum memory and the minimum memory as parameters
  • the dynamic memory size parameter can also be used well for various product requirements without having to statically configure different bootargs for different products to avoid maintenance troubles.
  • the bootargs environment variable mainly relies on dynamic memory.
  • the size parameter is generated. The initial static configuration of the bootargs no longer plays a decisive role. In time, the bootargs are destroyed, the memory parameters are lost, and the product does not run wrong.
  • FIG. 3 is a schematic flowchart of a U-Boot booting Linux kernel according to an embodiment of the present invention.
  • the step of dynamically determining the memory size parameter by using the maximum memory and the minimum memory as parameters during the running of the U-Boot boot program includes:
  • the initial value of the memory size parameter is the minimum memory
  • the dynamic memory size parameter takes the current memory size parameter, and the measurement ends. This scheme is preferred in the dynamic measurement process, which limits the value range of the memory size parameter. If the minimum memory and maximum memory limit are exceeded, the dynamic memory size parameter will not be out of range and an exception will occur; Setting the magic word can make the measured dynamic memory size parameter meet the needs of the current product.
  • the memory size parameter is multiplied by 2;
  • the dynamic memory size parameter is equal to the maximum memory, and the measurement ends.
  • the warning of the abnormal memory size parameter is returned, and the measurement ends. If an abnormality occurs in the dynamic measurement step, the abnormality is fed back to the system to repair it according to the abnormality and help to perform maintenance better.
  • the step of dynamically generating the bootargs environment variable according to the dynamic memory size parameter obtained by the dynamic measurement includes:
  • Read the environment variable bootargs and parse the static memory size parameter in the static configuration.
  • the static memory size parameter does not exist, use the dynamic memory size parameter to regenerate the bootargs environment variable. Based on the dynamic memory size parameter, the regenerated bootargs environment variable can better use the needs of the current product.
  • the dynamic memory size parameter is used to regenerate the bootargs environment variable, and the return static memory size parameter does not exist. Warning.
  • the existence of the dynamic memory size parameter makes the static memory size parameter not affect the normal operation of the system even if it is lost, and the detection and warning that the static memory size parameter does not exist can help the user to know the current abnormal situation, and better. Repair and maintenance, if this problem occurs, you can quickly get the problem without having to check the machine thoroughly, and then solve the problem, save time and improve work efficiency.
  • the maximum memory value is equal to the maximum memory supported by the DDR memory controller used.
  • the method uses only one DDR memory controller.
  • the method of the solution requires high continuity of memory addresses. Only one DDR memory controller can reduce the algorithm compensation between multiple memory controllers to perform corresponding steps and reduce the workload; of course, if multiple The memory address between the DDR memory controllers is continuous. You can also use this method directly. If the memory address is not continuous, you can use the method of this scheme to transfer the memory size parameters after compensation.
  • the minimum memory is set to 256 MByte.
  • 256MByte is a relatively small memory
  • the minimum memory value is 256MByte. Therefore, it is not necessary to set the minimum memory separately for each platform; of course, the minimum memory is no matter the minimum internal access value. Must be able to guarantee the work of U-Boot.
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • FIG. 4 is a schematic diagram of a system for transferring memory size parameters to a Linux kernel according to Embodiment 2 of the present invention, including:
  • the U-Boot boot program 10 is configured to pass a memory size parameter to the Linux kernel 21 of the Linux system 20;
  • the U-Boot bootloader 10 includes:
  • the static configuration module 11 is configured to statically set a maximum memory and a minimum memory that can be supported according to the CPU platform, and statically configure a bootargs environment variable;
  • the dynamic determining module 12 is configured to dynamically determine the dynamic memory size parameter by using the maximum memory and the minimum memory as parameters during the running of the U-Boot booting program;
  • the bootargs environment variable regeneration module 13 is configured to dynamically generate the bootargs environment variable according to the dynamic memory size parameter obtained by the dynamic measurement module.
  • the U-Boot bootloader, static configuration module, dynamic measurement module and bootargs environment variables are used to regenerate the coordination of the module, configuration and maximum memory and minimum memory, and the maximum memory and minimum memory are used as parameters.
  • the product statically configures different bootargs to avoid maintenance troubles.
  • the bootargs environment variable mainly depends on the dynamic memory size parameter, the initial static configuration of the bootargs no longer plays a decisive role. In time, the bootargs are destroyed, and the memory parameters are Lost, it will not cause problems in product operation.
  • the dynamic measurement module is further configured to:
  • the dynamic memory size parameter takes the current memory size parameter, and the measurement ends; if not, then Multiply the memory size parameter by 2, and re-determine whether the memory size parameter is less than the maximum memory with the new memory size parameter;
  • the bootargs environment variable regeneration module is also used to:
  • Read the environment variable bootargs and parse the static memory size parameter in the static configuration.
  • the static memory size parameter does not exist, use the dynamic memory size parameter to regenerate the bootargs environment variable.
  • the measured dynamic memory size parameter can meet the needs of the current product; based on the dynamic memory size parameter, the regenerated bootargs environment variable can better use the current product requirements.

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Automation & Control Theory (AREA)
  • Stored Programmes (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

一种向Linux内核传递内存大小参数的方法及系统,该方法包括:根据CPU平台,静态设置可支持的最大内存和最小内存(S1);静态配置bootargs环境变量(S2);在U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定得到动态内存大小参数(S3);根据动态测定得到的动态内存大小参数,重新动态生成bootargs环境变量(S4)。该方法可以减少维护麻烦,容易出错的情况发生。

Description

一种向Linux内核传递内存大小参数的方法及系统
本申请要求2016年04月12日提交的申请号为:201610224257.4、发明名称为“一种向Linux内核传递内存大小参数的方法及系统”的中国专利申请的优先权,其全部内容合并在此。
技术领域
本发明涉及操作系统领域,尤其涉及一种向Linux内核传递内存大小参数的方法及系统。
背景技术
现有技术中,常常需要采用命令行传递参数给Linux内核的U-Boot,命令行参数来源于bootargs环境变量,在bootargs中通常包含Linux可用的内存大小参数mem。
但是,在具体使用过程中,例如,出现使用同样CPU平台,但内存大小不同的产品时,静态配置bootargs存在如下问题:(1)需要对不同的产品静态配置不同的bootargs(因为mem不同),维护麻烦;(2)一旦bootargs被破坏,则内存参数丢失,可能导致产品运行出错。
由于其中内存大小参数尤为重要,因而若能够更好地向Linux内核传递内存大小参数,将能够很好的改善现有技术的缺陷,而这一目标也是本领域技术人员正在研究的方向。
发明内容
本发明所要解决的技术问题是维护麻烦,容易出错。
为了解决上述问题,本发明提供了一种向Linux内核传递内存大小参数的方法,包括步骤:
根据CPU平台,静态设置可支持的最大内存和最小内存;
静态配置bootargs环境变量;
在U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定得到动态内存大小参数;
根据动态测定得到的动态内存大小参数,重新动态生成bootargs环境变量。
可选的,所述在U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定内存大小参数的步骤包括:
在内存初始地址处写入预设魔术字;
将内存大小参数取初值为最小内存;
判断内存大小参数是否小于最大内存;
若小于,则读取内存初始地址加上内存大小参数处的变量;
判断变量是否等于魔术字,若等于,则动态内存大小参数取值为当前的内存大小参数,测定结束。本方案首选在动态测定过程中,限制了内存大小参数的取值范围,若超出最小内存和最大内存限定的范围,因而不会出现动态内存大小参数超出范围而出现异常的情况;另外,通过预设魔术字的设置,可以使得测定得到的动态内存大小参数符合当前产品的需要。
可选的,若在判断变量是否等于魔术字的步骤中,变量不等于魔术字,则内存大小参数乘以2;
并以新的内存大小参数,重新判断内存大小参数是否小于最大内存。循环判断,直至找到最适合的动态内存大小参数。
可选的,若在判断内存大小参数是否小于最大内存的步骤中,内存大小参数等于最大内存,则动态内存大小参数等于最大内存,测定结束。
可选的,若在判断内存大小参数是否小于最大内存的步骤中,内存大小参数大于最大内存,则反馈内存大小参数异常的警告,测定结束。若动态测定步骤出现异常,则将该异常反馈给系统,以便根据异常进行修复,帮助更 好地进行维护。
可选的,所述根据动态测定得到的动态内存大小参数,重新动态生成bootargs环境变量的步骤包括:
读取环境变量bootargs,解析其中静态配置的静态内存大小参数;
判断静态内存大小参数是否存在,若存在且静态内存大小参数与动态内存大小参数不同,则使用动态内存大小参数,重新生成bootargs环境变量;
若静态内存大小参数不存在,则使用动态内存大小参数,重新生成bootargs环境变量。以动态内存大小参数为基础,重新生成的bootargs环境变量可以更好地使用当前产品的需求。
可选的,若在判断静态内存大小参数是否存在的步骤中,静态内存大小参数不存在,则在使用动态内存大小参数,重新生成bootargs环境变量的同时,返回静态内存大小参数不存在的警告。动态内存大小参数的存在使得静态内存大小参数即使丢失也不会影响到系统的正常运行,而将静态内存大小参数不存在的检测和警告,则可以帮助用户知道当前存在的异常情况,而更好地进行修复和维护,若出现该问题时,无需对机器进行全面检查即可快速得到问题存在,继而解决问题,节约时间,提高工作效率。
可选的,所述最大内存的取值等于所使用的DDR内存控制器支持访问的最大内存;
所述方法只使用一个DDR内存控制器;
将该最小内存设置为256MByte。
本方案的方法,对于内存地址的连续性要求较高,只使用一个DDR内存控制器可以减少多个内存控制器之间进行算法补偿才能够进行对应的步骤,减少工作量;当然,若多个DDR内存控制器之间内存地址连续,也可以直接使用本方法;若内存地址不连续,则在进行补偿后也可以使用本方案的方法进行内存大小参数的传递。现在市面上主要的平台中,256MByte是其中比较小的内存,直接以取最小内存值为256MByte,则无需针对各个平台不同分别进行最小内存的设置;当然,无论最小内存取值多少,该最小内存必须能够 保证U-Boot的工作。
本发明还提供了一种向Linux内核传递内存大小参数的系统,包括:
CPU平台,用于运行Linux系统和U-Boot引导程序;
U-Boot引导程序,用于向所述Linux系统的Linux内核传递内存大小参数;
所述U-Boot引导程序包括:
静态配置模块,用于根据CPU平台静态设置可支持的最大内存和最小内存、以及静态配置bootargs环境变量;
动态测定模块,用于在所述U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定得到动态内存大小参数;
bootargs环境变量重新生成模块,用于根据所述动态测定模块得到的动态内存大小参数,重新动态生成bootargs环境变量。
可选的,所述动态测定模块还用于:
在内存初始地址处写入预设魔术字;将内存大小参数取初值为最小内存;判断内存大小参数是否小于最大内存;若等于,则动态内存大小参数等于最大内存,测定结束;
若小于,则读取内存初始地址加上内存大小参数处的变量;判断变量是否等于魔术字,若等于,则动态内存大小参数取值为当前的内存大小参数,测定结束;若不等于,则内存大小参数乘以2,并以新的内存大小参数,重新判断内存大小参数是否小于最大内存;
所述bootargs环境变量重新生成模块还用于:
读取环境变量bootargs,解析其中静态配置的静态内存大小参数;
判断静态内存大小参数是否存在,若存在且静态内存大小参数与动态内存大小参数不同,则使用动态内存大小参数,重新生成bootargs环境变量;若静态内存大小参数不存在,则使用动态内存大小参数,重新生成bootargs环境变量。
与现有技术相比,本发明的技术方案具有以下优点:
由于预先依据工作平台的不同,配置和最大内存和最小内存,并将最大内存和最小内存作为参数动态测定动态内存大小参数,并以该动态内存大小参数重新动态生成bootargs环境变量;这使得即使使用同一平台,也可以通过动态内存大小参数很好的使用各种产品的需求,而无须对不同的产品静态配置不同的bootargs,避免维护麻烦的问题;另外,由于bootargs环境变量主要依靠的是动态内存大小参数生成的,初始静态配置的bootargs不再渠道决定性的作用,及时该bootargs被破坏,内存参数丢失,也不会导致产品运行出错的问题。
附图说明
图1是现有技术中U-Boot引导Linux的概略流程图;
图2是本发明向Linux内核传递内存大小参数的方法流程图;
图3是本发明运用本发明方法后U-Boot引导Linux的概略流程图;
图4是本发明实施例二的一种向Linux内核传递内存大小参数的系统示意图。
具体实施方式
在下面的描述中阐述了很多具体细节以便于充分理解本发明。但是本发明能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本发明内涵的情况下做类似推广,因此本发明不受下面公开的具体实施的限制。
其次,本发明利用示意图进行详细描述,在详述本发明实施例时,为便于说明,所述示意图只是实例,其在此不应限制本发明保护的范围。
图1是现有技术中,U-Boot引导Linux的概略流程图,参考图1可知,常常采用到通过命令行传递参数给Linux内核的U-Boot的情况,该命令行参数来源于bootargs环境变量,在bootargs中通常包含Linux可用的内存大小参 数mem;
但是,在具体操作过程中,常常会出现使用同样CPU平台,但内存大小不同的产品。碰到这类情景,静态配置bootargs存在如下问题:(1)需要对不同的产品静态配置不同的bootargs(因为mem不同),维护麻烦;(2)一旦bootargs被破坏,则内存参数丢失,可能导致产品运行出错。
下面结合附图和具体实施例对本发明的技术方案做进一步说明。
实施例一:
为了解决背景技术中的技术问题,本发明提供了一种向Linux内核传递内存大小参数的方法,如图2所示,该方法包括步骤:
S1:根据CPU平台,静态设置可支持的最大内存和最小内存;
S2:静态配置bootargs环境变量;
S3:在U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定得到动态内存大小参数;
S4:根据动态测定得到的动态内存大小参数,重新动态生成bootargs环境变量。
与现有技术相比,本发明的技术方案具有以下优点:
由于预先依据工作平台的不同,配置和最大内存和最小内存,并将最大内存和最小内存作为参数动态测定动态内存大小参数,并以该动态内存大小参数重新动态生成bootargs环境变量;这使得即使使用同一平台,也可以通过动态内存大小参数很好的使用各种产品的需求,而无须对不同的产品静态配置不同的bootargs,避免维护麻烦的问题;另外,由于bootargs环境变量主要依靠的是动态内存大小参数生成的,初始静态配置的bootargs不再渠道决定性的作用,及时该bootargs被破坏,内存参数丢失,也不会导致产品运行出错的问题。
图3是本发明实施例U-Boot引导Linux内核的概略流程图,结合图3可知:
本实施例可选的,在U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定内存大小参数的步骤包括:
在内存初始地址处写入预设魔术字;
将内存大小参数取初值为最小内存;
判断内存大小参数是否小于最大内存;
若小于,则读取内存初始地址加上内存大小参数处的变量;
判断变量是否等于魔术字,若等于,则动态内存大小参数取值为当前的内存大小参数,测定结束。本方案首选在动态测定过程中,限制了内存大小参数的取值范围,若超出最小内存和最大内存限定的范围,因而不会出现动态内存大小参数超出范围而出现异常的情况;另外,通过预设魔术字的设置,可以使得测定得到的动态内存大小参数符合当前产品的需要。
本实施例可选的,若在判断变量是否等于魔术字的步骤中,变量不等于魔术字,则内存大小参数乘以2;
并以新的内存大小参数,重新判断内存大小参数是否小于最大内存。循环判断,直至找到最适合的动态内存大小参数。
本实施例可选的,若在判断内存大小参数是否小于最大内存的步骤中,内存大小参数等于最大内存,则动态内存大小参数等于最大内存,测定结束。
本实施例可选的,若在判断内存大小参数是否小于最大内存的步骤中,内存大小参数大于最大内存,则反馈内存大小参数异常的警告,测定结束。若动态测定步骤出现异常,则将该异常反馈给系统,以便根据异常进行修复,帮助更好地进行维护。
本实施例可选的,根据动态测定得到的动态内存大小参数,重新动态生成bootargs环境变量的步骤包括:
读取环境变量bootargs,解析其中静态配置的静态内存大小参数;
判断静态内存大小参数是否存在,若存在且静态内存大小参数与动态内存大小参数不同,则使用动态内存大小参数,重新生成bootargs环境变量;
若静态内存大小参数不存在,则使用动态内存大小参数,重新生成bootargs环境变量。以动态内存大小参数为基础,重新生成的bootargs环境变量可以更好地使用当前产品的需求。
本实施例可选的,若在判断静态内存大小参数是否存在的步骤中,静态内存大小参数不存在,则在使用动态内存大小参数,重新生成bootargs环境变量的同时,返回静态内存大小参数不存在的警告。动态内存大小参数的存在使得静态内存大小参数即使丢失也不会影响到系统的正常运行,而将静态内存大小参数不存在的检测和警告,则可以帮助用户知道当前存在的异常情况,而更好地进行修复和维护,若出现该问题时,无需对机器进行全面检查即可快速得到问题存在,继而解决问题,节约时间,提高工作效率。
本实施例可选的,最大内存的取值等于所使用的DDR内存控制器支持访问的最大内存。
本实施例可选的,方法只使用一个DDR内存控制器。本方案的方法,对于内存地址的连续性要求较高,只使用一个DDR内存控制器可以减少多个内存控制器之间进行算法补偿才能够进行对应的步骤,减少工作量;当然,若多个DDR内存控制器之间内存地址连续,也可以直接使用本方法;若内存地址不连续,则在进行补偿后也可以使用本方案的方法进行内存大小参数的传递。
本实施例可选的,将该最小内存设置为256MByte。现在市面上主要的平台中,256MByte是其中比较小的内存,直接以取最小内存值为256MByte,则无需针对各个平台不同分别进行最小内存的设置;当然,无论最小内存取值多少,该最小内存必须能够保证U-Boot的工作。
结合图3所示,在根据测定的动态内存大小参数重新动态声测很难过bootargs环境变量后,还需要把boottargs拷贝到指定地址,并调用引导脚本搬移Linux,最后跳转知悉Linux,后续步骤与现有技术类似,主要区别在于,该bootargs里面包含有动态内存大小参数,这是现有技术所没有的。
实施例二:
图4是本发明实施例二的一种向Linux内核传递内存大小参数的系统示意图,包括:
CPU平台100,用于运行Linux系统20和U-Boot引导程序10;
U-Boot引导程序10,用于向Linux系统20的Linux内核21传递内存大小参数;
U-Boot引导程序10包括:
静态配置模块11,用于根据CPU平台静态设置可支持的最大内存和最小内存、以及静态配置bootargs环境变量;
动态测定模块12,用于在U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定得到动态内存大小参数;
bootargs环境变量重新生成模块13,用于根据动态测定模块得到的动态内存大小参数,重新动态生成bootargs环境变量。
与现有技术相比,本发明的技术方案具有以下优点:
由于预先依据CPU平台的不同,运用U-Boot引导程序、静态配置模块、动态测定模块和bootargs环境变量重新生成模块的协调工作,配置和最大内存和最小内存,并将最大内存和最小内存作为参数动态测定动态内存大小参数,并以该动态内存大小参数重新动态生成bootargs环境变量;这使得即使使用同一平台,也可以通过动态内存大小参数很好的使用各种产品的需求,而无须对不同的产品静态配置不同的bootargs,避免维护麻烦的问题;另外,由于bootargs环境变量主要依靠的是动态内存大小参数生成的,初始静态配置的bootargs不再渠道决定性的作用,及时该bootargs被破坏,内存参数丢失,也不会导致产品运行出错的问题。
本实施例可选的,动态测定模块还用于:
在内存初始地址处写入预设魔术字;将内存大小参数取初值为最小内存;判断内存大小参数是否小于最大内存;若等于,则动态内存大小参数等于最大内存,测定结束;
若小于,则读取内存初始地址加上内存大小参数处的变量;判断变量是否等于魔术字,若等于,则动态内存大小参数取值为当前的内存大小参数,测定结束;若不等于,则内存大小参数乘以2,并以新的内存大小参数,重新判断内存大小参数是否小于最大内存;
bootargs环境变量重新生成模块还用于:
读取环境变量bootargs,解析其中静态配置的静态内存大小参数;
判断静态内存大小参数是否存在,若存在且静态内存大小参数与动态内存大小参数不同,则使用动态内存大小参数,重新生成bootargs环境变量;
若静态内存大小参数不存在,则使用动态内存大小参数,重新生成bootargs环境变量。通过预设魔术字的设置,可以使得测定得到的动态内存大小参数符合当前产品的需要;以动态内存大小参数为基础,重新生成的bootargs环境变量可以更好地使用当前产品的需求。
本发明虽然已以较佳实施例公开如上,但其并不是用来限定本发明,任何本领域技术人员在不脱离本发明的精神和范围内,都可以利用上述揭示的方法和技术内容对本发明技术方案做出可能的变动和修改,因此,凡是未脱离本发明技术方案的内容,依据本发明的技术实质对以上实施例所作的任何简单修改、等同变化及修饰,均属于本发明技术方案的保护范围。

Claims (10)

  1. 一种向Linux内核传递内存大小参数的方法,其特征在于,包括:
    根据CPU平台,静态设置可支持的最大内存和最小内存;
    静态配置bootargs环境变量;
    在U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定得到动态内存大小参数;
    根据动态测定得到的动态内存大小参数,重新动态生成bootargs环境变量。
  2. 根据权利要求1所述的向Linux内核传递内存大小参数的方法,其特征在于,所述在U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定内存大小参数的步骤包括:
    在内存初始地址处写入预设魔术字;
    将内存大小参数取初值为最小内存;
    判断内存大小参数是否小于最大内存;
    若小于,则读取内存初始地址加上内存大小参数处的变量;
    判断变量是否等于魔术字,若等于,则动态内存大小参数取值为当前的内存大小参数,测定结束。
  3. 根据权利要求2所述的向Linux内核传递内存大小参数的方法,其特征在于,若在判断变量是否等于魔术字的步骤中,变量不等于魔术字,则内存大小参数乘以2;
    并以新的内存大小参数,重新判断内存大小参数是否小于最大内存。
  4. 根据权利要求2所述的向Linux内核传递内存大小参数的方法,其特征在于,若在判断内存大小参数是否小于最大内存的步骤中,内存大小参数等于最大内存,则动态内存大小参数等于最大内存,测定结束。
  5. 根据权利要求2所述的向Linux内核传递内存大小参数的方法,其特征在于,若在判断内存大小参数是否小于最大内存的步骤中,内存大小参数大于最大内存,则反馈内存大小参数异常的警告,测定结束。
  6. 根据权利要求1所述的向Linux内核传递内存大小参数的方法,其特征在于,所述根据动态测定得到的动态内存大小参数,重新动态生成bootargs环境变量的步骤包括:
    读取环境变量bootargs,解析其中静态配置的静态内存大小参数;
    判断静态内存大小参数是否存在,若存在且静态内存大小参数与动态内存大小参数不同,则使用动态内存大小参数,重新生成bootargs环境变量;
    若静态内存大小参数不存在,则使用动态内存大小参数,重新生成bootargs环境变量。
  7. 根据权利要求6所述的向Linux内核传递内存大小参数的方法,其特征在于,若在判断静态内存大小参数是否存在的步骤中,静态内存大小参数不存在,则在使用动态内存大小参数,重新生成bootargs环境变量的同时,返回静态内存大小参数不存在的警告。
  8. 根据权利要求1所述的向Linux内核传递内存大小参数的方法,其特征在于,所述最大内存的取值等于所使用的DDR内存控制器支持访问的最大内存;所述方法只使用一个DDR内存控制器;
    将该最小内存设置为256MByte。
  9. 一种向Linux内核传递内存大小参数的系统,其特征在于,包括:
    CPU平台,用于运行Linux系统和U-Boot引导程序;
    U-Boot引导程序,用于向所述Linux系统的Linux内核传递内存大小参数;
    所述U-Boot引导程序包括:
    静态配置模块,用于根据CPU平台静态设置可支持的最大内存和最小内存、以及静态配置bootargs环境变量;
    动态测定模块,用于在所述U-Boot引导程序运行过程中,以最大内存和最小内存为参数动态测定得到动态内存大小参数;
    bootargs环境变量重新生成模块,用于根据所述动态测定模块得到的动态 内存大小参数,重新动态生成bootargs环境变量。
  10. 如权利要求9所述的一种向Linux内核传递内存大小参数的系统,其特征在于,所述动态测定模块还用于:
    在内存初始地址处写入预设魔术字;将内存大小参数取初值为最小内存;判断内存大小参数是否小于最大内存;若等于,则动态内存大小参数等于最大内存,测定结束;
    若小于,则读取内存初始地址加上内存大小参数处的变量;判断变量是否等于魔术字,若等于,则动态内存大小参数取值为当前的内存大小参数,测定结束;若不等于,则内存大小参数乘以2,并以新的内存大小参数,重新判断内存大小参数是否小于最大内存;
    所述bootargs环境变量重新生成模块还用于:
    读取环境变量bootargs,解析其中静态配置的静态内存大小参数;
    判断静态内存大小参数是否存在,若存在且静态内存大小参数与动态内存大小参数不同,则使用动态内存大小参数,重新生成bootargs环境变量;若静态内存大小参数不存在,则使用动态内存大小参数,重新生成bootargs环境变量。
PCT/CN2016/108169 2016-04-12 2016-11-30 一种向Linux内核传递内存大小参数的方法及系统 WO2017177690A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610224257.4A CN105785824B (zh) 2016-04-12 2016-04-12 一种向Linux内核传递内存大小参数的方法及系统
CN201610224257.4 2016-04-12

Publications (1)

Publication Number Publication Date
WO2017177690A1 true WO2017177690A1 (zh) 2017-10-19

Family

ID=56396292

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/108169 WO2017177690A1 (zh) 2016-04-12 2016-11-30 一种向Linux内核传递内存大小参数的方法及系统

Country Status (2)

Country Link
CN (1) CN105785824B (zh)
WO (1) WO2017177690A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111209062A (zh) * 2020-01-11 2020-05-29 阿里巴巴集团控股有限公司 信息获取方法、装置、电子设备及计算机存储介质

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105785824B (zh) * 2016-04-12 2020-02-11 上海斐讯数据通信技术有限公司 一种向Linux内核传递内存大小参数的方法及系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6515683B1 (en) * 1999-06-22 2003-02-04 Siemens Energy And Automation Autoconfiguring graphic interface for controllers having dynamic database structures
CN101661436A (zh) * 2009-09-30 2010-03-03 中兴通讯股份有限公司 一种嵌入式系统内存动态分配方法及装置
CN102508726A (zh) * 2011-11-14 2012-06-20 福建星网锐捷网络有限公司 内存参数配置方法、处理器及设备
CN103678161A (zh) * 2012-09-06 2014-03-26 中兴通讯股份有限公司 内存管理方法及装置
CN103744694A (zh) * 2013-12-24 2014-04-23 武汉烽火众智数字技术有限责任公司 基于Nand闪存的动态分区搜索装置及其方法
CN105785824A (zh) * 2016-04-12 2016-07-20 上海斐讯数据通信技术有限公司 一种向Linux内核传递内存大小参数的方法及系统

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100517240C (zh) * 2006-06-21 2009-07-22 中兴通讯股份有限公司 一种嵌入式操作系统的内存池分配方法
CN102541572B (zh) * 2010-12-08 2015-09-16 中兴通讯股份有限公司 一种实现操作系统内核引导的方法、系统及装置
CN102298545B (zh) * 2011-08-23 2014-03-19 晨星软件研发(深圳)有限公司 一种系统启动引导处理方法及装置
CN103365700B (zh) * 2013-06-28 2016-01-06 福建师范大学 一种面向云计算虚拟化环境的资源监测和调整系统
CN104156234B (zh) * 2014-07-22 2018-07-31 华为技术有限公司 启动多核处理器、bootloader大小端模式自适应的方法及装置
CN104123381A (zh) * 2014-08-01 2014-10-29 武汉邮电科学研究院 一种硬件板卡的自动匹配方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6515683B1 (en) * 1999-06-22 2003-02-04 Siemens Energy And Automation Autoconfiguring graphic interface for controllers having dynamic database structures
CN101661436A (zh) * 2009-09-30 2010-03-03 中兴通讯股份有限公司 一种嵌入式系统内存动态分配方法及装置
CN102508726A (zh) * 2011-11-14 2012-06-20 福建星网锐捷网络有限公司 内存参数配置方法、处理器及设备
CN103678161A (zh) * 2012-09-06 2014-03-26 中兴通讯股份有限公司 内存管理方法及装置
CN103744694A (zh) * 2013-12-24 2014-04-23 武汉烽火众智数字技术有限责任公司 基于Nand闪存的动态分区搜索装置及其方法
CN105785824A (zh) * 2016-04-12 2016-07-20 上海斐讯数据通信技术有限公司 一种向Linux内核传递内存大小参数的方法及系统

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111209062A (zh) * 2020-01-11 2020-05-29 阿里巴巴集团控股有限公司 信息获取方法、装置、电子设备及计算机存储介质
CN111209062B (zh) * 2020-01-11 2023-04-25 阿里巴巴集团控股有限公司 信息获取方法、装置、电子设备及计算机存储介质

Also Published As

Publication number Publication date
CN105785824B (zh) 2020-02-11
CN105785824A (zh) 2016-07-20

Similar Documents

Publication Publication Date Title
US10235259B2 (en) Memory overclocking method and computer device
US20220391103A1 (en) Memory anomaly processing method and system, electronic device, and storage medium
EP3033680B1 (en) Memory migration in presence of live memory traffic
US10467106B2 (en) Data processing method, data processing system, and non-transitory computer program product for controlling a workload delay time
JP2013512526A (ja) プロセッサスワップ無しという条件を検出するメカニズムおよびブート中の高速バスキャリブレーションの修正変更
CN105320553A (zh) 一种基于国产处理器平台更新网卡固件的方法及系统
CN107491373A (zh) 一种任务栈溢出监测方法及系统
CN105302768A (zh) 一种从cpu异常处理方法及装置
CN104615472A (zh) 一种防止在线刷新bios+me fw失败的方法
CN107346268A (zh) 广义写入操作验证方法
US8006028B2 (en) Enabling memory module slots in a computing system after a repair action
WO2017177690A1 (zh) 一种向Linux内核传递内存大小参数的方法及系统
CN104598340A (zh) 硬件故障的检测系统、电子装置及方法
US7831858B2 (en) Extended fault resilience for a platform
CN108427617A (zh) Bmc获取cpu温度的方法、装置及设备
CN107392030A (zh) 一种检测虚拟机启动安全的方法及装置
JP2009187314A (ja) 二重化コントローラ・システム、cpuモジュール、そのプログラム
JP2005149503A (ja) Dmaを使用してメモリをテストするためのシステムおよび方法
CN107179911B (zh) 一种重启管理引擎的方法和设备
CN116436933A (zh) 一种基于流式计算的数据处理方法及装置
TWI554876B (zh) 節點置換處理方法與使用其之伺服器系統
TWI733964B (zh) 記憶體整體測試之系統及其方法
CN113987423B (zh) 一种基于进程替换的软件保护方法、装置及设备
EP4191449A1 (en) Systems and methods for verifying program states
US11487646B2 (en) Dynamic test case timers

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16898502

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 16898502

Country of ref document: EP

Kind code of ref document: A1