Method and apparatus for executing bootloader
The bootloader execution device verifies boot table integrity by using CRC checks and retries, addressing discrepancies in boot table copies and ensuring system stability.
Patent Information
- Application Number
- KR1020240145127
- Authority / Receiving Office
- KR · KR
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2044-10-22
AI Technical Summary
Existing bootloader programs struggle to verify the integrity of boot table copies from non-volatile ROM to volatile RAM due to coding simplicity and the difficulty of performing integrity checks during RAM stabilization, leading to potential discrepancies and system abnormalities.
A method and apparatus that includes a bootloader execution device with a ROM containing a bootloader area, boot table area, boot BIT code area, and a tag area storing CRC, which performs CRC calculations on these areas before and after copying to RAM, allowing for integrity checks and retries if discrepancies are detected.
Ensures the integrity of boot table copies by verifying the copy process and allowing retries, preventing system failures and enabling detection of ROM or RAM defects.
Smart Images

Figure 112024115120279-PAT00002_ABST
Abstract
Description
Technology Field
[0001] This description relates to a bootloader execution method and device. Background Technology
[0002] Generally, the booting process of an embedded system can be divided into the device hardware initialization process, the boot table copying process, and the runtime library execution process, and these processes are executed by a bootloader program written by a developer. Among these, the boot table copying process is responsible for transferring data written to non-volatile ROM (Read Only Memory), such as flash memory, to volatile RAM (Random Access Memory), such as DDR3 (Double Data Rate version 3) memory.
[0003] Because bootloader programs execute before runtime libraries, they are subject to many coding constraints; consequently, they are generally configured to be as simple as possible, excluding Built-In Tests (BITs). Furthermore, since the boot table is loaded into RAM in separate regions and the data can change depending on program execution, integrity checks such as Cyclic Redundancy Checks (CRCs) are difficult to perform after the main program has entered. Therefore, traditionally, BITs were performed by calculating the CRC of the flash memory data within the main program and comparing it with the CRC recorded in the flash memory, without a procedure to verify the integrity of the memory copy results within the bootloader. However, if the root table is copied while the RAM is not yet stabilized, discrepancies may occur between the source data written to ROM and the data copied to RAM. In fact, when multiple identical embedded system products were manufactured, the RAM stabilization times varied slightly from product to product.
[0004] As such, if the source data written to ROM and the data copied to RAM do not match, booting proceeds as is and the bootloader program is executed, incorrect commands may be executed, causing the system to be forcibly shut down or operate abnormally. The problem to be solved
[0005] At least one of the embodiments may provide a bootloader execution method and apparatus capable of verifying the integrity of a boot table copy. means of solving the problem
[0006] According to one embodiment, a method for a processor to execute a bootloader may be provided. The bootloader execution method includes the step of copying a boot table stored in ROM (Read-Only Memory) to RAM (Random Access Memory) when power is applied, and the step of checking the integrity of the copy of the boot table.
[0007] The above ROM may include a bootloader area, a boot table area where the boot table is stored, a boot BIT (Built-In-Test) code area for integrity checks on the copy of the boot table, and a tag area where a CRC (Cyclic Redundancy Check) for a program image of the entire data recorded in the ROM is stored.
[0008] The above-mentioned inspection step may include the step of calculating a CRC for the bootloader area excluding the boot table area in the ROM, the boot BIT code area, and the area where the boot table is copied in the RAM, and the step of checking the integrity based on the result of comparing the calculated CRC with the CRC stored in the tag area.
[0009] The above ROM may further include a zero padding region into which zero padding is inserted, and the step of calculating the CRC may further include a step of calculating the size of the zero padding region, and a step of omitting data reading from the ROM by the size of the zero padding region and calculating the CRC.
[0010] The step of checking the integrity based on the comparison result between the calculated CRC and the CRC stored in the tag area may further include the step of determining that the boot table has been copied to the RAM without error and executing the runtime library if the calculated CRC and the CRC stored in the tag area match.
[0011] The above-mentioned checking step may further include a step of increasing a boot failure counter if the calculated CRC and the CRC stored in the tag area do not match, and a step of retrying the copy of the boot table to the RAM if the boot failure counter is less than a set value.
[0012] The above-mentioned checking step may further include the step of setting a boot failure flag and forcibly executing a runtime library when the above-mentioned boot failure counter reaches a set value.
[0013] The above-mentioned inspection step may further include a step of detecting a defect in the ROM or the RAM through a Built-In-Test (BIT) for the ROM if the boot failure flag is set after the execution of the runtime library.
[0014] The detection step may include a step of calculating a CRC for a memory area where a program image of the entire data recorded in the ROM is stored, a step of determining a defect in the RAM if the calculated CRC matches the CRC stored in the tag area, and a step of determining a defect in the ROM if the calculated CRC does not match the CRC stored in the tag area.
[0015] According to another embodiment, a bootloader execution device may be provided. The bootloader execution device includes a Read-Only Memory (ROM) and a Random Access Memory (RAM), a memory that stores instructions, and a processor configured to execute the instructions to perform a boot table copy operation when power is applied. The boot table copy operation may include an operation to copy a boot table stored in the ROM to the RAM, an operation to check the integrity of the copy of the boot table, and an operation to detect a defect in the ROM or RAM when a boot fails due to an error in the copy of the boot table.
[0016] The above ROM may include a bootloader area, a boot table area where the boot table is stored, a boot BIT (Built-In-Test) code area for checking the integrity of the copy of the boot table, and a tag area where a CRC (Cyclic Redundancy Check) for a program image of all data recorded in the ROM is stored, and the operation of checking the integrity may include an operation of calculating a CRC for the bootloader area excluding the boot table area in the ROM, the boot BIT code area, and the area where the boot table is copied in the RAM, and an operation of determining that the boot table has been copied to the RAM without error and executing a runtime library if the calculated CRC matches the CRC stored in the tag area.
[0017] The above ROM may further include a zero padding region into which zero padding is inserted, and the operation of calculating the CRC may further include a step of calculating the size of the zero padding region, and an operation of omitting data reading from the ROM by the size of the zero padding region and calculating the CRC.
[0018] The above-described checking operation may further include an operation to increase a boot failure counter if the calculated CRC and the CRC stored in the tag area do not match, and an operation to retry copying the boot table to the RAM if the boot failure counter is less than a set value.
[0019] The above-mentioned checking operation may further include an operation to set a boot failure flag and forcibly execute a runtime library when the above-mentioned boot failure counter reaches a set value.
[0020] The above detection operation may include an operation to determine the boot failure through the above boot failure flag.
[0021] The above detection operation may include an operation to calculate a CRC for a memory area where a program image of the entire data recorded in the ROM is stored, an operation to determine a defect in the RAM if the calculated CRC matches the CRC stored in the tag area, and an operation to determine a defect in the ROM if the calculated CRC does not match the CRC stored in the tag area. Effects of the invention
[0022] According to at least one of the embodiments, the integrity of the boot table copy can be verified after the boot table is copied from ROM to RAM.
[0023] In addition, according to at least one of the embodiments, if a boot table copy is attempted while RAM stabilization is not complete, a retry can be determined and the integrity of the memory copy result can be guaranteed.
[0024] In addition, according to at least one of the embodiments, if a boot failure occurs due to a boot table copy error, it is possible to detect whether the ROM is defective or the RAM is defective through a BIT for the ROM. Brief explanation of the drawing
[0025] FIG. 1 is a diagram showing the boot table copying process of a bootloader execution device according to an embodiment. FIG. 2 is a flowchart illustrating a method for copying a boot table of a bootloader execution device according to an embodiment. FIG. 3 is a flowchart illustrating in detail a method for checking the integrity of a boot table copy result according to an embodiment. FIG. 4 is a drawing showing a bootloader execution device according to one embodiment. Specific details for implementing the invention
[0026] Embodiments of the present invention are described below with reference to the attached drawings so that those skilled in the art can easily implement them. However, the present invention may be embodied in various different forms and is not limited to the embodiments described herein. Furthermore, in order to clearly explain the present invention in the drawings, parts unrelated to the explanation have been omitted, and similar parts throughout the specification are denoted by similar reference numerals.
[0027] Throughout the specification, when a part is described as being "connected" to another part, this includes not only cases where they are "directly or physically connected," but also cases where they are "indirectly or non-contactually connected" with other elements in between, or cases where they are "electrically connected."
[0028] Furthermore, when it is stated that a part "includes" a certain component, this means that, unless specifically stated otherwise, it does not exclude other components but may include additional components.
[0029] In addition, in the flowchart described with reference to the drawings in this specification, the order of operations may be changed, several operations may be merged or some operations may be divided, and certain operations may not be performed.
[0030] Now, a bootloader execution device and method according to an embodiment will be described in detail with reference to the drawings.
[0031] FIG. 1 is a diagram showing the boot table copying process of a bootloader execution device according to an embodiment, and FIG. 2 is a flowchart showing the boot table copying method of a bootloader execution device according to an embodiment.
[0032] Referring to FIG. 1, the bootloader execution device can execute the bootloader when power is applied.
[0033] In some embodiments, the bootloader execution device may be part of the boot device of an embedded system. In some embodiments, the bootloader execution device may be a bootloader.
[0034] The bootloader is stored in non-volatile memory, such as ROM (Read-Only Memory) (100), and is the first program to run when power is applied.
[0035] The ROM (100) may include a bootloader area (110) and a boot table area (140).
[0036] The bootloader area (110) may be a memory area of the ROM (100) on which the bootloader is written. The bootloader area (110) may store, for example, hardware device initialization code (PLL initialization, power setting, RAM (Random Access Memory) setting, data bus setting), boot table copy code, and program entry point entry code. The boot table area (140) may be a memory area of the ROM (100) on which the boot table is written. The boot table area (140) may store, for example, actual program execution code, C language variable initial value data, interrupt vector table, constant data, and switch-case data table.
[0037] According to an embodiment, the ROM (100) may further include a boot BIT (Built-In-Test) code area (120) for checking the integrity of the copy of the boot table after the boot table stored in the boot table area (140) is copied to the RAM (200).
[0038] Additionally, the ROM (100) may further include a tag area (160) in which a Cyclic Redundancy Check (CRC) calculated for the area where the program image is stored is stored when the program image for all data recorded in the ROM (100) is stored in the ROM (100). The tag area (160) may be located at the end of the program image.
[0039] Additionally, the ROM (100) may further include zero padding regions (130, 150) into which zero padding is inserted according to the size of the ROM (100).
[0040] The bootloader area (110) may be located at the very beginning of the ROM (100).
[0041] When the power is turned on, the bootloader execution device sets the instruction pointer (Program Counter) register to a memory address corresponding to the bootloader area (110) of the ROM (100), and can execute instruction code starting from the location pointed to by this memory address.
[0042] When the command code of the bootloader area (110) is executed, system hardware devices such as RAM (200) can be initialized.
[0043] Since the ROM (100) is read-only, the bootloader execution device needs to copy the boot table stored in the ROM (100) to an area of RAM (200).
[0044] Referring to FIG. 2 together with FIG. 1, when the system hardware device is initialized, the bootloader execution device can copy the bootloader table stored in the ROM (100) to the RAM (200) (S210).
[0045] The boot table may include multiple sub-regions, and each sub-region may specify the address and size information of the destination area to be copied. Accordingly, the bootloader execution device can copy the boot table to an area of RAM (200) based on the address and size information of the destination area specified in each sub-region of the boot table.
[0046] Next, after the bootloader execution device copies the boot table stored in the ROM (100) to the RAM (200), it can execute the command code stored in the boot BIT code area (120). When the command code stored in the boot BIT code area (120) is executed, an integrity check can be performed on the result of copying the boot table (S220). A CRC calculation may be used for the integrity check. The data area used for the CRC calculation may be the bootloader area (110), boot BIT code area (120), and zero padding area (130, 150) stored in the ROM (100), excluding the boot table area (140), and the boot table area (210, 220, 230) copied to the RAM (200).
[0047] The bootloader execution device can calculate the CRC for the bootloader area (110), boot BIT code area (120), and zero padding area (130, 150) stored in the ROM (100), and the boot table area (210, 220, 230) copied to the RAM (200).
[0048] The bootloader execution device can verify the integrity of the boot table copy result by comparing the calculated CRC with the CRC stored in the tag area (160) of the ROM (100) to check if they match.
[0049] If the calculated CRC matches the CRC stored in the tag area (160) of the ROM (100), the bootloader execution device determines that the boot table has been copied to each memory area of the RAM (200) without error and can execute the runtime library.
[0050] Meanwhile, if the calculated CRC and the CRC stored in the tag area (160) do not match, the bootloader execution device determines that the stabilization of the RAM (200) is in progress and may retry copying the boot table.
[0051] FIG. 3 is a flowchart illustrating in detail a method for checking the integrity of a boot table copy result according to an embodiment.
[0052] Referring to FIG. 3, the bootloader execution device can perform an integrity check after copying the boot table stored in the ROM (100) to the RAM (200). The bootloader execution device can use CRC calculation to check the integrity of the boot table copy result.
[0053] The bootloader execution device can copy the boot table stored in the boot table area (140) of the ROM (100) to the RAM (200) and then calculate the CRC for the bootloader area (110) and the boot BIT code area (120) in the ROM (100) (S302).
[0054] Next, the bootloader execution device can calculate the CRC for the boot table area (210, 220, 230) in the RAM (200).
[0055] Next, the bootloader execution device calculates the size of the zero padding area (130, 150) in the ROM (100) (S306) and can calculate the CRC for the zero padding area (130, 150) (S308). At this time, since the data in the zero padding area (130, 150) is 0, the bootloader execution device can calculate the CRC by omitting data reading from the ROM (100) for the size of the zero padding area (130, 150).
[0056] That is, the bootloader execution device can calculate the CRC for the bootloader area (110), the boot BIT code area (120), the zero padding area (130, 150), and the boot table area (210, 220, 230) of the RAM (200). Since the data value for the zero padding area (130, 150) is known, the CRC calculation can be performed faster by omitting data reading from the ROM (100) and calculating the CRC.
[0057] The bootloader execution device can compare the calculated CRC with the CRC stored in the tag area of the ROM (100) (S310).
[0058] If the calculated CRC and the stored CRC match (S312), the bootloader execution device determines that the boot table has been copied to each memory area of the RAM (200) without error and can execute the runtime library (S314).
[0059] Meanwhile, if the calculated CRC and the stored CRC do not match (S312), the bootloader execution device can increase the boot failure counter (S316) and compare the boot failure counter with a set value (N).
[0060] If the boot failure counter is less than the set value (N) (S318), the bootloader execution device can retry copying the boot table and start again from step (S302).
[0061] If the bootloader executable device repeats the boot table copying N times but the calculated CRC and the stored CRC do not match, it sets a boot failure flag (S320) and can forcibly execute the runtime library (S314). At this time, the bootloader executable device can notify the main program that the CRC calculation result is inconsistent so that the user can know of the boot failure.
[0062] After the bootloader executable executes the runtime library, it can check the boot failure flag (S322).
[0063] If the bootloader execution device confirms that the boot failure flag is set (S324), it can additionally perform a ROM BIT.
[0064] The bootloader execution device can perform a ROM BIT by calculating a CRC for the entire memory area where a program image including a boot table area (140) is stored in the ROM (100) (S326) and comparing the calculated CRC with the CRC stored in the tag area (160) of the ROM (100) (S328).
[0065] The bootloader execution device can determine whether the RAM (200) is defective or the ROM (100) is defective depending on whether the CRC calculated from the ROM BIT matches the stored CRC.
[0066] If the bootloader execution device determines that the RAM (200) is defective (S332) if the CRC calculated from the ROM BIT matches the stored CRC (S330).
[0067] Meanwhile, if the CRC calculated from the ROM BIT does not match the stored CRC (S330), the bootloader execution device may determine that the ROM (100) is defective (S334).
[0068] In this way, the bootloader execution device according to the embodiment can verify the integrity during the root table copying process and decide to retry the boot table copy based on the result.
[0069] In addition, the bootloader execution device according to the embodiment can identify whether there is a problem in the ROM (100) or in the RAM (200) by performing a ROM BIT when an error occurs during the root table copying process even after repeating the boot table copying N times.
[0070] FIG. 4 is a drawing showing a bootloader execution device according to one embodiment.
[0071] Referring to FIG. 4, the bootloader execution device (400) may be a computing device in which the boot table copying method described above is implemented.
[0072] The bootloader execution device (400) may include a processor (410) and memory (420).
[0073] The memory (420) may include the ROM (100) and RAM (200) described in FIG. 1.
[0074] The processor (410) can be implemented in various types such as an Application Processor (AP), a Central Processing Unit (CPU), a Graphic Processing Unit (GPU), etc., and can be any semiconductor device that executes instructions stored in memory (420). The processor (410) can execute program instructions stored in memory (420). Such a processor (410) can store program instructions in memory (420) to implement at least some of the functions and / or operations of the bootloader execution device described above, and control the execution of the functions and / or operations described based on FIGS. 1 to 3.
[0075] The memory (420) may be located inside or outside the processor (410), and the memory (420) may be connected to the processor (410) through various known means.
[0076] At least some of the bootloader execution method according to the embodiment may be implemented as a program or software executed on a computing device, and the program or software may be stored on a computer-readable medium.
[0077] In addition, at least some of the bootloader execution methods according to the embodiments of the present invention may be implemented in hardware that can be electrically connected to a computing device.
[0078] Although embodiments of the present invention have been described in detail above, the scope of the present invention is not limited thereto, and various modifications and improvements by those skilled in the art using the basic concept of the present invention as defined in the following claims also fall within the scope of the present invention.
Claims
Claim 1 A method for executing a bootloader by a processor, wherein when power is applied, the method comprises the steps of copying a boot table stored in a Read-Only Memory (ROM) to a Random Access Memory (RAM) and checking the integrity of the copy of the boot table, wherein the ROM includes a bootloader area, a boot table area where the boot table is stored, a boot BIT (Built-In-Test) code area for checking the integrity of the copy of the boot table, and a tag area where a Cyclic Redundancy Check (CRC) for an area where a program image of all data recorded in the ROM is stored is stored, and the step of checking the integrity of the copy of the boot table includes the step of calculating a CRC for the bootloader area excluding the boot table area in the ROM, the boot BIT code area, and the area where the boot table is copied in the RAM, and the step of checking the integrity based on the result of comparing the calculated CRC with the CRC stored in the tag area. Claim 2 delete Claim 3 delete Claim 4 A bootloader execution method according to claim 1, wherein the ROM further includes a zero padding region into which zero padding is inserted, and the step of calculating the CRC further includes a step of calculating the size of the zero padding region, and a step of omitting data reading from the ROM by the size of the zero padding region and calculating the CRC. Claim 5 A bootloader execution method according to claim 1, wherein the step of checking the integrity of the copy of the boot table further includes the step of determining that the boot table has been copied to the RAM without error and executing a runtime library if the calculated CRC and the CRC stored in the tag area match. Claim 6 A bootloader execution method according to claim 1, wherein the step of checking the integrity of the copy of the boot table further comprises: a step of increasing a boot failure counter if the calculated CRC and the CRC stored in the tag area do not match; and a step of retrying the copy of the boot table to the RAM if the boot failure counter is less than a set value. Claim 7 A bootloader execution method according to claim 6, wherein the step of checking the integrity of the copy of the boot table further includes the step of setting a boot failure flag and forcibly executing a runtime library when the boot failure counter reaches a set value. Claim 8 A bootloader execution method according to claim 7, wherein the step of checking the integrity of the copy of the boot table further includes the step of detecting a defect in the ROM or the RAM through a Built-In-Test (BIT) for the ROM if the boot failure flag is set after the execution of the runtime library. Claim 9 A bootloader execution method according to claim 8, wherein the detecting step comprises: a step of calculating a CRC for a memory area where a program image of the entire data recorded in the ROM is stored; a step of determining a defect in the RAM if the CRC calculated for the memory area where the program image of the entire data recorded in the ROM is stored matches the CRC stored in the tag area; and a step of determining a defect in the ROM if the CRC calculated for the memory area where the program image of the entire data recorded in the ROM is stored does not match the CRC stored in the tag area. Claim 10 The system includes a memory that stores instructions, comprising ROM (Read-Only Memory) and RAM (Random Access Memory), and a processor configured to execute said instructions to perform a boot table copy operation upon power application; the boot table copy operation includes an operation of copying a boot table stored in the ROM to the RAM, an operation of checking the integrity of the copy of the boot table, and an operation of detecting a defect in the ROM or RAM in the event of a boot failure due to an error in the copy of the boot table; the ROM includes a bootloader area, a boot table area where the boot table is stored, a boot BIT (Built-In-Test) code area for checking the integrity of the copy of the boot table, and a tag area where a CRC (Cyclic Redundancy Check) for an area where a program image of the entire data recorded in the ROM is stored is stored; and the operation of checking integrity includes the bootloader area excluding the boot table area in the ROM, the boot BIT code area, and the area where the boot table is copied in the RAM. A bootloader execution device comprising an operation to calculate a CRC, and an operation to determine that the boot table has been copied to the RAM without error and to execute a runtime library if the calculated CRC matches the CRC stored in the tag area. Claim 11 delete Claim 12 A bootloader execution device according to claim 10, wherein the ROM further includes a zero padding region into which zero padding is inserted, and the operation of calculating the CRC further includes the step of calculating the size of the zero padding region and the operation of omitting data reading from the ROM by the size of the zero padding region and calculating the CRC. Claim 13 A bootloader execution device according to claim 10, wherein the operation of checking integrity further includes, if the calculated CRC and the CRC stored in the tag area do not match, an operation of increasing a boot failure counter, and if the boot failure counter is less than a set value, an operation of retrying to copy the boot table to the RAM. Claim 14 A bootloader execution device according to claim 13, wherein the operation of checking integrity further includes, when the boot failure counter reaches a set value, setting a boot failure flag and forcibly executing a runtime library. Claim 15 A bootloader execution device according to claim 14, wherein the detecting operation includes the operation of determining the boot failure through the boot failure flag. Claim 16 A bootloader execution device according to claim 10, wherein the detecting operation comprises: an operation of calculating a CRC for a memory area where a program image of the entire data recorded in the ROM is stored; an operation of determining a defect in the RAM if the CRC calculated for the memory area where the program image of the entire data recorded in the ROM is stored matches the CRC stored in the tag area; and an operation of determining a defect in the ROM if the CRC calculated for the memory area where the program image of the entire data recorded in the ROM is stored does not match the CRC stored in the tag area.
Citation Information
Patent Citations
Memory controller, system including the same, and method thereof
KR1020160143010A
Method for updating Boot ROM of Embedded system and booting of thereof
KR1020200068345A
Automatic power off based on firmware status
KR1020210089257A
Apparatus and Method for Dynamic Processing of Failure in Static Random Access Memory using Cyclic Redundancy Check
KR1020220146140A
Boot controller and computing device including the same
KR1020240126710A
