CN110858145A - Method and device for updating BIOS (basic input output System) in Linux operating system - Google Patents

Method and device for updating BIOS (basic input output System) in Linux operating system Download PDF

Info

Publication number
CN110858145A
CN110858145A CN201810961527.9A CN201810961527A CN110858145A CN 110858145 A CN110858145 A CN 110858145A CN 201810961527 A CN201810961527 A CN 201810961527A CN 110858145 A CN110858145 A CN 110858145A
Authority
CN
China
Prior art keywords
virtual address
space
address space
memory chip
mapping
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201810961527.9A
Other languages
Chinese (zh)
Inventor
马丽娟
赵雪峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Loongson Technology Corp Ltd
Original Assignee
Loongson Technology Corp Ltd
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 Loongson Technology Corp Ltd filed Critical Loongson Technology Corp Ltd
Priority to CN201810961527.9A priority Critical patent/CN110858145A/en
Publication of CN110858145A publication Critical patent/CN110858145A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a method and a device for updating a BIOS (basic input output System) in a Linux operating system, wherein the method comprises the following steps: mapping a first physical space of a memory chip for storing a Basic Input Output System (BIOS) to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space for storing a BIOS source file to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space; reading the BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip according to the mapping relation between the first physical space and the first virtual address space. The BIOS updating method and the BIOS updating device are convenient to operate and high in updating speed.

Description

