CN110858145B - BIOS updating method and device under Linux operating system - Google Patents

BIOS updating method and device under Linux operating system Download PDF

Info

Publication number
CN110858145B
CN110858145B CN201810961527.9A CN201810961527A CN110858145B CN 110858145 B CN110858145 B CN 110858145B CN 201810961527 A CN201810961527 A CN 201810961527A CN 110858145 B CN110858145 B CN 110858145B
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.)
Active
Application number
CN201810961527.9A
Other languages
Chinese (zh)
Other versions
CN110858145A (en
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/CN110858145B/en
Publication of CN110858145A publication Critical patent/CN110858145A/en
Application granted granted Critical
Publication of CN110858145B publication Critical patent/CN110858145B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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 BIOS updating method and device under a Linux operating system, wherein the method comprises the following steps: mapping a first physical space of a memory chip 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 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 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 according to the mapping relation between the first physical space and the first virtual address space. The BIOS updating method is convenient to operate and high in updating speed.

Description

BIOS updating method and device under 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 (Basic Input Output System, BIOS for short) is a standard firmware interface, which is a set of programs that are solidified on a Read Only Memory (ROM) chip on the computer motherboard, and which stores the basic input/output program of the computer, the system setup information, the self-checking program after power-on, and the system self-starting program. Its main function is to provide the lowest, most direct hardware setup and control for the computer. The Linux operating system is a free-to-use and freely-spread multi-user-like multitasking (Uniplexed Information and Computering System, abbreviated as UNIX) operating system, which is a multi-user, multitasking, multi-thread supporting and multi-central processing unit (Central Processing Unit, abbreviated as CPU) operating system based on POSIX and UNIX.
Since there is no disk operating system (Disk Operating System, abbreviated as DOS) in the Linux operating system, the Linux operating system cannot update the BIOS through the DOS like the Windows operating system. There are two methods for updating BIOS in Linux operating system at present: one is to take down the Flash chip with BIOS stored therein to burn on a special burner; the other is to write by proprietary commands under the BIOS command line.
Aiming at the first BIOS updating method, the Flash chip can be taken out only by opening the case, so that the operation of updating the BIOS is time-consuming; for the second BIOS updating method, the operating system needs to be restarted, a BIOS command line is entered, and a specific command is executed to update the BIOS, so that the method is difficult to realize in a scene that a machine cannot be restarted on a client site, and in addition, if a new Flash model is added, the BIOS code needs to be modified, so that the difficulty is relatively high for engineers unfamiliar with the BIOS code.
Disclosure of Invention
The application provides a BIOS updating method under a Linux operating system, which aims to solve the technical problems that the BIOS updating operation 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 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 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 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 according to the mapping relation between the first physical space and the first virtual address space.
In one possible design, the method further comprises:
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 storing type information of the memory chip, wherein 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 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 according to the mapping relation between the first physical space and the first virtual address space, wherein the method comprises the following steps:
Reading the type information of the memory 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 memory chip;
and 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 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.
In one possible design, the method further comprises:
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;
And before the read BIOS source file to be updated is programmed into the memory chip by adopting 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, the method further comprises:
reading manufacturer and identification 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;
Judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set, and judging whether the obtained judgment result is yes.
In one possible design, the target controller is a 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 writing the read BIOS source file to be updated to the memory chip by adopting 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 includes:
if the read type information of the memory chip is first information, the read BIOS source file to be updated is programmed to the memory chip by adopting a serial peripheral interface SPI programming 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 memory chip is second information, the read BIOS source file to be updated is programmed to the memory chip by adopting a short pin count bus (LPC) programming 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 memory 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;
allocating a second virtual address space for a second physical space storing the BIOS source file to be updated in the virtual address space;
before mapping the first physical space of the memory chip storing the BIOS to the first virtual address space to obtain the mapping relation between the first physical space and the first virtual address space, the method further comprises:
Allocating a first virtual address space in a virtual address space for a first physical space of the memory chip;
Before mapping the configuration space of the target controller included in the CPU to the third virtual address space to obtain the mapping relation 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 the control space of the 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:
The fourth virtual address space is allocated in a virtual address space for the control space.
In a second aspect, an embodiment of the present application provides a device 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 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 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 also used 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 storing type information of the memory chip, wherein the type information of the memory chip is used for indicating the type of the memory chip;
the programming module is particularly used for programming the electronic device,
Reading the type information of the memory 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 memory chip;
and 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 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.
In one possible design, the mapping module is also used 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 the controller of the memory chip according to a mapping relationship 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, and judging whether 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 in any of the possible designs of the first aspect.
In a fourth aspect, the application provides a computer readable storage medium having stored thereon instructions which when executed by a processor perform the steps of the method of any of the possible designs of the first aspect.
According to the application, both the physical space of the storage 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 as the virtual address space belongs to the user space, 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 the user state, so that the information in the BIOS source file to be updated can be read in the virtual address space and the read BIOS source file to be updated is written into the storage chip through the mapping relation, and the updating rate of the BIOS is improved without complicated copying process; meanwhile, the BIOS is updated in the user space, and the operation in the user space does not need to restart the operating system, namely the normal operation of the computer is not affected, so that the BIOS updating method of the embodiment can update the BIOS in the normal operation state of the computer, does not need to take out a memory chip, restart the electronic equipment such as the computer and the like, and is convenient to operate.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions of the prior art, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it will be obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort to a person skilled in the art.
FIG. 1 is a flowchart illustrating a method for updating BIOS in a Linux operating system according to the present application;
FIG. 2 is a flowchart II of a BIOS update method under a Linux operating system provided by the present application;
FIG. 3 is a flowchart of a BIOS update method under a Linux operating system according to the present application;
FIG. 4 is a schematic diagram of a BIOS update device under a Linux operating system according to the present application;
FIG. 5 is a schematic diagram of a BIOS updating device under a Linux operating system according to the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Fig. 1 is a flowchart of a method for updating a BIOS under a Linux operating system according to the present application, as shown in fig. 1, the method in this embodiment may include:
Step S101, mapping a first physical space of a memory chip storing 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 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;
Specifically, the specific implementation of this step is: opening a full mirror (/ dev/mem) device of a physical memory, calling a mmap function to map a first physical space of a memory chip storing a 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 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.
The physical space of the memory chip refers to a space formed by all physical addresses of the memory chip; the second physical space storing the BIOS source file to be updated refers to a space formed by storing a physical address of the BIOS source file to be updated in a corresponding storage device (such as a disk). The memory chip may be a Flash chip, or may be an electrically erasable programmable read-only memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ ONLY MEMORY, abbreviated as EEPROM), or may be another chip with a memory function, which is not described herein.
Optionally, after the Linux operating system is started, the operating system allocates a corresponding virtual address space for each process; accordingly, the first virtual address space may be formed by a segment of virtual addresses in the virtual address space of the first user process, and the second virtual address space may be formed by a segment of virtual addresses in the virtual address space of the second user process, optionally the first virtual address space is contiguous and the second virtual address space is also contiguous. 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 storing the BIOS is mapped to the virtual address space corresponding to the first user process, the mapping is only needed once, and the mapping is not needed for a plurality of times; and mapping the second physical space storing the BIOS source file to be updated to the virtual address space corresponding to the second user process only once without performing multiple mapping.
Further, before mapping the first physical space of the memory chip storing the BIOS to the first virtual address space of the first user process to obtain a mapping relationship between the first physical space and the first virtual address space, the first virtual address space is allocated 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 storing a BIOS source file to be updated to a second virtual address space of a second user process to obtain a mapping relationship between the second physical space and the second virtual address space, the BIOS source file to be updated needs to be opened, and the second virtual address space is allocated for the second physical space corresponding to the BIOS source file to be updated in the virtual address space of the second user process.
The/dev/mem device can be used to access the physical memory by opening/dev/mem device, calling mmap function, mapping corresponding physical address in the physical memory to virtual address space of corresponding user process.
The mmap is a function of memory mapping files, and the function can map a file or other objects to a virtual address space of a user process, so that the one-to-one correspondence between file disk addresses and a section of virtual address in the process virtual address space is established. After the mapping relation is realized, the user process can perform read-write operation on the virtual memory corresponding to the section of virtual address in a pointer mode, and the system can automatically write back the dirty page to the corresponding file disk, so that 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 programming the read BIOS source file to be updated to the memory chip according to the mapping relation between the first physical space and the first virtual address space.
Specifically, accessing a second physical space under the user space through the mapping relation between the second physical space and the second virtual address space, and reading a BIOS source file to be updated from the second physical space; and then, the read BIOS source file to be updated is programmed into the memory 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.
According to the embodiment, the physical space of the storage 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, 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 the user state, namely, the physical space of the storage chip for storing the BIOS and the physical space for storing the BIOS source file to be updated can be accessed through the established mapping relation in the user state, so that information in the BIOS source file to be updated can be read through the mapping relation in the virtual address space, and the read BIOS source file to be updated is written into the storage chip without complicated copying process, and the updating rate of the BIOS is improved; meanwhile, the BIOS is updated in the user space, and the operation in the user space does not need to restart the operating system, namely the normal operation of the computer is not affected, so that the BIOS updating method of the embodiment can update the BIOS in the normal operation state of the computer, does not need to take out a memory chip, restart the electronic equipment such as the computer and the like, and is convenient to operate.
The method for updating the BIOS under the Linux operating system of the embodiment comprises the following steps: mapping a first physical space of a memory chip for storing 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 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 according to the mapping relation between the first physical space and the first virtual address space. The updating method of the BIOS under the Linux operating system of the embodiment is convenient to operate and high in updating speed.
When the memory chip is a Flash chip, since the Flash chip has different types, the different types correspond to different burning protocols, in order to prevent the user from adopting an error burning protocol to burn when the type of the Flash chip is not known in advance, the embodiment is improved on the basis of the previous embodiment.
Fig. 2 is a flowchart of a method for updating a BIOS under a Linux operating system according to the present application, as shown in fig. 2, the method in this embodiment may include:
step S201, mapping a first physical space of a memory chip storing a 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 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 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 storing 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 specific implementation of this step is: the method comprises the steps of opening/dev/mem equipment, calling a mmap function to map a first physical space of a storage chip storing a 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 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 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 configuration space is a space 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 a space formed by all physical addresses of the memory chip; the second physical space storing the BIOS source file to be updated refers to a space formed by storing a physical address of the BIOS source file to be updated in a corresponding storage device (such as a disk). The memory chip may be a Flash chip, an EEPROM, or other chips with memory functions, which will not be described herein.
Optionally, after the Linux operating system is started, the operating system allocates a corresponding virtual address space for each process; correspondingly, the first virtual address space may be formed by a section of virtual address in the virtual address space of the first user process, the second virtual address space may be formed by a section of virtual address in the virtual address space of the second user process, and the third virtual address space may be formed by a section of virtual address 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 storing the BIOS is mapped to the virtual address space corresponding to the first user process, the mapping is only needed once, and the mapping is not needed for a plurality of times; when the second physical space 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 the mapping is not needed for a plurality of times; 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 once, and the mapping is not needed for a plurality of times.
It should be understood by those skilled in the art that before mapping the first physical space of the memory chip storing the BIOS to the first virtual address space of the first user process to obtain a mapping relationship between the first physical space and the first virtual address space, the first virtual address space is allocated 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 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 the 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 controller included in the 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, distributing the third virtual address space for the configuration space in the virtual address space of the third user process.
For a controller included in the CPU: the CPU includes many controllers, such as a general purpose input/output (General Purpose Input Output, abbreviated as GPIO) controller and a Flash controller, so in the 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 that stores type information of a memory chip of the BIOS.
Alternatively, the type information of the memory chip storing the BIOS may be obtained by the GPIO controller, at which time at least the configuration space of the GPIO controller needs to be mapped to the third virtual address space of the 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 (SERIAL PERIPHERAL INTERFACE, abbreviated as SPI), 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 short Pin Count bus (LPC), a flag bit 1 is stored in the GPIO controller; the type of the memory chip can be determined by the flag bit stored in the GPIO controller.
Step S202, reading the type information of the memory 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 memory chip;
Specifically, the physical address of the configuration space is accessed under the user space through the mapping relation between the configuration space of the target controller and the third virtual address 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 a user through an interface of a computer or the like.
If the target controller is a GPIO controller, 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, including reading the type information of the memory chip stored in the GPIO controller according to the mapping relationship between the configuration space and the third virtual address space, to obtain the type of the memory chip.
Step 203, 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 by adopting 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.
Specifically, accessing the second physical space under the user space through the mapping relation between the second physical space and the second virtual address space, and reading a BIOS source file to be updated from the second physical space; and then, the read BIOS source file to be updated is programmed into the memory 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 relationship between the first physical space and the first virtual address space, a read BIOS source file to be updated is programmed into the memory chip by adopting a programming protocol corresponding to the type of the memory chip, including:
If the type information of the memory chip read from the GPIO controller is first information, programming a BIOS source file to be updated to the memory chip by adopting an SPI programming 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 type information of the memory chip read from the GPIO controller is the second information, writing the BIOS source file to be updated into the memory chip by adopting an LPC (Low Power control) writing 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 memory chip is LPC Flash.
In this embodiment, the mapping relationship is established by mapping the configuration space of the target controller of the CPU to the virtual address space of the third user process, 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, so that the type information of the memory chip can be obtained without a complicated copying process, and when the type of the memory chip is not known in advance by the user while the update rate of the BIOS is improved, the type of the memory chip is known, so that the correct burning protocol is adopted for burning.
In addition, when the type of the memory chip is newly added, the BIOS code is not required to be changed, and only the program code corresponding to the BIOS updating method is required to be changed, so that the method is simple and convenient for users familiar with the Linux system.
Further, in order to prevent erroneous burning caused by that a burning protocol corresponding to the type of the memory chip does not support the current memory chip, the present embodiment is improved on the basis of the previous embodiment, and fig. 3 is a flowchart two of a method for updating a BIOS under a Linux operating system provided by the present application, referring to fig. 3, the method of the present embodiment may include:
Step S301, mapping a first physical space of a memory chip storing a 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 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 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 storing 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 memory 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 memory 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 memory chip;
step S303, reading the manufacturer and the identifier of the memory 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 identifier of the memory chip adopt a burning protocol corresponding to the type of the memory chip.
And S304, judging whether preset manufacturer and identifier sets exist in the manufacturer and the identifier of the memory chip, if so, 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 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 operating system allocates a corresponding virtual address space for each process; correspondingly, the first virtual address space may be formed by a segment of virtual address in the virtual address space of the first user process, the second virtual address space may be formed by a segment of virtual address in the virtual address space of the second user process, the third virtual address space may be formed by a segment of virtual address in the virtual address space of the third user process, and the fourth virtual address space may be formed by a segment of virtual address in the virtual address space of the fourth user process.
Mapping the control space of the controller of the memory 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 relation between the control space and the 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 the 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 formed by 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.
Before mapping a control space of a controller of the memory chip to a fourth virtual address space of a fourth user process, and obtaining a mapping relation between the control space and the fourth virtual address space, distributing the fourth virtual address space for the control space in the virtual address space of the fourth user process.
The rest of the contents in step S301 are the same as those in step S201, and step S302 is the same as that in step S202, which is not described in detail in this embodiment.
For step S303, the physical address of the control space is accessed in the user space through the mapping relationship between the control space and the fourth virtual address space of the controller, and the manufacturer and the identifier of the memory chip are read from the control space. The manufacturer of the memory chip and the identified physical address stored in the controller of the memory chip are input by a user through an interface of a computer or other equipment.
If the type of the memory chip is SPI Flash chip, the manufacturer and the identifier of the memory chip are read from the memory by adopting SPI protocol, and if the type of the memory chip is LPC Flash chip, the manufacturer and the identifier of the memory chip are read from the memory by adopting 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 identification of the memory chip may be a model number of the memory chip.
For step S304, the preset vendor and identifier are stored in a centralized manner, and the vendor and identifier are the vendor and identifier of the memory chip supported by the burning protocol corresponding to the type of the memory chip. If the read manufacturer and identification of the current memory chip have preset manufacturer and identification sets, the corresponding burning protocol of the memory chip type is considered to be capable of burning the current memory chip, and a subsequent burning flow is carried out; if the read manufacturer and identification of the current memory chip do not have the preset manufacturer and identification set, the burning protocol corresponding to the type of the memory chip is considered to be incapable of burning the current memory chip, and the process is exited.
In this embodiment, by reading the manufacturer and the identifier of the memory chip, erroneous 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 a control space of the memory chip, the control space of the memory chip may further include controller information of the memory chip, and at this time, the Linux operating system may access the controller of the memory chip through the fourth virtual address space of the fourth user process, and write the read BIOS source file to be updated 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 situation that the type of the memory chip is LPC Flash.
Fig. 4 is a schematic structural diagram of a BIOS updating device under a Linux operating system according to the present application, as shown in fig. 4, the device in this embodiment may include: a mapping module 41 and a programming module 42.
The mapping module 41 maps 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 maps 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 the mapping relationship between the second physical space and the second virtual address space, and to program the read BIOS source file to be updated into the memory chip according to the mapping relationship between the first physical space and the first virtual address space.
The device of the present embodiment may be used to execute the technical solution of the foregoing method embodiment, and its implementation principle and technical effects are similar, and are not described herein again.
In one 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, to obtain a mapping relationship between the configuration space and the third virtual address space; the target controller is a controller storing type information of the memory chip, wherein the type information of the memory chip is used for indicating the type of the memory chip;
In one possible design, the writing module 42 is specifically configured to read, according to a mapping relationship between the configuration space and the third virtual address space, type information of the memory chip stored in the target controller, to obtain a type of the memory chip;
and 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 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.
In one 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, the read BIOS source file to be updated is programmed to the memory chip by adopting an SPI programming 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 memory chip is second information, writing the read BIOS source file to be updated into the memory chip by adopting an LPC (Linear predictive coding) writing 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 memory chip is LPC Flash.
In one possible design, the mapping module 41 is further configured to map a control space of the 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.
Correspondingly, the programming module 42 is further configured to read, according to a mapping relationship between the control space and the fourth virtual address space, a manufacturer and an identifier of the memory chip stored in the controller of the memory chip; and
Judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set, and judging whether the obtained judgment result is yes.
The device of the present embodiment may be used to execute the technical solution of the foregoing method embodiment, and its implementation principle and technical effects are similar, and are not described herein again.
Fig. 5 is a schematic diagram of a second structure of a BIOS updating device under a Linux operating system according to the present application, as shown in fig. 5, where the device in this embodiment may further include, based on the device structure shown in fig. 4: a distribution module 43.
The allocation module 43 is configured to open a 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; allocating a second virtual address space for a second physical space storing the BIOS source file to be updated in the virtual address space; and
Before mapping a first physical space of a memory chip storing BIOS to a first virtual address space to obtain a mapping relation between the first physical space and the first virtual address space, distributing the first virtual address space for the first physical space of the memory chip in the virtual address space; and
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, distributing the third virtual address space for the configuration space in the virtual address space; 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, distributing the fourth virtual address space for the control space in the virtual address space.
The device of the present embodiment may be used to execute the technical solution of the foregoing method embodiment, and its implementation principle and technical effects are similar, and are not described herein again.
The embodiment of the application also provides electronic equipment, which comprises: 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 method embodiments described above.
The embodiment of the application provides a computer readable storage medium, and instructions are stored on the computer readable storage medium, and when the instructions are executed by a processor, the steps of the method corresponding to any one of the method embodiments are realized.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application.

