A smart card multi-operating system upgrade switching method and system
By designing a multi-operating system upgrade switching method in smart cards, using the technology of automatic identification algorithm and relocating interrupt vector table, the problem of slow chip startup and switching performance during smart cards upgrade and switching in the existing technology is solved, and all codes are realized. Upgrade switching and fast switching performance.
Patent Information
- Application Number
- CN202210534319.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-05-17
AI Technical Summary
In the prior art, when upgrading and switching of smart card multiple operating systems, there is a problem that the chip cannot be started, and the upgrade and switching of all codes cannot be achieved. At the same time, the switching performance is slow, which may cause the communication protocol to time out.
Design a smart card multi-operation system upgrade switching method, generate and independently store its own startup program data through each operating system, determine the target operating system using an automatic identification algorithm, and relocate the interrupt vector table and interrupt service program interface address. Implement switching and upgrading of operating system code.
It realizes that all codes in each operating system can be upgraded and updated, avoiding the chip's default startup program data area being erased, ensuring that the chip can still start normally after power outage, and the switching performance is fast, and there is no need to lose power outage. Backup protection mechanism avoids communication protocol timeout.
Smart Images

Figure CN114924774B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of communication technology, and in particular relates to a smart card multi-operating system upgrade switching method and system. Background Art
[0002] As the smart card (communication smart card) operating system has complex functions and carries various industry applications to provide services to customers, especially the use of eSIM products to package smart cards into patch cards and weld them on the motherboard, it saves the motherboard area and various electronic devices to a certain extent, and even does not require a smart card slot. However, with the evolution of smart card product functions, in order to meet the needs of new services, if the smart card chip cannot be replaced, the only feasible solution is to upgrade the operating system of the smart card chip that has been issued and welded to the device. Therefore, when designing the smart card operating system, the following upgrade methods are recommended:
[0003] 1. Reserve a small amount of code space and the module entry that may need to be upgraded to download the upgrade program patch and complete the upgrade of the functional module. (Only the pre-set modules can be upgraded)
[0004] 2. Design two or more smart card operating system code storage areas, download the new operating system code by running the operating system of the currently used operating system code area and store it in another free operating system code area. After the download is successful, the operating system code upgrade is completed by switching the operating system code area. (The entire operating system code can be upgraded)
[0005] Although the above two solutions have their own advantages and disadvantages, they can basically meet the existing upgrade needs. However, the key point is to run different versions of operating system codes by switching different operating system code areas. The existing technology realizes code area switching by calling entry functions of different code areas. The premise of this approach is that the program code used to identify and call the entry function of the enabled operating system is independently stored in a fixed area, and this part of the code and the operating system cannot be updated and upgraded.
[0006] The existing technology of switching code areas by calling entry functions of different code areas has certain defects, because when the chip is powered on, it is necessary to load the key data of the compiled and linked program to be run from a fixed startup address, such as: interrupt vector table, stack size and address, interrupt service program interface address, entry function code interface address, etc., hereinafter collectively referred to as startup program data. For the solution of using multiple operating system code areas to achieve upgrade through switching, the interrupt vector table and interrupt service program address of the code in each operating system code storage area are different. In order to load different startup program data when the chip is powered on after switching, it is necessary to replace the startup program data of the original operating system code area with the startup program data of the operating system code to be used as the chip startup initialization data. The implementation methods are:
[0007] 1. Overwrite the original startup program data by erasing data.
[0008] This method can realize the upgrade and switching of all codes, but when erasing and overwriting the original startup program data, if the power is lost during the erasing, the chip will never be able to start.
[0009] 2. Compile the codes related to the startup program data (i.e. the above startup program) independently, so that these codes are stored independently outside the code area of multiple operating systems, and these startup codes cannot be upgraded by switching different operating systems. Although this method can avoid the problem that the chip cannot be started permanently due to power failure, it will cause some codes to be unable to be upgraded. In addition to the operating system identification code, these program codes also include interrupt service programs, reset programs, data receiving and sending programs, power-off protection programs, chip storage area erasing programs, etc.
[0010] 3. In order to avoid the defects in Solution 2, only the operating system identification program is retained in the startup program part. After the chip is powered on and started through the current chip default startup program data, the operating system to be run is identified, the startup program data area is switched, and then the chip soft-start operation is realized without powering off through the soft reset function module provided by the hardware. This solution relies on the soft reset startup function provided by the chip hardware and is not suitable for chips without this function. At the same time, the startup program cannot be updated and upgraded by switching the operating system. Summary of the invention
[0011] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and to provide a smart card multi-operating system upgrade switching method and system, which can realize that all codes in each operating system can be upgraded and updated, ensure that the data in the default startup program data area of the chip is not erased, and avoid the problem of the chip being unable to start due to power failure. At the same time, the switching performance is fast, and no power-off backup protection mechanism is required, which avoids the chip starting too slowly and causing the communication protocol timeout.
[0012] According to one aspect of the present invention, the present invention provides a smart card multi-operating system upgrade switching method, the method comprising:
[0013] Each smart card operating system is designed to generate its own startup program data and independently store it in a specific code storage location. After the chip is powered on and started according to the chip default startup program data, each operating system startup program data is traversed, and the target operating system to be enabled is determined by an automatic identification algorithm; wherein the code area of each operating system stores the startup program data required for the chip to power on the operating system, and the automatic identification algorithm identifies the target operating system by unique identification data;
[0014] The chip relocates the chip interrupt vector table and the interrupt service program interface address through code, so that the chip runs the code startup program data of the target operating system to be enabled, and then calls the entry function of the target operating system code to realize the smart card multi-operating system upgrade switching.
[0015] Preferably, the method includes a startup process of a chip startup module, an operating system switching process, and a fallback process for abnormal operation.
[0016] Preferably, the startup process of the chip startup module includes:
[0017] S1. After the chip is powered on, the default startup module of the chip is run;
[0018] S2. Search for existing operating systems, read the startup program data of each operating system, verify the checksum in each startup program data, and if the verification succeeds, record the value Nn of the counter, where n is a natural number;
[0019] S3. If the verification fails, then verify the checksum of the startup program data of the next operating system until the startup program data of all operating systems are verified;
[0020] S4. If the checksums of all operating systems fail, the chip's default boot program data is used to boot;
[0021] S5. Take the operating system with the largest counter as the target operating system to be started, initialize the interrupt vector and interrupt service program in the startup program data of the target operating system, and the entry program, relocate the interrupt vector table and the interrupt service program interface address, and then call the entry program to run the target operating system.
[0022] Preferably, the operating system switching process includes:
[0023] C1. The old operating system has been started;
[0024] C2, receiving the operating system switching instruction and entering the operating system switching module;
[0025] C3, read the startup program data of the new operating system to be switched, use MAX(N1, N2, ... Nn) + 1 as a new counter, and calculate the checksum with all the startup program data and the new counter;
[0026] C4, write all the boot program data, the new counter and the checksum together into the boot program data storage area of the new operating system;
[0027] C5. Restart;
[0028] C6. After power-on, enter the startup process of the chip startup module and complete the operating system switch.
[0029] Preferably, the abnormal operation fallback process includes:
[0030] The rollback process is divided into two types: user-initiated rollback and automatic rollback due to operating system exception:
[0031] User-initiated rollback: When the operating system is running normally, the user executes a rollback operation through instructions, that is, switches to the previous operating system. In essence, the rollback operation is completed according to the operating system switching process;
[0032] Automatic rollback in case of system exception: If a hardware exception occurs during the operation of the new operating system, the operating system calls the switching process in the abnormal interrupt service program and enters the operating system switching process; or, directly erases the data in the data storage area of the operating system startup program, and enters the operating system startup process after the chip is restarted, automatically identifies the valid operating system and completes the startup.
[0033] According to another aspect of the present invention, the present invention further provides a smart card multi-operating system upgrade switching system, the upgrade switching system comprising a chip and multiple smart card operating systems,
[0034] After the chip is started according to the default startup program data of the chip, the startup program data of each operating system is traversed, and the target operating system to be enabled is determined by an automatic recognition algorithm; wherein the code area of each operating system stores the startup program data required for the chip to power on the operating system, and the automatic recognition algorithm identifies the target operating system by the unique identification data;
[0035] The chip relocates the chip interrupt vector table and the interrupt service program interface address through code, so that the chip runs the code startup program data of the enabled target operating system, and then calls the entry function of the target operating system code to realize the smart card multi-operating system upgrade switching.
[0036] Preferably, when the upgrade switching system is running, a startup process of the chip startup module, an operating system switching process and a fallback process in case of abnormal operation are executed.
[0037] Preferably, the startup process of the chip startup module includes:
[0038] S1. After the chip is powered on, the default startup module of the chip is run;
[0039] S2. Search for existing operating systems, read the startup program data of each operating system, verify the checksum in each startup program data, and if the verification succeeds, record the value Nn of the counter, where n is a natural number;
[0040] S3. If the verification fails, then verify the checksum of the startup program data of the next operating system until the startup program data of all operating systems are verified;
[0041] S4. If the checksums of all operating systems fail, the chip's default boot program data is used to boot;
[0042] S5. Take the operating system with the largest counter as the target operating system to be started, initialize the interrupt vector and interrupt service program in the startup program data of the target operating system, and the entry program, relocate the interrupt vector table and the interrupt service program interface address, and then call the entry program to run the target operating system.
[0043] Preferably, the operating system switching process includes:
[0044] C1. The old operating system has been started;
[0045] C2, receiving the operating system switching instruction and entering the operating system switching module;
[0046] C3, read the startup program data of the new operating system to be switched, use MAX(N1, N2, ... Nn) + 1 as a new counter, and calculate the checksum with all the startup program data and the new counter;
[0047] C4, write all the boot program data, the new counter and the checksum together into the boot program data storage area of the new operating system;
[0048] C5. Restart;
[0049] C6. After power-on, enter the startup process of the chip startup module and complete the operating system switch.
[0050] Preferably, the abnormal operation fallback process includes:
[0051] The rollback process is divided into two types: user-initiated rollback and automatic rollback due to operating system exception:
[0052] User-initiated rollback: When the operating system is running normally, the user executes a rollback operation through instructions, that is, switches to the previous operating system. In essence, the rollback operation is completed according to the operating system switching process;
[0053] Automatic rollback in case of system exception: If a hardware exception occurs during the operation of the new operating system, the operating system calls the switching process in the abnormal interrupt service program and enters the operating system switching process; or, directly erases the data in the data storage area of the operating system startup program, and enters the operating system startup process after the chip is restarted, automatically identifies the valid operating system, and completes the startup.
[0054] Beneficial effects:
[0055] 1. Ensure that the data in the default boot program data area of the chip is not erased to avoid the problem that the chip cannot start due to power failure.
[0056] 2. All codes in each operating system can be upgraded and updated through the above operating system switching method.
[0057] 3. Fast switching performance, no power-off backup protection mechanism is required, only one FLASH page (the page where the counter and checksum are located) needs to be erased to avoid the chip starting too slowly and causing the communication protocol to time out.
[0058] The features and advantages of the present invention will become clear through reference to the following drawings and detailed description of specific embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a flow chart of a smart card multi-operating system upgrade switching method;
[0060] Figure 2 It is a schematic diagram of the storage of each operating system code and boot program data;
[0061] Figure 3 It is a schematic diagram of the interaction process between the chip and the operating system;
[0062] Figure 4 This is a schematic diagram of switching between multiple operating systems. DETAILED DESCRIPTION
[0063] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0064] Example 1
[0065] Figure 1 The present invention is a flow chart of a smart card multi-operating system upgrade and switching method. Figure 1 As shown, the present invention provides a smart card multi-operating system upgrade switching method, the method comprising:
[0066] After the chip is started according to the chip startup program data, each operating system startup program data is traversed, and the target operating system to be enabled is determined by an automatic identification algorithm; wherein the code area of each operating system stores the startup program data required for the chip to power on the operating system, and the automatic identification algorithm identifies the target operating system by the unique identification data;
[0067] The chip relocates the chip interrupt vector table and the interrupt service program interface address through code, so that the chip runs the code startup program data of the enabled target operating system, and then calls the entry function of the target operating system code to realize the smart card multi-operating system upgrade switching.
[0068] Specifically, each operating system code area has its own code data for chip startup, and the startup program data includes stack configuration data required for chip operation, chip hardware or software interrupt vector table and interface implementation data for reset interrupt when chip starts, wherein:
[0069] The stack configuration data is as follows:
[0070]
[0071] The interrupt vectors are as follows:
[0072]
[0073] The chip reset interrupt is implemented as follows:
[0074]
[0075] The data used to start the chip is different for each operating system. The corresponding startup program data is needed to enable the chip to run normally when the operating systems in different storage areas are running. The storage diagram of each operating system code and startup program data is as follows: Figure 2 shown.
[0076] After the chip is started from the chip's default startup program data, it searches for each operating system startup program data, determines the operating system that needs to be enabled through an automatic recognition algorithm, and relocates the chip interrupt vector table and interrupt service program interface address through code, that is, by changing the chip hardware vector register address, the initialized interrupt vector is configured as the interrupt vector in the startup program data of the operating system to be started, so that the chip runs the code startup program data of the enabled operating system, and then calls the entry function of the started operating system code to realize the smart card multi-operating system upgrade switching.
[0077] The automatic identification algorithm uniquely identifies the operating system through automatically generated specific identification data. The specific identification data preferably uses a counter, which uniquely corresponds to the operating system on the one hand, and counts the number of operating systems and the number of times they are used on the other hand. Considering that the boot program data of each operating system that is different from the default boot program data of the chip needs to be written into the operating system storage area by downloading, and the counter data is also stored. In order to prevent the chip from losing power during the erasing process, resulting in the chip memory data being unknown, it is preferred to verify and calculate the operating system boot program data and write it into each operating system boot program data storage area together with the operating system boot program data and the counter.
[0078] The method of this embodiment can ensure that all codes in each operating system can be upgraded and updated, ensuring that the data in the chip's default startup program data area is not erased, avoiding the problem of the chip being unable to start due to power failure. At the same time, the switching performance is fast and no power-off backup protection mechanism is required, avoiding the chip starting too slowly and causing the communication protocol to time out.
[0079] Preferably, the method includes a startup process of a chip startup module, an operating system switching process, and a fallback process for abnormal operation.
[0080] Preferably, the startup process of the chip startup module includes:
[0081] S1. After the chip is powered on, the default startup module of the chip is run;
[0082] S2. Search for existing operating systems, read the startup program data of each operating system, verify the checksum in each startup program data, and if the verification succeeds, record the value Nn of the counter, where n is a natural number;
[0083] S3. If the verification fails, then verify the checksum of the startup program data of the next operating system until the startup program data of all operating systems are verified;
[0084] S4. If the checksums of all operating systems fail, the chip's default boot program data is used to boot;
[0085] S5. Take the operating system with the largest counter as the target operating system to be started, initialize the interrupt vector and interrupt service program in the startup program data of the target operating system, and the entry program, relocate the interrupt vector table and the interrupt service program interface address, and then call the entry program to run the target operating system.
[0086] Preferably, the operating system switching process includes:
[0087] C1. The old operating system has been started;
[0088] C2, receiving the operating system switching instruction and entering the operating system switching module;
[0089] C3, read the startup program data of the new operating system to be switched, use MAX(N1, N2, ... Nn) + 1 as a new counter, and calculate the checksum with all the startup program data and the new counter;
[0090] C4, write all the boot program data, the new counter and the checksum together into the boot program data storage area of the new operating system;
[0091] C5. Restart;
[0092] C6. After power-on, enter the startup process of the chip startup module and complete the operating system switch.
[0093] Preferably, the abnormal operation fallback process includes:
[0094] The rollback process is divided into two types: user-initiated rollback and automatic rollback due to operating system exception:
[0095] User-initiated rollback: When the operating system is running normally, the user executes a rollback operation through instructions, that is, switches to the previous operating system. In essence, the rollback operation is completed according to the operating system switching process;
[0096] Automatic rollback in case of system exception: If a hardware exception occurs during the operation of the new operating system, the operating system calls the switching process in the abnormal interrupt service program and enters the operating system switching process; or, directly erases the data in the data storage area of the operating system startup program, and enters the operating system startup process after the chip is restarted, automatically identifies the valid operating system, and completes the operating system startup.
[0097] According to another aspect of the present invention, the present invention further provides a smart card multi-operating system upgrade switching system, the upgrade switching system comprising a chip and multiple smart card operating systems,
[0098] After the chip is started according to the chip startup program data, the chip traverses each operating system startup program data and determines the target operating system to be enabled through an automatic identification algorithm; wherein the code area of each operating system stores the startup program data required for the chip to power on the operating system, and the automatic identification algorithm identifies the target operating system through unique identification data;
[0099] The chip relocates the chip interrupt vector table and the interrupt service program interface address through code, so that the chip runs the code startup program data of the enabled target operating system, and then calls the entry function of the target operating system code to realize the smart card multi-operating system upgrade switching.
[0100] Preferably, when the upgrade switching system is running, a startup process of the chip startup module, an operating system switching process and a fallback process in case of abnormal operation are executed.
[0101] Specifically, refer to Figure 3 , the startup process of the chip startup module includes:
[0102] S1. After the chip is powered on, the default startup module of the chip is run;
[0103] S2. Search for existing operating systems, read the startup program data of each operating system, verify the checksum in each startup program data, and if the verification succeeds, record the value Nn of the counter, where n is a natural number;
[0104] The checksum is unique data calculated by a general algorithm for all operating system startup program data, and the general algorithm is preferably a simple and fast algorithm such as XOR and HASH.
[0105] The counter is in the chip storage area where the operating system startup program data is located. The counter is just an identifier used to uniquely mark the operating system startup program data, or it can be a character table with certain rules. The counter is used here for ease of understanding. On the one hand, it is used to identify multiple operating systems, and on the other hand, the latest character or the largest count is used to represent that the operating system startup program data stored in this area is the operating system startup program data to be started.
[0106] S3. If the verification fails, then verify the checksum of the startup program data of the next operating system until the startup program data of all operating systems are verified;
[0107] S4. If the checksums of all operating systems fail, the chip's default boot program data is used to boot;
[0108] S5. Take the operating system with the largest counter as the target operating system to be started, initialize the interrupt vector and interrupt service program in the startup program data of the target operating system, and the entry program, relocate the interrupt vector table and the interrupt service program interface address, and then call the entry program to run the target operating system.
[0109] Preferably, the operating system switching process includes:
[0110] C1. The old operating system has been started;
[0111] C2, receiving the operating system switching instruction and entering the operating system switching module;
[0112] C3, read the startup program data of the new operating system to be switched, use MAX(N1, N2, ... Nn) + 1 as a new counter, and calculate the checksum with all the startup program data and the new counter;
[0113] Taking the description of the preferred counter as an example, MAX represents an algorithm for finding the maximum number, so as to find the maximum count and the operating system startup program data in the storage area where the maximum count is located.
[0114] C4, write all the boot program data, the new counter and the checksum together into the boot program data storage area of the new operating system;
[0115] Among them, erasing FLASH does not require backup protection. Even if the power is lost during the erasing process, the new operating system will not be started when the power is turned on again. When the chip is programmed to erase the data in the startup program data storage area, if the chip loses power, all data in the FLASH storage area will be lost. The general practice is that the data in the storage area becomes an irregular random number. Either the data in the storage area cannot be read, or the data read out is an irregular random number. After the chip is powered on again, all the operating system startup program data will be read in the operating system switching process, and the checksum in each startup program data will be checked. Because the correct checksum cannot be calculated for irregular random numbers, the startup program data of the new operating system will not be used to run the operating system later.
[0116] C5. Restart;
[0117] C6. After power-on, enter the startup process of the chip startup module and complete the operating system switch.
[0118] Preferably, the abnormal operation fallback process includes:
[0119] The rollback process is divided into two types: user-initiated rollback and automatic rollback due to operating system exception:
[0120] User-initiated rollback: When the operating system is running normally, the user executes a rollback operation through instructions, that is, switches to the previous operating system. In essence, the rollback operation is completed according to the operating system switching process;
[0121] Automatic rollback in case of system exception: If a hardware exception occurs during the operation of the new operating system, the operating system calls the switching process in the abnormal interrupt service program and enters the operating system switching process; or, directly erases the data in the data storage area of the operating system startup program, and enters the operating system startup process after the chip is restarted, automatically identifies the valid operating system, and completes the operating system startup.
[0122] Through this embodiment, it is ensured that the data in the chip startup program data area is not erased, avoiding the problem that the chip cannot be started due to power failure. Through the above operating system switching method, all codes in each operating system can be upgraded and updated. The switching performance is fast, and no power failure backup protection mechanism is required. Only one FLASH page (the page where the counter and checksum are located) needs to be erased to avoid the chip starting too slowly and causing the communication protocol to time out.
[0123] Example 2
[0124] Figure 4 This is a schematic diagram of multiple operating system switching. Figure 4 As shown, the present invention also provides a smart card multi-operating system upgrade switching system, the upgrade switching system includes a chip and multiple smart card operating systems,
[0125] After the chip is started according to the chip startup program data, the chip traverses each operating system startup program data and determines the target operating system to be enabled through an automatic identification algorithm; wherein the code area of each operating system stores the startup program data required for the chip to power on the operating system, and the automatic identification algorithm identifies the target operating system through unique identification data;
[0126] The chip relocates the chip interrupt vector table and the interrupt service program interface address through code, so that the chip runs the startup program data of the enabled target operating system, and then calls the entry function of the target operating system code to realize the smart card multi-operating system upgrade switching.
[0127] Preferably, when the upgrade switching system is running, a startup process of the chip startup module, an operating system switching process and a fallback process in case of abnormal operation are executed.
[0128] Preferably, the startup process of the chip startup module includes:
[0129] S1. After the chip is powered on, the default startup module of the chip is run;
[0130] S2. Search for existing operating systems, read the startup program data of each operating system, verify the checksum in each startup program data, and if the verification succeeds, record the value Nn of the counter, where n is a natural number;
[0131] S3. If the verification fails, then verify the checksum of the startup program data of the next operating system until the startup program data of all operating systems are verified;
[0132] S4. If the checksums of all operating systems fail, the chip's default boot program data is used to boot;
[0133] S5. Take the operating system with the largest counter as the target operating system to be started, initialize the interrupt vector and interrupt service program in the startup program data of the target operating system, and the entry program, relocate the interrupt vector table and the interrupt service program interface address, and then call the entry program to run the target operating system.
[0134] Preferably, the operating system switching process includes:
[0135] C1. The old operating system has been started;
[0136] C2, receiving the operating system switching instruction and entering the operating system switching module;
[0137] C3, read the startup program data of the new operating system to be switched, use MAX(N1, N2, ... Nn) + 1 as a new counter, and calculate the checksum with all the startup program data and the new counter;
[0138] C4, write all the boot program data, the new counter and the checksum together into the boot program data storage area of the new operating system;
[0139] C5. Restart;
[0140] C6. After power-on, enter the startup process of the chip startup module and complete the operating system switch.
[0141] Preferably, the abnormal operation fallback process includes:
[0142] The rollback process is divided into two types: user-initiated rollback and automatic rollback due to operating system exception:
[0143] User-initiated rollback: When the operating system is running normally, the user executes a rollback operation through instructions, that is, switches to the previous operating system. In essence, the rollback operation is completed according to the operating system switching process;
[0144] Automatic rollback in case of system exception: If a hardware exception occurs during the operation of the new operating system, the operating system calls the switching process in the abnormal interrupt service program and enters the operating system switching process; or, directly erases the data in the data storage area of the operating system startup program, and enters the operating system startup process after the chip is restarted, automatically identifies the valid operating system, and completes the startup.
[0145] The specific implementation process of this embodiment 2 is the same as the implementation process of each step in embodiment 1, and will not be repeated here.
[0146] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.
Claims
1. A smart card multi-operating system upgrade switching method, characterized in that: The method comprises: After the chip is started according to the chip startup program data, each operating system startup program data is traversed, and the target operating system to be enabled is determined by an automatic identification algorithm; wherein the code area of each operating system stores the startup program data required for the chip to power on the operating system, and the automatic identification algorithm identifies the target operating system by the unique identification data; The chip relocates the chip interrupt vector table and the interrupt service program interface address through the code, so that the chip runs the code startup program data of the enabled target operating system, and then calls the entry function of the target operating system code to realize the smart card multi-operating system upgrade switch; The method includes a startup process of a chip startup module, an operating system switching process, and a fallback process for abnormal operation; The startup process of the chip startup module includes: S1. After the chip is powered on, the default startup module of the chip is run; S2. Search for existing operating systems, read the startup program data of each operating system, verify the checksum in each startup program data, and if the verification succeeds, record the value Nn of the counter, where n is a natural number; S3. If the verification fails, then verify the checksum of the startup program data of the next operating system until the startup program data of all operating systems are verified; S4. If the checksums of all operating systems fail, the chip's default boot program data is used to boot; S5, taking the operating system with the largest counter as the target operating system to be started, initializing the interrupt vector and interrupt service routine in the startup program data of the target operating system, and the entry program, relocating the interrupt vector table and the interrupt service routine interface address, and then calling the entry program to run the target operating system; The operating system switching process includes: C1. The old operating system has been started; C2, receiving the operating system switching instruction and entering the operating system switching module; C3, read the startup program data of the new operating system to be switched, use MAX (N1, N2, ... Nn) + 1 as a new counter, and calculate the checksum with all the startup program data and the new counter; C4. Write all the boot program data, the new counter and the checksum together into the boot program data storage area of the new operating system; C5. Restart; C6. After power-on, enter the startup process of the chip startup module and complete the operating system switch.
2. The method according to claim 1, characterized in that The abnormal fallback process includes: The rollback process is divided into two types: user-initiated rollback and automatic rollback due to operating system exception: User-initiated rollback: When the operating system is running normally, the user executes the rollback operation through instructions; Automatic rollback in case of system exception: If a hardware exception occurs during the operation of the new operating system, the operating system calls the switching process in the abnormal interrupt service program and enters the operating system switching process; or, directly erases the data in the data storage area of the operating system startup program, and enters the operating system startup process after the chip is restarted, and automatically identifies the valid operating system.
3. A smart card multi-operating system upgrade switching system, the upgrade switching system comprising a chip and multiple smart card operating systems, characterized in that: After the chip is started according to the chip startup program data, the chip traverses each operating system startup program data and determines the target operating system to be enabled through an automatic identification algorithm; wherein the code area of each operating system stores the startup program data required for the chip to power on the operating system, and the automatic identification algorithm identifies the target operating system through unique identification data; The chip relocates the chip interrupt vector table and the interrupt service program interface address through the code, so that the chip runs the code startup program data of the enabled target operating system, and then calls the entry function of the target operating system code to realize the smart card multi-operating system upgrade switch; When the upgrade switching system is running, the startup process of the chip startup module, the operating system switching process and the fallback process in case of abnormal operation are executed; The startup process of the chip startup module includes: S1. After the chip is powered on, the default startup module of the chip is run; S2. Search for existing operating systems, read the startup program data of each operating system, verify the checksum in each startup program data, and if the verification succeeds, record the value Nn of the counter, where n is a natural number; S3. If the verification fails, then verify the checksum of the startup program data of the next operating system until the startup program data of all operating systems are verified; S4. If the checksums of all operating systems fail, the chip's default boot program data is used to boot; S5, taking the operating system with the largest counter as the target operating system to be started, initializing the interrupt vector and interrupt service routine in the startup program data of the target operating system, and the entry program, relocating the interrupt vector table and the interrupt service routine interface address, and then calling the entry program to run the target operating system; The operating system switching process includes: C1. The old operating system has been started; C2, receiving the operating system switching instruction and entering the operating system switching module; C3, read the startup program data of the new operating system to be switched, use MAX (N1, N2, ... Nn) + 1 as a new counter, and calculate the checksum with all the startup program data and the new counter; C4. Write all the boot program data, the new counter and the checksum together into the boot program data storage area of the new operating system; C5. Restart; C6. After power-on, enter the startup process of the chip startup module and complete the operating system switch.
4. The system according to claim 3, characterized in that The abnormal operation fallback process includes: The rollback process is divided into two types: user-initiated rollback and automatic rollback due to operating system exception: User-initiated rollback: When the operating system is running normally, the user executes the rollback operation through instructions; Automatic rollback in case of system exception: If a hardware exception occurs during the operation of the new operating system, the operating system calls the switching process in the abnormal interrupt service program and enters the operating system switching process; or, directly erases the data in the data storage area of the operating system startup program, and enters the operating system startup process after the chip is restarted, and automatically identifies the valid operating system.
Citation Information
Patent Citations
Kernel dynamic switching method and control system of digital signal processing (DSP) chip
CN103116522A
Embedded multi-operation system boot program upgrading method
CN106371863A