Method and device for updating BIOS (basic input output System) in Linux operating system
Technical Field
The present application relates to computer technologies, and in particular, to a method and an apparatus for updating a BIOS in a Linux operating system.
Background
The Basic Input Output System (BIOS) is a standard firmware interface, which is a set of programs solidified on a Read Only Memory (ROM) chip on a computer motherboard, and stores a Basic Input Output program, System setting information, a self-checking program after power-on, and a System self-starting program. Its primary function is to provide the lowest level, most direct hardware setup and control for the computer. The Linux operating system is a free-to-use and free-to-propagate UNIX (unified Information and computing system) operating system, and is a multi-user, multi-task, multi-thread and multi-Central Processing Unit (CPU) operating system based on POSIX and UNIX.
Because the Linux Operating System does not have a Disk Operating System (DOS), the Linux Operating System cannot update the BIOS through DOS like the Windows Operating System. At present, there are two methods for updating the BIOS in the Linux operating system: one is to take down the Flash chip storing BIOS to burn in a special burner; another is to perform programming by a proprietary command under the BIOS command line.
For the first BIOS updating method, since the Flash chip can be taken out only by opening the chassis, the operation of updating the BIOS wastes time; in addition, if a new Flash model is added, the BIOS code needs to be modified, and the difficulty is high for engineers unfamiliar with the BIOS code.
Content of application
The application provides a method for updating a BIOS in a Linux operating system, which aims to solve the technical problem that the updating operation of the BIOS is complex or the operating system needs to be restarted in the prior art.
In a first aspect, the present application provides a method for updating a BIOS in a Linux operating system, including:
mapping a first physical space of a memory chip for storing a Basic Input Output System (BIOS) to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space for storing a BIOS source file to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space;
reading a BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and writing the read BIOS source file to be updated to the storage chip according to the mapping relation between the first physical space and the first virtual address space.
In one possible design, the method further includes:
mapping a configuration space of a target controller included in a Central Processing Unit (CPU) to a third virtual address space to obtain a mapping relation between the configuration space and the third virtual address space; the target controller is a controller which stores type information of the memory chip, and the type information of the memory chip is used for indicating the type of the memory chip;
reading a BIOS source file to be updated according to the mapping relationship between the second physical space and the second virtual address space, and writing the read BIOS source file to be updated to the memory chip according to the mapping relationship between the first physical space and the first virtual address space, including:
reading the type information of the storage chip stored in the target controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the storage chip;
reading a BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip by adopting a programming protocol corresponding to the type of the storage chip according to the mapping relation between the first physical space and the first virtual address space.
In one possible design, the method further includes:
mapping a control space of a controller of the memory chip to a fourth virtual address space to obtain a mapping relation between the control space and the fourth virtual address space;
before writing the read BIOS source file to be updated to the memory chip by using a writing protocol corresponding to the type of the memory chip according to the mapping relationship between the first physical space and the first virtual address space, the method further includes:
reading a manufacturer and an identifier of the memory chip stored in a controller of the memory chip according to the mapping relation between the control space and the fourth virtual address space;
and judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set, wherein the obtained judgment result is yes.
In a possible design, the reading, by the target controller, the type information of the memory chip stored in the target controller according to the mapping relationship between the configuration space and the third virtual address space to obtain the type of the memory chip includes:
reading the type information of the memory chip stored in the GPIO controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the memory chip;
the programming, according to the mapping relationship between the first physical space and the first virtual address space, the read BIOS source file to be updated to the memory chip by using a programming protocol corresponding to the type of the memory chip includes:
if the read type information of the memory chip is first information, writing the read BIOS source file to be updated to the memory chip by adopting a Serial Peripheral Interface (SPI) burning protocol according to the mapping relation between the first physical space and the first virtual address space; the first information is used for indicating that the type of the memory chip is SPI Flash;
if the read type information of the storage chip is second information, writing the read BIOS source file to be updated to the storage chip by adopting a short pin count bus LPC burning protocol according to the mapping relation between the first physical space and the space; the second information is used for indicating that the type of the storage chip is LPC Flash.
In one possible design, before mapping a second physical space storing a BIOS source file to be updated to a second virtual address space to obtain a mapping relationship between the first virtual address space and the second physical space, the method further includes:
opening the BIOS source file to be updated;
distributing a second virtual address space for a second physical space for storing the BIOS source file to be updated in the virtual address space;
before mapping a first physical space of a memory chip storing the BIOS to a first virtual address space to obtain a mapping relationship between the first physical space and the first virtual address space, the method further includes:
allocating a first virtual address space for a first physical space of the memory chip in a virtual address space;
before mapping a configuration space of a target controller included in a CPU to a third virtual address space to obtain a mapping relationship between the configuration space and the third virtual address space, the method further includes:
allocating the third virtual address space in a virtual address space for the configuration space;
before mapping a control space of a controller of the memory chip to a fourth virtual address space to obtain a mapping relationship between the control space and the fourth virtual address space, the method further includes:
allocating the fourth virtual address space in a virtual address space for the control space.
In a second aspect, an embodiment of the present application provides an apparatus for updating a BIOS in a Linux operating system, including:
the mapping module is used for mapping a first physical space of a memory chip for storing a Basic Input Output System (BIOS) to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space for storing a BIOS source file to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space;
and the programming module is used for reading the BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip according to the mapping relation between the first physical space and the first virtual address space.
In one possible design, the mapping module is further configured to,
mapping a configuration space of a target controller included in a Central Processing Unit (CPU) to a third virtual address space to obtain a mapping relation between the configuration space and the third virtual address space; the target controller is a controller which stores type information of the memory chip, and the type information of the memory chip is used for indicating the type of the memory chip;
the programming module is specifically configured to,
reading the type information of the storage chip stored in the target controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the storage chip;
reading a BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip by adopting a programming protocol corresponding to the type of the storage chip according to the mapping relation between the first physical space and the first virtual address space.
In one possible design, the mapping module is further configured to,
mapping a control space of a controller of the memory chip to a fourth virtual address space to obtain a mapping relation between the control space and the fourth virtual address space;
the programming module is further configured to read a manufacturer and an identifier of the memory chip stored in a controller of the memory chip according to a mapping relationship between the control space and the fourth virtual address space; and the number of the first and second groups,
and judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set, wherein the obtained judgment result is yes.
In a third aspect, the present application provides an electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the steps of the method of any one of the possible designs of the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon instructions which, when executed by a processor, implement the steps of the method in any one of the possible designs of the first aspect.
According to the method, the physical space of the memory chip for storing the BIOS and the physical space for storing the BIOS source file to be updated are both mapped to the virtual address space, and the virtual address space belongs to the user space, and the mapping relation between the virtual address space and the physical address space can be used as a bridge for accessing the physical address space in a user state, so that information in the BIOS source file to be updated can be read in the virtual address space through the mapping relation and the read BIOS source file to be updated can be written into the memory chip, a tedious copying process is not needed, and the updating rate of the BIOS is improved; meanwhile, the BIOS is updated in the user space, and the normal operation of the computer is not influenced without restarting an operating system in the operation in the user space, so that the BIOS updating method of the embodiment can update in the normal operation state of the computer, does not need to take out a storage chip and restart electronic equipment such as a computer, and is convenient to operate.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to these drawings without inventive exercise.
FIG. 1 is a first flowchart of a BIOS updating method under the Linux operating system provided in the present application;
FIG. 2 is a second flowchart illustrating a BIOS updating method in the Linux operating system according to the present application;
fig. 3 is a flowchart three of a method for updating a BIOS in the Linux operating system according to the present application;
FIG. 4 is a first schematic structural diagram of a BIOS updating apparatus under the Linux operating system provided in the present application;
fig. 5 is a second schematic structural diagram of a BIOS updating apparatus under the Linux operating system according to the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Fig. 1 is a first flowchart of a method for updating a BIOS in a Linux operating system according to the present application, as shown in fig. 1, the method of this embodiment may include:
step S101, mapping a first physical space of a memory chip for storing the BIOS to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space for storing a source file of the BIOS to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space;
specifically, the step is specifically realized as follows: the method comprises the steps of opening a full mirror image (/ dev/mem) device of a physical memory, calling a mmap function to map a first physical space of a storage chip for storing the BIOS to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space for storing a source file of the BIOS to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space.
The physical space of the memory chip is a space formed by all physical addresses of the memory chip; the second physical space for storing the BIOS source file to be updated refers to a space formed by physical addresses of the corresponding storage device (such as a disk) for storing the BIOS source file to be updated. The memory chip may be a Flash chip, a charged Erasable Programmable read only memory (EEPROM for short), or other chips with a memory function, which is not described herein again.
Optionally, after the Linux operating system is started, the Linux operating system allocates a corresponding virtual address space to each process; accordingly, the first virtual address space may be composed of a segment of virtual addresses in the virtual address space of the first user process, and the second virtual address space may be composed of a segment of virtual addresses in the virtual address space of the second user process, optionally, the first virtual address space is continuous, and the second virtual address space is continuous. The first user process and the second user process may be different processes.
The first virtual address space is continuous and the second virtual address space is continuous, so that when the first physical space of the memory chip for storing the BIOS is mapped to the virtual address space corresponding to the first user process, mapping is only needed once, and multiple times of mapping are not needed; and when the second physical space for storing the BIOS source file to be updated is mapped to the virtual address space corresponding to the second user process, the mapping is only needed once, and multiple times of mapping are not needed.
Further, before mapping a first physical space of a memory chip storing the BIOS to a first virtual address space of a first user process to obtain a mapping relationship between the first physical space and the first virtual address space, allocating a first virtual address space to the first physical space of the memory chip in the virtual address space of the first user process. Before mapping a second physical space for storing the BIOS source file to be updated to a second virtual address space of a second user process to obtain a mapping relation between the second physical space and the second virtual address space, the BIOS source file to be updated needs to be opened, and a second virtual address space is allocated to the second physical space corresponding to the BIOS source file to be updated in the virtual address space of the second user process.
The method comprises the steps of opening the/dev/mem device, calling a mmap function, and mapping a corresponding physical address in the physical memory to a virtual address space of a corresponding user process.
The mmap is a function of a memory mapping file, and the function can map a file or other objects to a virtual address space of a user process, so as to establish a one-to-one correspondence relationship between a file disk address and a section of virtual address in the process virtual address space. After the mapping relation is realized, the user process can adopt a pointer mode to perform read-write operation on the virtual memory corresponding to the section of virtual address, and the system can automatically write back the dirty page to the corresponding file disk, namely, the operation on the file is completed without calling system calling functions such as read, write and the like.
Step S102, reading a BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and writing the read BIOS source file to be updated to the storage chip according to the mapping relation between the first physical space and the first virtual address space.
Specifically, the second physical space is accessed under the user space through the mapping relation between the second physical space and the second virtual address space, and the BIOS source file to be updated is read from the second physical space; and then, the read BIOS source file to be updated is programmed into the storage chip according to the mapping relation between the first physical space and the first virtual address space, so that the updating of the BIOS is realized.
In the embodiment, both the physical space of the memory chip for storing the BIOS and the physical space for storing the BIOS source file to be updated are mapped to the virtual address space, and since the virtual address space belongs to the user space and the mapping relationship between the virtual address space and the physical address space can be used as a bridge for accessing the physical address space in the user mode, that is, the physical space of the memory chip for storing the BIOS and the physical space for storing the BIOS source file to be updated can be accessed in the user mode through the established mapping relationship, so that information in the BIOS source file to be updated can be read in the virtual address space through the mapping relationship and the read BIOS source file to be updated can be written into the memory chip, and the update rate of the BIOS is improved without a complicated copy process; meanwhile, the BIOS is updated in the user space, and the normal operation of the computer is not influenced without restarting an operating system in the operation in the user space, so that the BIOS updating method of the embodiment can update in the normal operation state of the computer, does not need to take out a storage chip and restart electronic equipment such as a computer, and is convenient to operate.
The method for updating the BIOS in the Linux operating system comprises the following steps: mapping a first physical space of a memory chip for storing the BIOS to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space for storing a source file of the BIOS to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space; reading the BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip according to the mapping relation between the first physical space and the first virtual address space. The method for updating the BIOS in the Linux operating system is convenient to operate and high in updating rate.
When the storage chip is a Flash chip, since the Flash chip has different types corresponding to different burning protocols, in order to prevent a user from adopting an incorrect burning protocol for burning when the user does not know the type of the Flash chip in advance, the embodiment is improved on the basis of the previous embodiment.
Fig. 2 is a first flowchart of a method for updating a BIOS in a Linux operating system according to the present application, as shown in fig. 2, the method of this embodiment may include:
step S201, mapping a first physical space of a memory chip for storing the BIOS to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, mapping a second physical space for storing a source file of the BIOS to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space, and mapping a configuration space of a target controller included in a CPU to a third virtual address space to obtain a mapping relation between the configuration space and the third virtual address space; the target controller is a controller which stores the type information of the memory chip, and the type information of the memory chip is used for indicating the type of the memory chip;
specifically, the step is specifically realized as follows: the method comprises the steps of opening/dev/mem equipment, calling a mmap function to map a first physical space of a memory chip for storing the BIOS to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, mapping a second physical space for storing a source file of the BIOS to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space, and mapping a configuration space of a target controller included by a CPU to a third virtual address space to obtain a mapping relation between the configuration space and the third virtual address space.
The configuration space is formed by physical addresses corresponding to a configuration register of a target controller included in the CPU, and the first physical space of the memory chip is formed by all the physical addresses of the memory chip; the second physical space for storing the BIOS source file to be updated refers to a space formed by physical addresses of the corresponding storage device (such as a disk) for storing the BIOS source file to be updated. The memory chip may be a Flash chip, an EEPROM chip, or other chips with a memory function, which are not described herein again.
Optionally, after the Linux operating system is started, the Linux operating system allocates a corresponding virtual address space to each process; correspondingly, the first virtual address space may be composed of a segment of virtual addresses in the virtual address space of the first user process, the second virtual address space may be composed of a segment of virtual addresses in the virtual address space of the second user process, and the third virtual address space may be composed of a segment of virtual addresses in the virtual address space of the third user process; optionally, the first virtual address space is contiguous, the second virtual address space is also contiguous, and the third virtual address space is also contiguous. The first user process, the second user process and the third user process may be different processes.
The first virtual address space is continuous, the second virtual address space is continuous, and the third virtual address space is continuous, so that when the first physical space of the memory chip for storing the BIOS is mapped to the virtual address space corresponding to the first user process, mapping is only needed once, and multiple times of mapping are not needed; when the second physical space for storing the BIOS source file to be updated is mapped to the virtual address space corresponding to the second user process, the mapping is only needed once, and multiple times of mapping are not needed; and when the configuration space of the target controller included in the CPU is mapped to the virtual address space corresponding to the third user process, the mapping is only needed to be carried out once, and the mapping is not needed to be carried out for multiple times.
As will be understood by those skilled in the art, before mapping a first physical space of a memory chip storing a BIOS to a first virtual address space of a first user process to obtain a mapping relationship between the first physical space and the first virtual address space, allocating a first virtual address space to the first physical space of the memory chip in the virtual address space of the first user process; before mapping a second physical space for storing a BIOS source file to be updated to a second virtual address space of a second user process to obtain a mapping relation between the second physical space and the second virtual address space, opening the BIOS source file to be updated, and distributing a second virtual address space for the second physical space corresponding to the BIOS source file to be updated in the virtual address space of the second user process; before mapping a configuration space of a target system included in a CPU to a third virtual address space of a third user process to obtain a mapping relation between the configuration space and the third virtual address space, allocating a third virtual address space to the configuration space in the virtual address space of the third user process.
For the controller included in the CPU: the CPU includes many controllers, such as general purpose Input/Output (GPIO) controllers and Flash controllers, so that in an actual implementation process, one controller may be selected from the CPU as a target controller, and a configuration space of the target controller is mapped to a third virtual address space of a third user process. The target controller is a controller for storing type information of a memory chip of the BIOS.
Optionally, the type information of the memory chip storing the BIOS may be obtained by the GPIO controller, and at this time, at least the configuration space of the GPIO controller needs to be mapped to a third virtual address space of a third user process. The type information of the Flash chip storing the BIOS may be 0 or 1, for example, when the type of the Flash chip storing the BIOS is an SPI Flash chip corresponding to a Serial Peripheral Interface (SPI for short), a flag bit 0 is stored in the GPIO controller at this time, and when the type of the Flash chip storing the BIOS is an LPC Flash chip corresponding to a Low Pin Count bus (LPC for short), a flag bit 1 is stored in the GPIO controller; the type of the memory chip can be determined through the flag bit stored in the GPIO controller.
Step S202, reading the type information of the storage chip stored in the target controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the storage chip;
specifically, through the mapping relationship between the configuration space of the target controller and the third virtual address space, the physical address of the configuration space is accessed under the user space, and the type information of the memory chip is read from the configuration space. Wherein, the physical address of the type information of the memory chip stored in the target controller is input by the user through the interface of the computer or the like.
If the target controller is a GPIO controller, reading the type information of the storage chip stored in the target controller according to the mapping relation between the configuration space and the third virtual address space, wherein the reading of the type information of the storage chip stored in the GPIO controller according to the mapping relation between the configuration space and the third virtual address space is included, and the type of the storage chip is obtained.
Step S203, reading the BIOS source file to be updated according to the mapping relationship between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the memory chip by using a programming protocol corresponding to the type of the memory chip according to the mapping relationship between the first physical space and the first virtual address space.
Specifically, the second physical space is accessed under the user space through the mapping relation between the second physical space and the second virtual address space, and the BIOS source file to be updated is read from the second physical space; and then, the read BIOS source file to be updated is programmed into the storage chip according to the mapping relation between the first physical space and the first virtual address space, so that the updating of the BIOS is realized.
If the target controller is a GPIO controller, according to the mapping relation between the first physical space and the first virtual address space, a burning protocol corresponding to the type of the storage chip is adopted to burn and write the read BIOS source file to be updated to the storage chip, and the method comprises the following steps:
if the type information of the storage chip read from the GPIO controller is first information, writing a BIOS source file to be updated to the storage chip by adopting an SPI (serial peripheral interface) burning protocol according to the mapping relation between the first physical space and the first virtual address space; the first information is used for indicating that the type of the storage chip is SPI Flash.
If the type information of the memory chip read from the GPIO controller is second information, writing a BIOS source file to be updated to the memory chip by adopting an LPC (linear predictive coding) burning protocol according to the mapping relation between the first physical space and the first virtual address space; the second information is used for indicating that the type of the storage chip is LPC Flash.
In the embodiment, the configuration space of the target controller of the CPU is mapped to the virtual address space of the third user process to establish a mapping relationship, and according to the mapping relationship, the type information of the memory chip stored in the target controller of the CPU is accessed in the user space, and the type information of the memory chip can be obtained without a cumbersome copy process.
In addition, when the type of the memory chip is newly added, the BIOS code does not need to be changed, and only the program code corresponding to the BIOS updating method needs to be changed, which is simple and convenient for a user familiar with the Linux system.
Further, in order to prevent the erroneous writing caused by the fact that the writing protocol corresponding to the type of the memory chip does not support the current memory chip, the embodiment is improved on the basis of the previous embodiment, and fig. 3 is a flowchart of a BIOS updating method under the Linux operating system provided by the present application, referring to fig. 3, where the method of the embodiment may include:
step S301, mapping a first physical space of a memory chip storing the BIOS to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, mapping a second physical space storing a source file of the BIOS to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space, and mapping a configuration space of a target controller included in a CPU to a third virtual address space to obtain a mapping relation between the configuration space and the third virtual address space; the target controller is a controller which stores the type information of the memory chip, and the type information of the memory chip is used for indicating the type of the memory chip; mapping a control space of a controller of the storage chip to a fourth virtual address space to obtain a mapping relation between the control space and the fourth virtual address space;
step S302, reading the type information of the storage chip stored in the target controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the storage chip;
step S303, reading the manufacturer and the identifier of the storage chip stored in the control space according to the mapping relation between the control space and the fourth virtual address space;
the manufacturer and the mark of the memory chip adopt a burning protocol corresponding to the type of the memory chip.
Step S304, judging whether the manufacturer and the identification of the memory chip have a preset manufacturer and identification set, if so, reading the BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the memory chip by adopting a programming protocol corresponding to the type of the memory chip according to the mapping relation between the first physical space and the first virtual address space.
Optionally, after the Linux operating system is started, the Linux operating system allocates a corresponding virtual address space to each process; accordingly, the first virtual address space may be composed of a segment of virtual addresses in the virtual address space of the first user process, the second virtual address space may be composed of a segment of virtual addresses in the virtual address space of the second user process, the third virtual address space may be composed of a segment of virtual addresses in the virtual address space of the third user process, and the fourth virtual address space may be composed of a segment of virtual addresses in the virtual address space of the fourth user process.
Mapping the control space of the controller of the storage chip to a fourth virtual address space of a fourth user process to obtain a mapping relation between the control space and the fourth virtual address space: specifically, the mapping relationship between the control space and a fourth virtual address space is obtained by calling a mmap function to map the control space of the controller of the memory chip to the fourth virtual address space of a fourth user process. The control space is a space formed by physical addresses corresponding to a control register of the memory chip controller; the fourth virtual address space is comprised of a segment of virtual addresses in the virtual address space of the fourth user process. Optionally, the first virtual address space is contiguous, the second virtual address space is contiguous, the third virtual address space is contiguous, and the fourth virtual address space is contiguous; the first user process, the second user process, the third user process and the fourth user process may be different processes.
And before the control space of the controller of the storage chip is mapped to a fourth virtual address space of a fourth user process to obtain the mapping relation between the control space and the fourth virtual address space, allocating the fourth virtual address space to the control space in the virtual address space of the fourth user process.
The rest of the content in step S301 is the same as step S201, and step S302 is the same as step S202, which is not described again in this embodiment.
In step S303, the physical address of the control space is accessed in the user space through the mapping relationship between the control space of the controller and the fourth virtual address space, and the manufacturer and the identifier of the memory chip are read from the control space. The physical addresses of the manufacturer and the identification of the memory chip stored in the controller of the memory chip are input by a user through an interface of a computer or the like.
If the type of the memory chip is an SPI Flash chip, the manufacturer and the identification of the memory chip are read from the memory by adopting an SPI protocol, and if the type of the memory chip is an LPC Flash chip, the manufacturer and the identification of the memory chip are read from the memory by adopting an LPC protocol. The SPI protocol and the LPC protocol are protocols in the prior art, and are not described in detail in this embodiment. In addition, the identifier of the memory chip may be a model of the memory chip.
For step S304, the preset manufacturer and manufacturer identifier collectively stored and the manufacturer and identifier identified as the manufacturer and identifier of the memory chip supported by the burning protocol corresponding to the type of the memory chip. If the manufacturer and the identifier of the read current memory chip have a preset manufacturer and identifier set, the burning protocol corresponding to the type of the memory chip is considered to be capable of burning the current memory chip, and a subsequent burning process is carried out; and if the read manufacturer and the read identifier of the current memory chip do not have the preset manufacturer and identifier set, determining that the burning protocol corresponding to the type of the memory chip can not burn the current memory chip, and exiting the process.
In the embodiment, by reading the manufacturer and the identifier of the memory chip, the error burning caused by the fact that the burning protocol corresponding to the type of the memory chip does not support the memory chip is prevented.
Further, the fourth virtual address space is a virtual address space corresponding to the control space of the memory chip, and the control space of the memory chip may further include controller information of the memory chip, at this time, the Linux operating system may further access the controller of the memory chip through the fourth virtual address space of the fourth user process, and the read BIOS source file to be updated is programmed to the memory chip through the controller information and the mapping relationship between the first physical space and the first virtual address space; the scheme is mainly applied to the condition that the type of the storage chip is LPC Flash.
Fig. 4 is a first schematic structural diagram of an updating apparatus of a BIOS in a Linux operating system according to the present application, as shown in fig. 4, the apparatus of the present embodiment may include: a mapping module 41 and a programming module 42.
The mapping module 41 is configured to map a first physical space of a memory chip storing the BIOS to a first virtual address space to obtain a mapping relationship between the first physical space and the first virtual address space, and map a second physical space storing a BIOS source file to be updated to a second virtual address space to obtain a mapping relationship between the second physical space and the second virtual address space.
And the programming module 42 is configured to read a BIOS source file to be updated according to a mapping relationship between the second physical space and the second virtual address space, and to program the read BIOS source file to be updated to the storage chip according to a mapping relationship between the first physical space and the first virtual address space.
The apparatus of this embodiment may be configured to implement the technical solutions of the above method embodiments, and the implementation principles and technical effects are similar, which are not described herein again.
In a possible design, the mapping module 41 is further configured to map a configuration space of a target controller included in the CPU to a third virtual address space, so as to obtain a mapping relationship between the configuration space and the third virtual address space; the target controller is a controller which stores type information of the memory chip, and the type information of the memory chip is used for indicating the type of the memory chip;
in a possible design, the programming module 42 is specifically configured to, according to a mapping relationship between the configuration space and the third virtual address space, read type information of the memory chip stored in the target controller, to obtain a type of the memory chip;
reading a BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip by adopting a programming protocol corresponding to the type of the storage chip according to the mapping relation between the first physical space and the first virtual address space.
In a possible design, if the target controller is a GPIO controller, the programming module 42 is specifically configured to: reading the type information of the memory chip stored in the GPIO controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the memory chip; if the read type information of the memory chip is first information, writing the read BIOS source file to be updated to the memory chip by adopting an SPI (serial peripheral interface) burning protocol according to the mapping relation between the first physical space and the first virtual address space; the first information is used for indicating that the type of the memory chip is SPI Flash; if the read type information of the storage chip is second information, writing the read BIOS source file to be updated to the storage chip by adopting an LPC (Linear predictive coding) burning protocol according to the mapping relation between the first physical space and the space; the second information is used for indicating that the type of the storage chip is LPC Flash.
In a possible design, the mapping module 41 is further configured to map a control space of a controller of the memory chip to a fourth virtual address space, so as to obtain a mapping relationship between the control space and the fourth virtual address space.
Correspondingly, the programming module 42 is further configured to read a manufacturer and an identifier of the memory chip stored in the controller of the memory chip according to a mapping relationship between the control space and the fourth virtual address space; and the number of the first and second groups,
and judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set, wherein the obtained judgment result is yes.
The apparatus of this embodiment may be configured to implement the technical solutions of the above method embodiments, and the implementation principles and technical effects are similar, which are not described herein again.
Fig. 5 is a schematic structural diagram of a second structure of the update apparatus of the BIOS in the Linux operating system according to the present application, and as shown in fig. 5, the apparatus of the present embodiment may further include, on the basis of the apparatus structure shown in fig. 4: a dispensing module 43.
The allocating module 43 is configured to open the BIOS source file to be updated before mapping a second physical space storing the BIOS source file to be updated to a second virtual address space to obtain a mapping relationship between the first virtual address space and the second physical space; distributing a second virtual address space for a second physical space for storing the BIOS source file to be updated in the virtual address space; and the number of the first and second groups,
before a first physical space of a memory chip for storing BIOS is mapped to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, allocating the first virtual address space to the first physical space of the memory chip in the virtual address space; and the number of the first and second groups,
before mapping a configuration space of a target controller included in a CPU to a third virtual address space to obtain a mapping relation between the configuration space and the third virtual address space, allocating the third virtual address space to the configuration space in the virtual address space; and the number of the first and second groups,
and before mapping a control space of a controller of the memory chip to a fourth virtual address space to obtain a mapping relation between the control space and the fourth virtual address space, allocating the fourth virtual address space to the control space in the virtual address space.
The apparatus of this embodiment may be configured to implement the technical solutions of the above method embodiments, and the implementation principles and technical effects are similar, which are not described herein again.
An embodiment of the present application further provides an electronic device, including: a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the steps of the method corresponding to any of the above-described method embodiments.
The present application provides a computer-readable storage medium, where instructions are stored on the computer-readable storage medium, and when the instructions are executed by a processor, the instructions implement the steps of the method corresponding to any of the above method embodiments.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. A method for updating a BIOS in a Linux operating system is characterized by comprising the following steps:
mapping a first physical space of a memory chip for storing a Basic Input Output System (BIOS) to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space for storing a BIOS source file to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space;
reading a BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and writing the read BIOS source file to be updated to the storage chip according to the mapping relation between the first physical space and the first virtual address space.
2. The method of claim 1, further comprising:
mapping a configuration space of a target controller included in a Central Processing Unit (CPU) to a third virtual address space to obtain a mapping relation between the configuration space and the third virtual address space; the target controller is a controller which stores type information of the memory chip, and the type information of the memory chip is used for indicating the type of the memory chip;
reading a BIOS source file to be updated according to the mapping relationship between the second physical space and the second virtual address space, and writing the read BIOS source file to be updated to the memory chip according to the mapping relationship between the first physical space and the first virtual address space, including:
reading the type information of the storage chip stored in the target controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the storage chip;
reading a BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip by adopting a programming protocol corresponding to the type of the storage chip according to the mapping relation between the first physical space and the first virtual address space.
3. The method of claim 2, further comprising:
mapping a control space of a controller of the memory chip to a fourth virtual address space to obtain a mapping relation between the control space and the fourth virtual address space;
before writing the read BIOS source file to be updated to the memory chip by using a writing protocol corresponding to the type of the memory chip according to the mapping relationship between the first physical space and the first virtual address space, the method further includes:
reading a manufacturer and an identifier of the memory chip stored in a controller of the memory chip according to the mapping relation between the control space and the fourth virtual address space;
and judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set, wherein the obtained judgment result is yes.
4. The method according to claim 2, wherein the target controller is a general purpose input output GPIO controller, and the reading the type information of the memory chip stored in the target controller according to the mapping relationship between the configuration space and the third virtual address space to obtain the type of the memory chip includes:
reading the type information of the memory chip stored in the GPIO controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the memory chip;
the programming, according to the mapping relationship between the first physical space and the first virtual address space, the read BIOS source file to be updated to the memory chip by using a programming protocol corresponding to the type of the memory chip includes:
if the read type information of the memory chip is first information, writing the read BIOS source file to be updated to the memory chip by adopting a Serial Peripheral Interface (SPI) burning protocol according to the mapping relation between the first physical space and the first virtual address space; the first information is used for indicating that the type of the memory chip is SPI Flash;
if the read type information of the storage chip is second information, writing the read BIOS source file to be updated to the storage chip by adopting a short pin count bus LPC burning protocol according to the mapping relation between the first physical space and the space; the second information is used for indicating that the type of the storage chip is LPC Flash.
5. The method according to claim 3, wherein before mapping a second physical space storing the BIOS source file to be updated to a second virtual address space to obtain a mapping relationship between the first virtual address space and the second physical space, the method further comprises:
opening the BIOS source file to be updated;
distributing a second virtual address space for a second physical space for storing the BIOS source file to be updated in the virtual address space;
before mapping a first physical space of a memory chip storing the BIOS to a first virtual address space to obtain a mapping relationship between the first physical space and the first virtual address space, the method further includes:
allocating a first virtual address space for a first physical space of the memory chip in a virtual address space;
before mapping a configuration space of a target controller included in a CPU to a third virtual address space to obtain a mapping relationship between the configuration space and the third virtual address space, the method further includes:
allocating the third virtual address space in a virtual address space for the configuration space;
before mapping a control space of a controller of the memory chip to a fourth virtual address space to obtain a mapping relationship between the control space and the fourth virtual address space, the method further includes:
allocating the fourth virtual address space in a virtual address space for the control space.
6. An updating device of BIOS in Linux operating system is characterized in that the device comprises:
the mapping module is used for mapping a first physical space of a memory chip for storing a Basic Input Output System (BIOS) to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space for storing a BIOS source file to be updated to a second virtual address space to obtain a mapping relation between the second physical space and the second virtual address space;
and the programming module is used for reading the BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip according to the mapping relation between the first physical space and the first virtual address space.
7. The apparatus of claim 6, wherein the mapping module is further configured to,
mapping a configuration space of a target controller included in a Central Processing Unit (CPU) to a third virtual address space to obtain a mapping relation between the configuration space and the third virtual address space; the target controller is a controller which stores type information of the memory chip, and the type information of the memory chip is used for indicating the type of the memory chip;
the programming module is specifically configured to,
reading the type information of the storage chip stored in the target controller according to the mapping relation between the configuration space and the third virtual address space to obtain the type of the storage chip;
reading a BIOS source file to be updated according to the mapping relation between the second physical space and the second virtual address space, and programming the read BIOS source file to be updated to the storage chip by adopting a programming protocol corresponding to the type of the storage chip according to the mapping relation between the first physical space and the first virtual address space.
8. The apparatus of claim 7, wherein the mapping module is further configured to,
mapping a control space of a controller of the memory chip to a fourth virtual address space to obtain a mapping relation between the control space and the fourth virtual address space;
the programming module is further configured to read a manufacturer and an identifier of the memory chip stored in a controller of the memory chip according to a mapping relationship between the control space and the fourth virtual address space; and the number of the first and second groups,
and judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set, wherein the obtained judgment result is yes.
9. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the steps of any of the methods of claims 1-5.
10. A computer-readable storage medium having stored thereon instructions which, when executed by a processor, carry out the steps of any of the methods of claims 1-5.
CN201810961527.9A 2018-08-22 2018-08-22 Method and device for updating BIOS (basic input output System) in Linux operating system Pending CN110858145A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810961527.9A CN110858145A (en) 2018-08-22 2018-08-22 Method and device for updating BIOS (basic input output System) in Linux operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810961527.9A CN110858145A (en) 2018-08-22 2018-08-22 Method and device for updating BIOS (basic input output System) in Linux operating system