Claims (6)

1. The BIOS updating method under the Linux operating system is characterized by comprising the following steps:
Mapping a first physical space of a memory chip storing a basic input output system BIOS to a first virtual address space of a first user process to obtain a mapping relation between the first physical space and the first virtual address space, and mapping a second physical space 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;
mapping a configuration space of a target controller included in a Central Processing Unit (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; the target controller is a controller storing type information of the memory chip, wherein 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 memory chip to a fourth virtual address space to obtain a mapping relation between the control space and the fourth virtual address space;
Reading the type information of the memory 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 memory chip;
reading manufacturer and identification 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;
Judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set or not;
If so, 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 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.
2. The method according to claim 1, wherein the target controller is a 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 writing the read BIOS source file to be updated to the memory chip by adopting 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 includes:
if the read type information of the memory chip is first information, the read BIOS source file to be updated is programmed to the memory chip by adopting a serial peripheral interface SPI programming 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 memory chip is second information, the read BIOS source file to be updated is programmed to the memory chip by adopting a short pin count bus (LPC) programming 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 memory chip is LPC Flash.
3. The method of claim 1, wherein prior to mapping a second physical space storing a BIOS source file to be updated to a second virtual address space resulting in a mapping of the first virtual address space and the second physical space, the method further comprises:
opening the BIOS source file to be updated;
allocating a second virtual address space for a second physical space storing the BIOS source file to be updated in the virtual address space;
before mapping the first physical space of the memory chip storing the BIOS to the first virtual address space to obtain the mapping relation between the first physical space and the first virtual address space, the method further comprises:
Allocating a first virtual address space in a virtual address space for a first physical space of the memory chip;
Before mapping the configuration space of the target controller included in the CPU to the third virtual address space to obtain the mapping relation 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 the control space of the 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:
The fourth virtual address space is allocated in a virtual address space for the control space.
4. A BIOS updating device under a Linux operating system, comprising:
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 of a first user process 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 of a second user process to obtain a mapping relation between the second physical space and the second virtual address space;
The mapping module is further configured to map a configuration space of a target controller included in the central processing unit CPU to a third virtual address space of a third user process, so as to obtain a mapping relationship between the configuration space and the third virtual address space; the target controller is a controller storing type information of the memory chip, wherein 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 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 used for reading the type information of the memory 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 memory chip; reading manufacturer and identification 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; judging whether the manufacturer and the identifier of the memory chip exist in a preset manufacturer and identifier set or not; if so, 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 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.
5. 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 of claims 1-3.
6. A computer readable storage medium, characterized in that it has stored thereon instructions which, when executed by a processor, implement the steps of the method of any of the preceding claims 1-3.
CN201810961527.9A 2018-08-22 2018-08-22 BIOS updating method and device under Linux operating system Active CN110858145B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810961527.9A CN110858145B (en) 2018-08-22 2018-08-22 BIOS updating method and device under Linux operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810961527.9A CN110858145B (en) 2018-08-22 2018-08-22 BIOS updating method and device under Linux operating system

Publications (2)

Publication Number Publication Date
CN110858145A CN110858145A (en) 2020-03-03
CN110858145B true CN110858145B (en) 2024-07-30

Family

ID=69636053

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810961527.9A Active CN110858145B (en) 2018-08-22 2018-08-22 BIOS updating method and device under Linux operating system

Country Status (1)

Country Link
CN (1) CN110858145B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN106502733A (en) * 2016-10-12 2017-03-15 广东乐源数字技术有限公司 A kind of method of mobile terminal firmware modification

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1584822B (en) * 2003-08-19 2010-04-21 联想(北京)有限公司 Method for updating computer fixing ware program
US20050193169A1 (en) * 2004-03-01 2005-09-01 Ahluwalia Manish K. Memory management
CN105677597A (en) * 2014-11-20 2016-06-15 中兴通讯股份有限公司 Data writing method and device
CN107391170B (en) * 2017-06-14 2021-01-22 深圳市共进电子股份有限公司 Upgrading method and device supporting multiple schemes 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 (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN106502733A (en) * 2016-10-12 2017-03-15 广东乐源数字技术有限公司 A kind of method of mobile terminal firmware modification

Also Published As

Publication number Publication date
CN110858145A (en) 2020-03-03

Similar Documents

Publication Publication Date Title
EP3764237B1 (en) System startup method and apparatus, electronic device and storage medium
US6754793B2 (en) Method for flashing ESCD and variables into a ROM
KR100531192B1 (en) Non-volatile memory control method
KR101602360B1 (en) System fast booting apparatus and method
CN105718281B (en) A kind of touch screen firmware upgrade method and device
TWI743709B (en) System capable of upgrading firmware in background and method for upgrading firmware in background
US20100169546A1 (en) Flash memory access circuit
KR20150100075A (en) Method of updating firmware of memory device including memory and controller
CN113741792B (en) Method for storing data by singlechip, singlechip and readable storage medium
CN111475215A (en) Server starting method, device and related equipment
US7958344B2 (en) Method for adjusting set-up default value of bios and mainboard using the same method
KR20170037017A (en) Memory Upgrade System And Method
US6738887B2 (en) Method and system for concurrent updating of a microcontroller's program memory
CN111783163B (en) Method and device for realizing host protection area and electronic equipment
CN109408226A (en) Data processing method, device and terminal device
CN110825421B (en) Firmware upgrading method, system and readable storage medium
CN110858145B (en) BIOS updating method and device under Linux operating system
US8122205B2 (en) Structured virtual registers for embedded controller devices
US20230289192A1 (en) Reversible virtual factory reset
CN102109965A (en) Flash memory storage system, flash memory controller, computer system and simulation method
CN102023873B (en) Application program execution method and system, storage media controller and storage device
CN112148203B (en) Memory management method, device, electronic equipment and storage medium
JP2010282645A (en) Linux program start-up 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

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
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.

GR01 Patent grant
GR01 Patent grant