Publications (1)

Publication Number Publication Date
CN110858145A true CN110858145A (en) 2020-03-03

Family

ID=69636053

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810961527.9A Pending CN110858145A (en) 2018-08-22 2018-08-22 Method and device for updating BIOS (basic input output System) in Linux operating system

Country Status (1)

Country Link
CN (1) CN110858145A (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1584822A (en) * 2003-08-19 2005-02-23 联想(北京)有限公司 Method for upgrated computer fixing ware programm
US20050193169A1 (en) * 2004-03-01 2005-09-01 Ahluwalia Manish K. Memory management
CN101944011A (en) * 2010-06-29 2011-01-12 北京中星微电子有限公司 Device, chip and method for running program
CN103064692A (en) * 2011-10-19 2013-04-24 北京市三希电子科技开发公司 Firmware update method and firmware update device
CN103984581A (en) * 2014-05-30 2014-08-13 乐视致新电子科技(天津)有限公司 Firmware upgrading method and device of chip
CN105677597A (en) * 2014-11-20 2016-06-15 中兴通讯股份有限公司 Data writing method and device
CN106502733A (en) * 2016-10-12 2017-03-15 广东乐源数字技术有限公司 A kind of method of mobile terminal firmware modification
CN107391170A (en) * 2017-06-14 2017-11-24 深圳市共进电子股份有限公司 Support multivariant upgrade method, device and computer equipment
CN108062253A (en) * 2017-12-11 2018-05-22 北京奇虎科技有限公司 The communication means of a kind of kernel state and User space, device and terminal
CN108197038A (en) * 2018-02-01 2018-06-22 深圳市风云实业有限公司 A kind of Linux data transmission methods, device and user terminal

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1584822A (en) * 2003-08-19 2005-02-23 联想(北京)有限公司 Method for upgrated computer fixing ware programm
US20050193169A1 (en) * 2004-03-01 2005-09-01 Ahluwalia Manish K. Memory management
CN101944011A (en) * 2010-06-29 2011-01-12 北京中星微电子有限公司 Device, chip and method for running program
CN103064692A (en) * 2011-10-19 2013-04-24 北京市三希电子科技开发公司 Firmware update method and firmware update device
CN103984581A (en) * 2014-05-30 2014-08-13 乐视致新电子科技(天津)有限公司 Firmware upgrading method and device of chip
CN105677597A (en) * 2014-11-20 2016-06-15 中兴通讯股份有限公司 Data writing method and device
CN106502733A (en) * 2016-10-12 2017-03-15 广东乐源数字技术有限公司 A kind of method of mobile terminal firmware modification
CN107391170A (en) * 2017-06-14 2017-11-24 深圳市共进电子股份有限公司 Support multivariant upgrade method, device and computer equipment
CN108062253A (en) * 2017-12-11 2018-05-22 北京奇虎科技有限公司 The communication means of a kind of kernel state and User space, device and terminal
CN108197038A (en) * 2018-02-01 2018-06-22 深圳市风云实业有限公司 A kind of Linux data transmission methods, device and user terminal

Similar Documents

Publication Publication Date Title
US6754793B2 (en) Method for flashing ESCD and variables into a ROM
US6401198B1 (en) Storing system-level mass storage configuration data in non-volatile memory on each mass storage device to allow for reboot/power-on reconfiguration of all installed mass storage devices to the same configuration as last use
KR101602360B1 (en) System fast booting apparatus and method
WO2017020647A1 (en) Novel storage-based embedded file system and realization method thereof
US20100169546A1 (en) Flash memory access circuit
CN105718281A (en) Touch screen firmware upgrading method and device
CN113741792B (en) Method for storing data by singlechip, singlechip and readable storage medium
CN107045423B (en) Memory device and data access method thereof
CN114153779A (en) I2C communication method, system, equipment and storage medium
CN113377392B (en) System capable of updating firmware in background and method for updating firmware in background
US7958344B2 (en) Method for adjusting set-up default value of bios and mainboard using the same method
US6738887B2 (en) Method and system for concurrent updating of a microcontroller's program memory
CN116578327B (en) Program updating method and device, electronic equipment and storage medium
CN110825421B (en) Firmware upgrading method, system and readable storage medium
CN109408226A (en) Data processing method, device and terminal device
JP2016143422A (en) Configuring serial devices
CN110688141A (en) Firmware updating method
KR100223844B1 (en) Option circuit
US7234039B1 (en) Method, system, and apparatus for determining the physical memory address of an allocated and locked memory buffer
CN110858145A (en) Method and device for updating BIOS (basic input output System) in Linux operating system
US8122205B2 (en) Structured virtual registers for embedded controller devices
JP4735765B2 (en) Linux program startup system
TW202013183A (en) High efficiency garbage collection method, and associated data storage device and controller thereof
CN111966285B (en) Method, main control chip and system for storing data into EEPROM
JP2000276461A (en) Microcomputer

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing

Applicant after: Loongson Zhongke Technology Co.,Ltd.

Address before: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing

Applicant before: LOONGSON TECHNOLOGY Corp.,Ltd.

CB02 Change of applicant information