Movatterモバイル変換


[0]ホーム

URL:


CN118503014A - Software upgrading method, device, equipment and computer readable storage medium - Google Patents

Software upgrading method, device, equipment and computer readable storage medium
Download PDF

Info

Publication number
CN118503014A
CN118503014ACN202410794634.2ACN202410794634ACN118503014ACN 118503014 ACN118503014 ACN 118503014ACN 202410794634 ACN202410794634 ACN 202410794634ACN 118503014 ACN118503014 ACN 118503014A
Authority
CN
China
Prior art keywords
partition
upgrade
data
software
target software
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410794634.2A
Other languages
Chinese (zh)
Inventor
刘健萍
李达
刘锐衍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Invt Electric Vehicle Drive Technology Shenzhen Co ltd
Original Assignee
Invt Electric Vehicle Drive Technology Shenzhen Co 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 Invt Electric Vehicle Drive Technology Shenzhen Co ltdfiledCriticalInvt Electric Vehicle Drive Technology Shenzhen Co ltd
Priority to CN202410794634.2ApriorityCriticalpatent/CN118503014A/en
Publication of CN118503014ApublicationCriticalpatent/CN118503014A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本申请公开了一种软件升级方法、装置、设备及计算机可读存储介质,应用于软件升级领域,包括:预先对车载芯片的主存进行分区,得到引导程序区和非引导程序区,对非引导程序区进行划分,得到内存空间一致的第一、第二分区;当接收到目标软件的升级指令时,从空中下载中心下载目标软件的升级数据,将升级数据下载至第一分区;对第一分区内的升级数据进行校验;若校验成功,则将第一分区的升级数据写入第二分区;若校验失败,则擦除第一分区中与目标软件相关的数据,并将第二分区中目标软件升级之前的原数据写入第一分区;利用引导程序区的引导加载程序运行第一分区的目标软件。减少了错误备份;在特殊情况下能够及时自恢复,使得软件升级更加安全。

The present application discloses a software upgrade method, device, equipment and computer-readable storage medium, which are applied to the field of software upgrade, including: pre-partitioning the main memory of the vehicle-mounted chip to obtain a boot program area and a non-boot program area, dividing the non-boot program area to obtain the first and second partitions with consistent memory space; when receiving the upgrade instruction of the target software, downloading the upgrade data of the target software from the air download center, and downloading the upgrade data to the first partition; verifying the upgrade data in the first partition; if the verification is successful, writing the upgrade data of the first partition to the second partition; if the verification fails, erasing the data related to the target software in the first partition, and writing the original data before the target software upgrade in the second partition to the first partition; using the boot loader in the boot program area to run the target software in the first partition. Reduced error backup; timely self-recovery under special circumstances, making software upgrades safer.

Description

Translated fromChinese
一种软件升级方法、装置、设备及计算机可读存储介质A software upgrade method, device, equipment and computer-readable storage medium

技术领域Technical Field

本申请涉及软件升级领域,特别涉及一种软件升级方法、装置、设备及计算机可读存储介质。The present application relates to the field of software upgrades, and in particular to a software upgrade method, apparatus, device, and computer-readable storage medium.

背景技术Background Art

在迅速发展的新能源汽车市场,新的产品需求不断涌现,因此对于车载ECU(Electronic Control Unit,电子控制单元)的软件升级需求也变得空前高涨。为了快速响应市场需求,OTA(Over-the-Air,空中下载)技术显得尤为重要。汽车远程升级技术OTA是指通过移动通信网络(2G/3G/4G或无线局域网WiFi)对汽车的零部件终端上固件、数据及应用进行远程管理的技术。简单来说OTA技术实现分三步:首先软件开发商将升级软件上传到OTA中心,然后用户从OTA中心通过无线传输的方式将升级软件下载到车辆端的ECU,最后车辆端的ECU自动升级软件。In the rapidly developing new energy vehicle market, new product demands continue to emerge, so the demand for software upgrades for vehicle-mounted ECUs (Electronic Control Units) has also become unprecedentedly high. In order to quickly respond to market demand, OTA (Over-the-Air) technology is particularly important. Automotive remote upgrade technology OTA refers to the technology of remotely managing the firmware, data and applications on the vehicle's component terminals through mobile communication networks (2G/3G/4G or wireless LAN WiFi). Simply put, OTA technology is implemented in three steps: first, the software developer uploads the upgrade software to the OTA center, then the user downloads the upgrade software from the OTA center to the vehicle's ECU through wireless transmission, and finally the vehicle's ECU automatically upgrades the software.

用户在享受OTA技术便捷升级车辆端软件的同时,也存在一定的风险,即OTA方式对车载ECU的功能影响较大。因此,基于OTA技术实现软件升级时,如何保证ECU在软件升级前后始终保证可运行的状态,是当前要解决的技术问题。While users enjoy the convenience of OTA technology to upgrade vehicle-side software, there are also certain risks, that is, the OTA method has a greater impact on the functions of the vehicle-mounted ECU. Therefore, when implementing software upgrades based on OTA technology, how to ensure that the ECU is always in an operational state before and after the software upgrade is a technical problem that needs to be solved at present.

发明内容Summary of the invention

有鉴于此,本申请的目的在于提供一种软件升级方法、装置、设备及介质,解决了现有技术中基于OTA技术实现软件升级时,无法保证ECU在软件升级前后始终保证可运行状态的问题。In view of this, the purpose of this application is to provide a software upgrade method, device, equipment and medium, which solves the problem in the prior art that when implementing software upgrade based on OTA technology, it is impossible to ensure that the ECU is always in an operational state before and after the software upgrade.

为解决上述技术问题,本申请提供了一种软件升级方法,包括:To solve the above technical problems, the present application provides a software upgrade method, comprising:

预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对所述非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,所述引导程序区存有引导加载程序;Pre-partitioning the main memory of the vehicle-mounted chip to obtain a boot program area and a non-boot program area, dividing the non-boot program area to obtain a first partition and a second partition with consistent memory space, wherein the boot program area stores a boot loader;

当接收到目标软件的升级指令时,从空中下载中心下载所述目标软件的升级数据,将所述升级数据下载至所述第一分区;When receiving an upgrade instruction of the target software, downloading the upgrade data of the target software from the air download center, and downloading the upgrade data to the first partition;

对所述第一分区内的升级数据进行校验,若校验成功,则将所述第一分区的升级数据写入至所述第二分区;Verifying the upgrade data in the first partition, and if the verification is successful, writing the upgrade data in the first partition to the second partition;

若校验失败,则擦除所述第一分区中与所述目标软件相关的数据,并将所述第二分区中所述目标软件升级之前的原数据写入至所述第一分区;If the verification fails, erasing the data related to the target software in the first partition, and writing the original data of the target software before the upgrade in the second partition to the first partition;

利用所述引导加载程序运行所述第一分区的所述目标软件。The target software of the first partition is run using the boot loader.

可选的,对所述第一分区内的升级数据进行校验,若校验成功,则将所述第一分区的升级数据写入至所述第二分区,包括:Optionally, verifying the upgrade data in the first partition, and if the verification succeeds, writing the upgrade data in the first partition into the second partition, includes:

利用循环冗余校验码技术对所述第一分区的升级数据进行校验;Using cyclic redundancy check code technology to verify the upgrade data of the first partition;

若校验成功,则下载成功,将所述第一分区的升级数据写入至所述第二分区,并将目标软件的有效标志位写入至所述第一分区。If the verification is successful, the download is successful, the upgrade data of the first partition is written to the second partition, and the valid flag of the target software is written to the first partition.

可选的,在将所述第一分区的升级数据写入至所述第二分区之后,还包括:Optionally, after writing the upgrade data of the first partition to the second partition, the method further includes:

当所述第一分区的升级数据全部写入至所述第二分区时,对所述第二分区的升级数据进行校验;When all the upgrade data of the first partition are written into the second partition, verifying the upgrade data of the second partition;

若检验成功,则将目标软件的有效标志位写入至所述第二分区;If the verification is successful, the valid flag of the target software is written into the second partition;

若检验失败,则擦除所述第二分区中与所述目标软件相关的数据,重新将所述第一分区的升级数据写入至所述第二分区,并对所述第二分区进行校验,对重试次数进行计数,得到计数值;If the verification fails, erasing the data related to the target software in the second partition, rewriting the upgrade data of the first partition to the second partition, verifying the second partition, counting the number of retries, and obtaining a count value;

若所述计数值达到预设阈值或检验成功,则停止将所述第一分区的升级数据写入至所述第二分区。If the count value reaches a preset threshold or the verification is successful, the writing of the upgrade data of the first partition to the second partition is stopped.

可选的,还包括:Optionally, also include:

当检测到电子控制单元上电时,检查所述第一分区和所述第二分区的有效标志位;When it is detected that the electronic control unit is powered on, checking the valid flag bits of the first partition and the second partition;

若所述第一分区存在所述目标软件的有效标志位,所述第二分区不存在所述目标软件的有效标志位时,则将所述第一分区中与目标软件相关的数据写入至所述第二分区中。If the first partition has a valid flag bit for the target software, and the second partition does not have a valid flag bit for the target software, the data related to the target software in the first partition is written into the second partition.

可选的,对所述第二分区进行校验,包括:Optionally, verifying the second partition includes:

按数据块形式分别读取所述第一分区和所述第二分区对应地址空间的数据值;Read the data values of the address spaces corresponding to the first partition and the second partition respectively in the form of data blocks;

若数据值一致,则校验成功;If the data values are consistent, the verification is successful;

若数据值不一致,则校验失败。If the data values are inconsistent, the verification fails.

可选的,对所述非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,包括:Optionally, dividing the non-boot program area to obtain a first partition and a second partition with consistent memory space includes:

将主存的标定段、数据段、中断向量表和程序段之间的预留区域进行压缩,得到内存空间一致的第一分区和第二分区。The reserved area between the calibration segment, the data segment, the interrupt vector table and the program segment of the main memory is compressed to obtain the first partition and the second partition with consistent memory space.

可选的,在将所述第一分区的升级数据写入至所述第二分区之后,还包括:Optionally, after writing the upgrade data of the first partition to the second partition, the method further includes:

通过接收机接收等待响应和积极响应;所述等待响应为在写入过程中所述车载芯片发出的响应;所述积极响应为写入完毕后所述车载芯片发出的响应;Receiving a waiting response and a positive response through a receiver; the waiting response is a response issued by the on-board chip during the writing process; the positive response is a response issued by the on-board chip after the writing is completed;

根据所述等待响应和所述积极响应确定备份时间;determining a backup time according to the waiting response and the positive response;

将所述备份时间与容忍时间进行比较,确定备份是否超时。The backup time is compared with the tolerance time to determine whether the backup has timed out.

本申请还提供了一种软件升级装置,包括:The present application also provides a software upgrade device, comprising:

预先分区模块,用于预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对所述非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,所述引导程序区存有引导加载程序;A pre-partitioning module is used to pre-partition the main memory of the vehicle-mounted chip to obtain a boot program area and a non-boot program area, and to divide the non-boot program area to obtain a first partition and a second partition with consistent memory space, wherein the boot program area stores a boot loader;

升级模块,用于当接收到目标软件的升级指令时,从空中下载中心下载所述目标软件的升级数据,将所述升级数据下载至所述第一分区;An upgrade module, configured to download upgrade data of the target software from an over-the-air download center upon receiving an upgrade instruction of the target software, and download the upgrade data to the first partition;

第一结果模块,用于对所述第一分区内的升级数据进行校验,若校验成功,则将所述第一分区的升级数据写入至所述第二分区;a first result module, configured to verify the upgrade data in the first partition, and if the verification succeeds, write the upgrade data in the first partition into the second partition;

第二结果模块,用于若校验失败,则擦除所述第一分区中与所述目标软件相关的数据,并将所述第二分区中所述目标软件升级之前的原数据写入至所述第一分区;A second result module, configured to erase the data related to the target software in the first partition if the verification fails, and write the original data of the target software in the second partition before the upgrade to the first partition;

执行模块,用于利用所述引导加载程序运行所述第一分区的所述目标软件An execution module, configured to run the target software of the first partition using the boot loader

本申请还提供了一种软件升级设备,包括:The present application also provides a software upgrade device, including:

存储器,用于存储计算机程序;Memory for storing computer programs;

处理器,用于执行所述计算机程序时实现上述的软件升级方法的步骤。A processor is used to implement the steps of the above-mentioned software upgrade method when executing the computer program.

本申请还提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机可执行指令,所述计算机可执行指令被处理器加载并执行时,实现上述的软件升级方法的步骤。The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are loaded and executed by a processor, the steps of the above-mentioned software upgrade method are implemented.

可见,本申请通过预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,引导程序区存有引导加载程序;当接收到目标软件的升级指令时,从空中下载中心下载目标软件的升级数据,将升级数据下载至第一分区;对第一分区内的升级数据进行校验,若校验成功,将第一分区的升级数据写入至第二分区;若校验失败,则擦除第一分区中与目标软件相关的数据,并将第二分区中目标软件升级之前的原数据写入至第一分区;利用引导加载程序运行第一分区的目标软件。即只有在第一分区的数据校验有效的情况下才会进行数据备份,已确保每次备份的升级数据都是有效的,减少了错误备份的情况,而在第一分区的数据校验失败的情况下,能够及时自恢复,使得软件升级更加安全。It can be seen that the present application partitions the main memory of the vehicle-mounted chip in advance to obtain a boot program area and a non-boot program area, divides the non-boot program area to obtain a first partition and a second partition with consistent memory space, and stores a boot loader in the boot program area; when receiving the upgrade instruction of the target software, download the upgrade data of the target software from the air download center, and download the upgrade data to the first partition; verify the upgrade data in the first partition, if the verification is successful, write the upgrade data of the first partition to the second partition; if the verification fails, erase the data related to the target software in the first partition, and write the original data before the target software upgrade in the second partition to the first partition; use the boot loader to run the target software in the first partition. That is, data backup will only be performed when the data verification of the first partition is valid, which ensures that the upgrade data backed up each time is valid, reducing the situation of erroneous backup, and in the case of data verification failure in the first partition, it can be self-recovered in time, making software upgrade safer.

此外,本申请还提供了一种软件升级装置、设备及计算机可读存储介质,同样具有上述有益效果。In addition, the present application also provides a software upgrade device, equipment and computer-readable storage medium, which also have the above-mentioned beneficial effects.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

图1为本申请实施例提供的一种软件升级方法的流程图;FIG1 is a flow chart of a software upgrade method provided in an embodiment of the present application;

图2为本申请实施例提供的一种软件升级中的备份流程示例图;FIG2 is an example diagram of a backup process in a software upgrade provided in an embodiment of the present application;

图3为本申请实施例提供的一种软件升级失败的回滚流程示例图;FIG3 is an example diagram of a rollback process for a software upgrade failure provided in an embodiment of the present application;

图4为本申请实施例提供的一种软件升级装置的结构示意图;FIG4 is a schematic diagram of the structure of a software upgrade device provided in an embodiment of the present application;

图5为本申请实施例提供的一种软件升级设备的结构示意图。FIG5 is a schematic diagram of the structure of a software upgrade device provided in an embodiment of the present application.

具体实施方式DETAILED DESCRIPTION

为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

请参考图1,图1为本申请实施例提供的一种软件升级方法的流程图。该方法可以包括:Please refer to Figure 1, which is a flow chart of a software upgrade method provided by an embodiment of the present application. The method may include:

S101:预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,引导程序区存有引导加载程序。S101: Partition the main memory of the vehicle-mounted chip in advance to obtain a boot program area and a non-boot program area, divide the non-boot program area to obtain a first partition and a second partition with consistent memory space, and store a boot loader in the boot program area.

本实施例的执行主体为车载终端。车载终端包括车载芯片和接收机。本实施例并不对车载芯片进行限定。例如可以是TC2XX系列的车载芯片;或者还可以是Tricore3XX系列的车载芯片。对车载芯片的主存(PFlash,program flash,主存;用于存放代码或者数据)进行区域划分,得到引导程序区和非引导程序区。其中,引导程序区存放Bootloader(引导加载程序),再将非引导程序区进行划分,得到第一分区(程序运行区)和第二分区(Backuparea,备份区)。可以理解的是,引导程序区的内存空间是远小于非引导程序区的;第一分区和第二分区存储数据一致,因此内存空间大小也是一样的,且第一分区和第二分区不会超过主存的最大地址位。本实施例通过第一分区的开始标志和结束标志,并同步到第二分区实现非引导程序区的划分。The execution subject of this embodiment is a vehicle-mounted terminal. The vehicle-mounted terminal includes a vehicle-mounted chip and a receiver. This embodiment does not limit the vehicle-mounted chip. For example, it can be a vehicle-mounted chip of the TC2XX series; or it can also be a vehicle-mounted chip of the Tricore3XX series. The main memory (PFlash, program flash, main memory; used to store code or data) of the vehicle-mounted chip is divided into regions to obtain a boot program area and a non-boot program area. Among them, the boot program area stores the Bootloader (boot loader), and then the non-boot program area is divided to obtain a first partition (program running area) and a second partition (Backuparea, backup area). It can be understood that the memory space of the boot program area is much smaller than that of the non-boot program area; the first partition and the second partition store the same data, so the memory space size is also the same, and the first partition and the second partition will not exceed the maximum address bit of the main memory. This embodiment uses the start mark and end mark of the first partition and synchronizes it to the second partition to realize the division of the non-boot program area.

进一步的,为了充分利用存储空间,上述对非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,可以包括以下步骤:Furthermore, in order to make full use of the storage space, the above-mentioned partitioning of the non-boot program area to obtain the first partition and the second partition with the same memory space may include the following steps:

将主存的标定段、数据段、中断向量表和程序段之间的预留区域进行压缩,得到内存空间一致的第一分区和第二分区。The reserved area between the calibration segment, data segment, interrupt vector table and program segment of the main memory is compressed to obtain the first partition and the second partition with consistent memory space.

具体地,考虑到主存中各个段之间会存在预留区间,因此为了充分利用主存的存储空间,可以将各段之间的预留区域(Reserve区域)进行压缩。如,将主存的标定段、数据段、中断向量表和程序段的之间的预留区域进行压缩,具体可以是通过移动小的标定段和数据段进行填充,达到压缩的效果。Specifically, considering that there are reserved intervals between each segment in the main memory, in order to fully utilize the storage space of the main memory, the reserved area (Reserve area) between each segment can be compressed. For example, the reserved area between the calibration segment, data segment, interrupt vector table and program segment of the main memory can be compressed, and specifically, the compression effect can be achieved by moving small calibration segments and data segments to fill them.

S102:当接收到目标软件的升级指令时,从空中下载中心下载目标软件的升级数据,将升级数据下载至第一分区。S102: When an upgrade instruction of the target software is received, the upgrade data of the target software is downloaded from the over-the-air download center, and the upgrade data is downloaded to the first partition.

具体地,当用户具有软件升级的需求时,就可以明确要升级的软件,即目标软件。并利用OTA技术从OTA中心下载目标软件的升级数据,将升级数据下载至主存内的第一分区。需要进行说明的是,这里的升级数据并不是基于升级前原数据的是新增数据,而是整个升级后的目标软件数据包。本实施例中的将升级数据下载至第一分区,可以是将升级数据覆盖第一分区中的原数据;或者还可以是将第一分区的原数据擦除,再将升级数据写入至第一分区。Specifically, when the user has a need for software upgrade, the software to be upgraded, that is, the target software, can be clearly identified. The upgrade data of the target software is downloaded from the OTA center using OTA technology, and the upgrade data is downloaded to the first partition in the main memory. It should be noted that the upgrade data here is not based on the original data before the upgrade, but the entire upgraded target software data package. Downloading the upgrade data to the first partition in this embodiment can be to overwrite the original data in the first partition with the upgrade data; or it can be to erase the original data in the first partition, and then write the upgrade data to the first partition.

S103:对第一分区内的升级数据进行校验,若校验成功,则将第一分区的升级数据写入至第二分区,将升级数据写入至第二分区。S103: Verify the upgrade data in the first partition. If the verification is successful, write the upgrade data in the first partition into the second partition.

具体的,当升级数据下载至第一分区完毕后就可以开始备份,但本实施例在备份之前,需要对第一分区内的升级数据进行校验,当校验成功时才可进入备份阶段,以此提高数据备份的有效性。具体的备份过程可以是,将第一分区中的升级数据写入至第二分区,以实现升级数据的备份。再具体地,可以是将第二分区中目标软件升级前的原数据进行擦除,将升级数据写入至第二分区;或者还可以是直接利用升级数据覆盖第二分区中目标软件升级前的原数据。Specifically, the backup can be started after the upgrade data is downloaded to the first partition. However, in this embodiment, the upgrade data in the first partition needs to be verified before the backup. The backup phase can be entered only when the verification is successful, so as to improve the effectiveness of the data backup. The specific backup process can be to write the upgrade data in the first partition to the second partition to realize the backup of the upgrade data. More specifically, the original data before the target software upgrade in the second partition can be erased and the upgrade data can be written to the second partition; or the original data before the target software upgrade in the second partition can be directly overwritten with the upgrade data.

进一步的, 为了提高数据校验效率和准确性,上述对第一分区内的升级数据进行校验,若校验成功,则将第一分区的升级数据写入至第二分区,具体可以包括以下步骤:Further, in order to improve the efficiency and accuracy of data verification, the above verification of the upgraded data in the first partition, if the verification is successful, then the upgraded data of the first partition is written to the second partition, which may specifically include the following steps:

步骤21:利用循环冗余校验码技术对第一分区的升级数据进行校验;Step 21: Verify the upgrade data of the first partition using cyclic redundancy check code technology;

步骤22:若校验成功,则下载成功,将第一分区的升级数据写入至第二分区,并将目标软件的有效标志位写入至第一分区。Step 22: If the verification is successful, the download is successful, the upgrade data of the first partition is written to the second partition, and the valid flag of the target software is written to the first partition.

具体的,本实施例将升级数据从OTA中心下载至第一分区后,利用CRC(循环冗余校验码)技术对第一分区的升级数据进行校验,提高数据验证的效率和准确性。并且,当校验成功时,还将目标软件的有效标志位写入至第一分区,便于后期通过检测有效标志位确定数据状态。Specifically, after the upgrade data is downloaded from the OTA center to the first partition, the CRC (cyclic redundancy check code) technology is used to verify the upgrade data of the first partition to improve the efficiency and accuracy of data verification. In addition, when the verification is successful, the valid flag bit of the target software is also written to the first partition, so that the data status can be determined later by detecting the valid flag bit.

进一步的,为了提高备份数据的有效性,在将第一分区的升级数据写入至第二分区之后,还可以包括以下步骤:Furthermore, in order to improve the validity of the backup data, after writing the upgrade data of the first partition to the second partition, the following steps may be further included:

步骤31:当第一分区的升级数据全部写入至第二分区时,对第二分区的升级数据进行校验;Step 31: When all the upgrade data of the first partition are written to the second partition, verify the upgrade data of the second partition;

步骤32:若检验成功,则将目标软件的有效标志位写入至第二分区;Step 32: If the verification is successful, the valid flag of the target software is written to the second partition;

步骤33:若检验失败,则擦除第二分区中与目标软件相关的数据,重新将升级数据写入至第二分区,并对第二分区进行校验,对重试次数进行计数,得到计数值;Step 33: If the verification fails, the data related to the target software in the second partition is erased, the upgrade data is rewritten to the second partition, and the second partition is verified, and the number of retries is counted to obtain a count value;

步骤34:若计数值达到预设阈值或检验成功,则停止将第一分区的升级数据写入至第二分区。Step 34: If the count value reaches a preset threshold or the verification is successful, stop writing the upgrade data of the first partition to the second partition.

具体可以参考图2,图2为本申请实施例提供的一种软件升级中的备份流程示例图。由图2可知,对软件升级中的备份过程包括擦除第二分区中与目标软件相关的数据,将第一分区中的升级数据写入第二分区,并进行校验,若校验成功,则将目标软件的有效标志位写入第二分区;若校验失败,则对重试次数进行计数,当重复次数未达到第一预设阈值时,还可以重复备份操作;直至校验成功,则完成备份,或者重试次数达到预设阈值,则备份失败,进入备份失败的处理流程。For details, please refer to Figure 2, which is an example diagram of a backup process in a software upgrade provided by an embodiment of the present application. As can be seen from Figure 2, the backup process in the software upgrade includes erasing the data related to the target software in the second partition, writing the upgrade data in the first partition to the second partition, and performing verification. If the verification is successful, the valid flag of the target software is written to the second partition; if the verification fails, the number of retries is counted, and when the number of repetitions does not reach the first preset threshold, the backup operation can be repeated; until the verification is successful, the backup is completed, or the number of retries reaches the preset threshold, the backup fails, and the backup failure processing flow is entered.

进一步的,为了提高数据备份的有效性和备份效率,上述对第二分区的升级数据进行校验,可以包括以下步骤:Furthermore, in order to improve the validity and efficiency of data backup, the above-mentioned verification of the upgraded data of the second partition may include the following steps:

步骤311:按数据块形式分别读取第一分区和第二分区对应地址空间的数据值;Step 311: Read the data values of the address spaces corresponding to the first partition and the second partition respectively in the form of data blocks;

步骤312:若数据值一致,则校验成功;Step 312: If the data values are consistent, the verification is successful;

步骤313:若数据值不一致,则校验失败。Step 313: If the data values are inconsistent, the verification fails.

具体的,本实施例还对备份进行校验。该校验方法不同于CRC校验。本实施例为了提高程序执行效率和减少备份时间,在第二分区完成备份之后直接按数据块读取第一分区和第二分区对应地址空间的数据值,依次快速完成比对校验。Specifically, the present embodiment also verifies the backup. This verification method is different from CRC verification. In order to improve program execution efficiency and reduce backup time, the present embodiment directly reads the data values of the corresponding address spaces of the first partition and the second partition according to the data blocks after the second partition completes the backup, and quickly completes the comparison verification in sequence.

进一步的,为了提高备份数据的时效性,在上述将升级数据写入至第二分区之后或者第二分区的升级数据校验成功之后,还可以包括以下步骤:Furthermore, in order to improve the timeliness of the backup data, after the upgrade data is written to the second partition or after the upgrade data of the second partition is successfully verified, the following steps may be further included:

步骤41:通过接收机接收等待响应和积极响应;等待响应为在写入过程中车载芯片发出的响应;积极响应为写入完毕后车载芯片发出的响应;Step 41: receiving a waiting response and a positive response through a receiver; the waiting response is a response sent by the on-board chip during the writing process; the positive response is a response sent by the on-board chip after the writing is completed;

步骤42:根据等待响应和积极响应确定备份时间;Step 42: Determine the backup time according to the waiting response and the positive response;

步骤43:将备份时间与容忍时间进行比较,确定备份是否超时。Step 43: Compare the backup time with the tolerance time to determine whether the backup has timed out.

具体的,可以通过车载芯片不间断地向上位机回复等待响应;当第二分区完成校验后或完成数据写入工作后,再通过车载芯片向上位机回复积极响应,根据等待响应和积极响应可以确定备份时间,备份时间与等待超时的容忍时间进行匹配,确定备份是否超时。现实操作过程中,备份操作可以在6秒左右完成,其中这6秒执行动作包括了第二分区目标软件升级前原数据的擦除,第一分区升级数据写入第二分区,以及对第二分区的升级程序的校验。其中,上位机为车载终端。Specifically, the vehicle-mounted chip can continuously reply to the host computer with a waiting response; when the second partition completes the verification or completes the data writing work, the vehicle-mounted chip will reply to the host computer with a positive response. The backup time can be determined based on the waiting response and the positive response. The backup time is matched with the tolerance time for the waiting timeout to determine whether the backup has timed out. In the actual operation process, the backup operation can be completed in about 6 seconds, and the 6-second execution action includes erasing the original data before the target software of the second partition is upgraded, writing the upgraded data of the first partition into the second partition, and verifying the upgrade program of the second partition. Among them, the host computer is the vehicle-mounted terminal.

S104:若校验失败,则擦除第一分区中与目标软件相关的数据,并将第二分区中目标软件升级之前的原数据写入至第一分区。S104: If the verification fails, the data related to the target software in the first partition is erased, and the original data before the target software is upgraded in the second partition is written into the first partition.

具体地,当对第一分区中的升级数据校验失败时,则说明升级数据下载至第一分区的过程中遇到一些特殊情况,导致校验失败。如遇到紧急情况需要中断目标软件的升级,或者是意外中断,或者人为中断等各种突发状况时,此时第一分区中可能存在一部分升级数据,这时需要将第一分区中所有与目标软件相关的数据进行擦除处理,将第二分区中目标软件升级之前的原数据写入到第一分区中。可以理解的是,第二分区中在升级软件前,已对该升级软件的原数据进行了备份,保存至第二分区,并且有效,才能达到步骤S104的回滚作用。Specifically, when the verification of the upgrade data in the first partition fails, it means that some special circumstances were encountered during the downloading of the upgrade data to the first partition, resulting in the verification failure. If an emergency situation occurs and the upgrade of the target software needs to be interrupted, or there are various emergencies such as an unexpected interruption or a human interruption, a part of the upgrade data may exist in the first partition at this time. At this time, all the data related to the target software in the first partition needs to be erased, and the original data before the upgrade of the target software in the second partition is written to the first partition. It is understandable that before the software is upgraded, the original data of the upgrade software has been backed up in the second partition, saved in the second partition, and is valid, so as to achieve the rollback effect of step S104.

进一步地,在上述将第二分区中目标软件升级之前的原数据写入至第一分区之后,还可以包括以下步骤:Furthermore, after writing the original data before the target software upgrade in the second partition to the first partition, the following steps may be further included:

步骤51:当原数据全部写入至第一分区时,对第一分区的原数据进行校验;Step 51: When all the original data are written to the first partition, verify the original data of the first partition;

步骤52:若检验成功,则将目标软件的有效标志位写入至第一分区;Step 52: If the verification is successful, the valid flag of the target software is written to the first partition;

步骤53:若检验失败,则擦除第一分区中与目标软件相关的数据,重新将升级数据写入至第一分区,并对第一分区的原数据再次进行校验,对重试次数进行计数,得到计数值;Step 53: If the verification fails, the data related to the target software in the first partition is erased, the upgrade data is rewritten to the first partition, and the original data in the first partition is verified again, and the number of retries is counted to obtain a count value;

步骤54:若计数值达到预设阈值或检验成功,则停止将原数据写入第一分区。Step 54: If the count value reaches a preset threshold or the verification is successful, stop writing the original data into the first partition.

具体可以参考图3,图3为本申请实施例提供的一种软件升级失败的回滚流程示例图。由图3可知,对软件升级失败中的回滚过程包括擦除第一分区中与目标软件相关的数据,将第二分区中的原数据写入第一分区,并进行校验,若校验成功,则将目标软件的有效标志位写入第一分区;若校验失败,则对重试次数进行计数,当重复次数未达到第二预设阈值时,还可以重复回滚操作;直至校验成功,则完成备份,或者重试次数达到第二预设阈值,则回滚失败,进入回滚失败的处理流程。For details, please refer to Figure 3, which is an example diagram of a rollback process for a software upgrade failure provided by an embodiment of the present application. As can be seen from Figure 3, the rollback process for a software upgrade failure includes erasing the data related to the target software in the first partition, writing the original data in the second partition to the first partition, and performing a verification. If the verification succeeds, the valid flag of the target software is written to the first partition; if the verification fails, the number of retries is counted, and when the number of repetitions does not reach the second preset threshold, the rollback operation can be repeated; until the verification succeeds, the backup is completed, or the number of retries reaches the second preset threshold, the rollback fails, and the rollback failure processing flow is entered.

S105:利用引导程序区的引导加载程序运行第一分区的目标软件。S105: Run the target software of the first partition using the boot loader in the boot program area.

具体地,若升级成功,则利用引导程序区的引导加载程序运行第一分区中升级后的目标软件;若升级失败;若升级失败,则利用步骤S104的回滚步骤,利用引导程序区的引导加载程序运行第一分区中升级前的目标软件。这样保证了ECU在升级中断后依然有可用的目标软件。Specifically, if the upgrade is successful, the boot loader in the boot program area is used to run the upgraded target software in the first partition; if the upgrade fails, the rollback step of step S104 is used to run the target software before the upgrade in the first partition using the boot loader in the boot program area. This ensures that the ECU still has available target software after the upgrade is interrupted.

进一步的,为了保证数据备份无损坏,还可以包括以下步骤:Furthermore, in order to ensure that the data backup is not damaged, the following steps may also be included:

步骤61:当检测到电子控制单元上电时,检查第一分区和第二分区的有效标志位;Step 61: When it is detected that the electronic control unit is powered on, checking the valid flag bits of the first partition and the second partition;

步骤62:若第一分区存在目标软件的标志位,第二分区不存在目标软件的有效标志位时,则将第一分区中与目标软件相关的数据写入至第二分区中。Step 62: If the first partition has a flag bit of the target software and the second partition does not have a valid flag bit of the target software, then the data related to the target software in the first partition is written into the second partition.

具体的,在ECU每次上电时,同时判断第一分区和第二分区中目标软件的有效标志是否还存在。若第二分区的目标软件的有效标志不存在,第一分区的目标软件的有效标志存在,则说明第二分区中目标软件的数据遭到受损,第一分区的目标软件的数据完好,此时需将第一分区中目标软件的数据写入至第二分区。当然,若第一分区中目标软件的数据受损时,也应及时将未受损的第二分区中目标软件的数据写入第一分区。以此保证每次上电时,ECU的PFlash中都存在数据完全相同的两份软件。可以理解的是,由于第一分区中的数据用于运行,而第二分区中的数据用于备份,所以第一分区的数据存储安全性要高于第二分区。所以,大概率下是将第一分区中的数据写入至第二分区。本实施例在每次上电后通过检测第二分区和第一分区中的有效标志,以防其中一个区域内的数据遭到损坏后,能够及时自动地进行数据备份,保证每次上电后第二分区与第一分区中都有该软件的数据,且两个分区中存储的数据一致。Specifically, each time the ECU is powered on, it is determined whether the valid flag of the target software in the first partition and the second partition still exists. If the valid flag of the target software in the second partition does not exist, and the valid flag of the target software in the first partition exists, it means that the data of the target software in the second partition is damaged, and the data of the target software in the first partition is intact. At this time, the data of the target software in the first partition needs to be written to the second partition. Of course, if the data of the target software in the first partition is damaged, the data of the target software in the undamaged second partition should also be written to the first partition in time. In this way, it is ensured that there are two copies of software with exactly the same data in the PFlash of the ECU every time it is powered on. It can be understood that since the data in the first partition is used for operation and the data in the second partition is used for backup, the data storage security of the first partition is higher than that of the second partition. Therefore, it is highly likely that the data in the first partition is written to the second partition. In this embodiment, by detecting the valid flags in the second partition and the first partition after each power-on, in case the data in one of the regions is damaged, the data can be backed up automatically and in time to ensure that the second partition and the first partition have the data of the software after each power-on, and the data stored in the two partitions are consistent.

应用本申请实施例提供的软件升级方法,通过预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对非引导程序区进行划分,得到内存空间一致的第一分区和第二分区;当接收到目标软件的升级指令时,从空中下载中心下载目标软件的升级数据,将升级数据下载至第一分区;对第一分区内的升级数据进行校验,若校验成功,则将第一分区的升级数据写入至第二分区;若校验失败,则擦除第一分区中与目标软件相关的数据,并将第二分区中目标软件升级之前的原数据写入至第一分区;利用引导程序区的引导加载程序运行第一分区的目标软件。本方法只有在第一分区的数据校验有效的情况下才会进行数据备份,已确保每次备份的升级数据都是有效的,减少了错误备份的情况,而在第一分区的数据校验失败的情况下,能够及时自恢复,使得软件升级更加安全。The software upgrade method provided by the embodiment of the present application is applied. The main memory of the vehicle-mounted chip is partitioned in advance to obtain a boot program area and a non-boot program area. The non-boot program area is divided to obtain a first partition and a second partition with consistent memory space; when an upgrade instruction of the target software is received, the upgrade data of the target software is downloaded from the air download center, and the upgrade data is downloaded to the first partition; the upgrade data in the first partition is verified, and if the verification is successful, the upgrade data of the first partition is written to the second partition; if the verification fails, the data related to the target software in the first partition is erased, and the original data before the target software upgrade in the second partition is written to the first partition; the boot loader of the boot program area is used to run the target software in the first partition. This method will only perform data backup when the data verification of the first partition is valid, which ensures that the upgrade data backed up each time is valid, reduces the situation of erroneous backup, and can self-recover in time when the data verification of the first partition fails, making the software upgrade safer.

为了使本申请更便于理解,具体可以参考如下具体实施例:In order to make the present application easier to understand, please refer to the following specific embodiments:

1. 对APP编译链接文件重新分区,腾出与APP(应用软件)同样内存大小的第二分区。1. Repartition the APP compiled link file to free up a second partition with the same memory size as the APP (application software).

2. 修改Boot的升级流程,在APP正常刷写结束不立刻向上位机回复积极响应,进行备份操作,借助FLS(Flash EEPROM Emulation模块在AUTOSAR架构中扮演着重要的角色。它不仅负责片上Flash的管理,还涉及到片外Flash的操作。FLS模块提供了一系列的API接口,使得开发者能够对Flash进行读取、编程和擦除等操作。)的操作接口擦除第二分区,读取出第一分区数据,按页写入到第二分区,写入完成之后,按块读取出第一分区和第二分区对应数据,一一对比之后数据完全一致回复积极响应到上位机。2. Modify the upgrade process of Boot. When the APP is flashed normally, do not immediately reply to the host computer with a positive response. Perform backup operations and use the FLS (Flash EEPROM Emulation module plays an important role in the AUTOSAR architecture. It is not only responsible for the management of on-chip Flash, but also involves the operation of off-chip Flash. The FLS module provides a series of API interfaces, allowing developers to read, program and erase Flash.) operation interface to erase the second partition, read the data of the first partition, write it to the second partition by page, and after the writing is completed, read the corresponding data of the first partition and the second partition by block. After comparing one by one, the data are completely consistent and reply to the host computer with a positive response.

3.Bootloader软件中加入上电后对第二分区有效标志位的检查,和第一分区的有效标志位置位方式相同,在第二分区擦除结束之后向NVM(非易失性存储器,是一种计算机即使关闭电源也能够保存已保存数据的存储器)写入无效标志,在一致性校验结束之后写入有效标志。3. Add a check on the valid flag of the second partition after power-on in the Bootloader software. The valid flag is set in the same way as the first partition. After the second partition is erased, an invalid flag is written to the NVM (non-volatile memory, which is a computer that can save saved data even when the power is turned off). After the consistency check is completed, a valid flag is written.

4.每次上电对第一分区和第二分区的有效标志进行判断,第一分区有效第二分区无效就进行自备份流程,第二分区有效第一分区无效就进行回滚流程。4. Each time the power is turned on, the validity flags of the first partition and the second partition are judged. If the first partition is valid and the second partition is invalid, the self-backup process is performed; if the second partition is valid and the first partition is invalid, the rollback process is performed.

OTA双备份的软件实现,在一定程度上增加了用户的可操作性,可以独立的选择升级版本,新版本的升级失败不会影响ECU功能正常使用,即当前版本不会因为升级失败而受损。在厂商发货成功之后,可以便捷的通过OTA远程升级软件功能,即使升级流程出问题导致APP程序丢失,也不用担心功能的正常使用,整个系统的鲁棒性得到提高,也让OTA的功能更加完善。The software implementation of OTA dual backup has increased the operability of users to a certain extent. Users can independently select the upgrade version. The failure of the new version upgrade will not affect the normal use of the ECU function, that is, the current version will not be damaged due to the upgrade failure. After the manufacturer successfully delivers the product, the software function can be easily upgraded remotely through OTA. Even if the upgrade process goes wrong and the APP program is lost, there is no need to worry about the normal use of the function. The robustness of the entire system is improved, and the OTA function is more complete.

下面对本申请实施例提供的软件升级装置进行介绍,下文描述的软件升级装置与上文描述的软件升级方法可相互对应参照。The following is an introduction to a software upgrade device provided in an embodiment of the present application. The software upgrade device described below and the software upgrade method described above can be referenced to each other.

具体请参考图4,图4为本申请实施例提供的一种软件升级装置的结构示意图,可以包括:Please refer to FIG. 4 for details. FIG. 4 is a schematic diagram of the structure of a software upgrade device provided in an embodiment of the present application, which may include:

预先分区模块100,用于预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对所述非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,所述引导程序区存有引导加载程序;A pre-partitioning module 100 is used to pre-partition the main memory of the vehicle-mounted chip to obtain a boot program area and a non-boot program area, and to divide the non-boot program area to obtain a first partition and a second partition with consistent memory space, wherein the boot program area stores a boot loader;

升级模块200,用于当接收到目标软件的升级指令时,从空中下载中心下载所述目标软件的升级数据,将所述升级数据下载至所述第一分区;The upgrade module 200 is used to download the upgrade data of the target software from the air download center when receiving the upgrade instruction of the target software, and download the upgrade data to the first partition;

第一结果模块300,用于对所述第一分区内的升级数据进行校验,若校验成功,则将所述第一分区的升级数据写入至所述第二分区;A first result module 300 is used to verify the upgrade data in the first partition, and if the verification is successful, write the upgrade data of the first partition into the second partition;

第二结果模块400,用于若校验失败,则擦除所述第一分区中与所述目标软件相关的数据,并将所述第二分区中所述目标软件升级之前的原数据写入至所述第一分区;The second result module 400 is used to erase the data related to the target software in the first partition if the verification fails, and write the original data of the target software in the second partition before the upgrade to the first partition;

执行模块500,用于利用所述引导加载程序运行所述第一分区的所述目标软件。The execution module 500 is used to run the target software of the first partition using the boot loader.

基于上述实施例,其中第一结果模块300,可以包括:Based on the above embodiment, the first result module 300 may include:

第一分区校验模块,用于利用循环冗余校验码技术对所述第一分区的升级数据进行校验;A first partition verification module, used to verify the upgrade data of the first partition using a cyclic redundancy check code technology;

第一校验结果模块,用于若校验成功,则下载成功,将所述第一分区的升级数据写入至所述第二分区,并将目标软件的有效标志位写入至所述第一分区。The first verification result module is used to write the upgrade data of the first partition into the second partition and write the valid flag of the target software into the first partition if the verification is successful and the download is successful.

基于上述实施例,其中软件升级装置,还可以包括:Based on the above embodiment, the software upgrade device may further include:

第二分区校验模块,用于在将所述第一分区的升级数据写入至所述第二分区之后,当所述第一分区的升级数据全部写入至所述第二分区时,对所述第二分区的升级数据进行校验;A second partition verification module, configured to verify the upgrade data of the second partition after the upgrade data of the first partition is written into the second partition and when all the upgrade data of the first partition is written into the second partition;

第二检验结果模块,用于若检验成功,则将目标软件的有效标志位写入至所述第二分区;A second inspection result module, configured to write a valid flag of the target software into the second partition if the inspection is successful;

第三校验结果模块,用于若检验失败,则擦除所述第二分区中与所述目标软件相关的数据,重新将所述第一分区的升级数据写入至所述第二分区,并对所述第二分区进行校验,对重试次数进行计数,得到计数值;a third verification result module, configured to, if the verification fails, erase the data related to the target software in the second partition, rewrite the upgrade data of the first partition to the second partition, verify the second partition, count the number of retries, and obtain a count value;

循环停止模块,用于若所述计数值达到预设阈值或检验成功,则停止将所述升级数据写入至所述第二分区。The cycle stop module is used to stop writing the upgrade data to the second partition if the count value reaches a preset threshold or the verification is successful.

基于上述实施例,其中软件升级装置,还可以包括:Based on the above embodiment, the software upgrade device may further include:

有效标志位检查模块,用于当检测到电子控制单元上电时,检查所述第一分区和所述第二分区的有效标志位;A valid flag bit checking module, used for checking the valid flag bits of the first partition and the second partition when it is detected that the electronic control unit is powered on;

备份模块,用于若所述第一分区存在所述目标软件的有效标志位,所述第二分区不存在所述目标软件的有效标志位时,则将所述第一分区中与目标软件相关的数据写入至所述第二分区中。The backup module is used to write the data related to the target software in the first partition into the second partition if the valid flag of the target software exists in the first partition and the valid flag of the target software does not exist in the second partition.

基于上述实施例,其中第二分区校验模块,可以包括:Based on the above embodiment, the second partition verification module may include:

读取单元,用于按数据块形式分别读取所述第一分区和所述第二分区对应地址空间的数据值;A reading unit, used for reading data values of address spaces corresponding to the first partition and the second partition respectively in the form of data blocks;

数据判定第一结果单元,用于若数据值一致,则校验成功;A data determination first result unit is used to verify success if the data values are consistent;

数据判定第二结果单元,用于若数据值不一致,则校验失败。The data determination second result unit is used to determine that the verification fails if the data values are inconsistent.

基于上述实施例,其中预先分区模块100,可以包括:Based on the above embodiment, the pre-partitioning module 100 may include:

分区单元,用于将主存的标定段、数据段、中断向量表和程序段之间的预留区域进行压缩,得到内存空间一致的第一分区和第二分区。The partition unit is used to compress the reserved area between the calibration segment, data segment, interrupt vector table and program segment of the main memory to obtain the first partition and the second partition with consistent memory space.

基于上述实施例,其中软件升级装置,还可以包括:Based on the above embodiment, the software upgrade device may further include:

接收模块,用于通过接收机接收等待响应和积极响应;所述等待响应为在写入过程中所述车载芯片发出的响应;所述积极响应为写入完毕后所述车载芯片发出的响应;A receiving module, used for receiving a waiting response and a positive response through a receiver; the waiting response is a response issued by the on-board chip during the writing process; the positive response is a response issued by the on-board chip after the writing is completed;

备份时间确定模块,用于根据所述等待响应和所述积极响应确定备份时间;A backup time determination module, used to determine the backup time according to the waiting response and the positive response;

比较模块,用于将所述备份时间与容忍时间进行比较,确定备份是否超时。The comparison module is used to compare the backup time with the tolerance time to determine whether the backup has timed out.

需要说明的是,上述软件升级装置中的模块以及单元在不影响逻辑的情况下,其顺序可以前后进行更改。It should be noted that the order of the modules and units in the above software upgrade device can be changed without affecting the logic.

应用本申请实施例提供的软件升级装置,通过预先分区模块100,用于预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对非引导程序区进行划分,得到内存空间一致的第一分区和第二分区;升级模块200,用于当接收到目标软件的升级指令时,从空中下载中心下载目标软件的升级数据,将升级数据下载至第一分区;第一结果模块300,用于对第一分区内的升级数据进行校验,若校验成功,则将第一分区的升级数据写入至第二分区;第二结果模块400,用于若校验失败,则擦除第一分区中与目标软件相关的数据,并将第二分区中目标软件升级之前的原数据写入至第一分区;执行模块500,用于利用引导加载程序运行第一分区的目标软件。本装置只有在第一分区的数据校验有效的情况下才会进行数据备份,已确保每次备份的升级数据都是有效的,减少了错误备份的情况,而在第一分区的数据校验失败的情况下,能够及时自恢复,使得软件升级更加安全。The software upgrade device provided by the embodiment of the present application is used, through the pre-partitioning module 100, for pre-partitioning the main memory of the vehicle-mounted chip to obtain the boot program area and the non-boot program area, and the non-boot program area is divided to obtain the first partition and the second partition with the same memory space; the upgrade module 200 is used to download the upgrade data of the target software from the air download center when receiving the upgrade instruction of the target software, and download the upgrade data to the first partition; the first result module 300 is used to verify the upgrade data in the first partition, if the verification is successful, then write the upgrade data of the first partition to the second partition; the second result module 400 is used to erase the data related to the target software in the first partition if the verification fails, and write the original data before the target software upgrade in the second partition to the first partition; the execution module 500 is used to run the target software of the first partition using the boot loader. The device will only perform data backup when the data verification of the first partition is valid, which ensures that the upgrade data backed up each time is valid, reduces the situation of erroneous backup, and can self-recover in time when the data verification of the first partition fails, making the software upgrade safer.

下面对本申请实施例提供的软件升级设备进行介绍,下文描述的软件升级设备与上文描述的软件升级方法可相互对应参照。The following is an introduction to the software upgrade device provided in the embodiment of the present application. The software upgrade device described below and the software upgrade method described above can refer to each other.

请参考图5,图5为本申请实施例提供的一种软件升级设备的结构示意图,可以包括:Please refer to FIG. 5 , which is a schematic diagram of the structure of a software upgrade device provided in an embodiment of the present application, which may include:

存储器10,用于存储计算机程序;A memory 10, used for storing computer programs;

处理器20,用于执行计算机程序,以实现上述的软件升级方法。The processor 20 is used to execute a computer program to implement the above-mentioned software upgrade method.

存储器10、处理器20、通信接口31均通过通信总线32完成相互间的通信。The memory 10 , the processor 20 , and the communication interface 31 all communicate with each other via the communication bus 32 .

在本申请实施例中,存储器10中用于存放一个或者一个以上程序,程序可以包括程序代码,程序代码包括计算机操作指令,在本申请实施例中,存储器10中可以存储有用于实现以下功能的程序:In the embodiment of the present application, the memory 10 is used to store one or more programs, and the program may include a program code, and the program code includes a computer operation instruction. In the embodiment of the present application, the memory 10 may store a program for implementing the following functions:

预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,引导程序区存有引导加载程序;The main memory of the vehicle-mounted chip is partitioned in advance to obtain a boot program area and a non-boot program area, and the non-boot program area is divided to obtain a first partition and a second partition with consistent memory space, and the boot program area stores a boot loader;

当接收到目标软件的升级指令时,从空中下载中心下载目标软件的升级数据,将升级数据下载至第一分区;When receiving an upgrade instruction of the target software, downloading the upgrade data of the target software from the air download center, and downloading the upgrade data to the first partition;

对第一分区内的升级数据进行校验,若校验成功,将第一分区的升级数据写入至第二分区;Verify the upgrade data in the first partition, and if the verification is successful, write the upgrade data in the first partition to the second partition;

若校验失败,则擦除第一分区中与目标软件相关的数据,并将第二分区中目标软件升级之前的原数据写入至第一分区;If the verification fails, the data related to the target software in the first partition is erased, and the original data before the target software upgrade in the second partition is written to the first partition;

利用引导加载程序运行第一分区的目标软件。The target software of the first partition is run using the boot loader.

在一种可能的实现方式中,存储器10可包括存储程序区和存储数据区,其中,存储程序区可存储操作系统,以及至少一个功能所需的应用程序等;存储数据区可存储使用过程中所创建的数据。In a possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.

此外,存储器10可以包括只读存储器和随机存取存储器,并向处理器提供指令和数据。存储器的一部分还可以包括NVRAM。存储器存储有操作系统和操作指令、可执行模块或者数据结构,或者它们的子集,或者它们的扩展集,其中,操作指令可包括各种操作指令,用于实现各种操作。操作系统可以包括各种系统程序,用于实现各种基础任务以及处理基于硬件的任务。In addition, the memory 10 may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include an NVRAM. The memory stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and processing hardware-based tasks.

处理器20可以为中央处理器(Central Processing Unit,CPU)、特定应用集成电路、数字信号处理器、现场可编程门阵列或者其他可编程逻辑器件,处理器20可以是微处理器或者也可以是任何常规的处理器等。处理器20可以调用存储器10中存储的程序。The processor 20 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic device, a microprocessor or any conventional processor, etc. The processor 20 may call a program stored in the memory 10 .

通信接口31可以为通信模块的接口,用于与其他设备或者系统连接。The communication interface 31 may be an interface of a communication module, and is used to connect to other devices or systems.

当然,需要说明的是,图5所示的结构并不构成对本申请实施例中软件升级设备的限定,在实际应用中软件升级设备可以包括比图5所示的更多或更少的部件,或者组合某些部件。Of course, it should be noted that the structure shown in FIG. 5 does not constitute a limitation on the software upgrade device in the embodiment of the present application. In actual applications, the software upgrade device may include more or fewer components than those shown in FIG. 5 , or combine certain components.

下面对本申请实施例提供的计算机可读存储介质进行介绍,下文描述的计算机可读存储介质与上文描述的软件升级方法可相互对应参照。The computer-readable storage medium provided in the embodiments of the present application is introduced below. The computer-readable storage medium described below and the software upgrade method described above can be referenced to each other.

本申请还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现上述的软件升级方法的步骤。The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned software upgrade method are implemented.

该计算机可读存储介质可以包括:U盘、移动硬盘、只读存储器(Read-OnlyMemory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应该认为超出本申请的范围。Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系属于仅仅用来将一个实体或者操作与另一个实体或者操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其他任何变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

以上对本申请所提供的一种软件升级方法、装置、设备及介质进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The above is a detailed introduction to a software upgrade method, device, equipment and medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims (10)

Translated fromChinese
1.一种软件升级方法,其特征在于,包括:1. A software upgrade method, comprising:预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对所述非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,所述引导程序区存有引导加载程序;Pre-partitioning the main memory of the vehicle-mounted chip to obtain a boot program area and a non-boot program area, dividing the non-boot program area to obtain a first partition and a second partition with consistent memory space, wherein the boot program area stores a boot loader;当接收到目标软件的升级指令时,从空中下载中心下载所述目标软件的升级数据,将所述升级数据下载至所述第一分区;When receiving an upgrade instruction of the target software, downloading the upgrade data of the target software from the air download center, and downloading the upgrade data to the first partition;对所述第一分区内的升级数据进行校验,若校验成功,则将所述第一分区的升级数据写入至所述第二分区;Verifying the upgrade data in the first partition, and if the verification is successful, writing the upgrade data in the first partition to the second partition;若校验失败,则擦除所述第一分区中与所述目标软件相关的数据,并将所述第二分区中所述目标软件升级之前的原数据写入至所述第一分区;If the verification fails, erasing the data related to the target software in the first partition, and writing the original data of the target software before the upgrade in the second partition to the first partition;利用所述引导加载程序运行所述第一分区的所述目标软件。The target software of the first partition is run using the boot loader.2.根据权利要求1所述的软件升级方法,其特征在于,对所述第一分区内的升级数据进行校验,若校验成功,则将所述第一分区的升级数据写入至所述第二分区,包括:2. The software upgrade method according to claim 1, characterized in that the upgrade data in the first partition is verified, and if the verification is successful, the upgrade data in the first partition is written to the second partition, comprising:利用循环冗余校验码技术对所述第一分区的升级数据进行校验;Using cyclic redundancy check code technology to verify the upgrade data of the first partition;若校验成功,则下载成功,将所述第一分区的升级数据写入至所述第二分区,并将目标软件的有效标志位写入至所述第一分区。If the verification is successful, the download is successful, the upgrade data of the first partition is written to the second partition, and the valid flag of the target software is written to the first partition.3.根据权利要求2所述的软件升级方法,其特征在于,在将所述第一分区的升级数据写入至所述第二分区之后,还包括:3. The software upgrade method according to claim 2, characterized in that after writing the upgrade data of the first partition to the second partition, it also includes:当所述第一分区的升级数据全部写入至所述第二分区时,对所述第二分区的升级数据进行校验;When all the upgrade data of the first partition are written into the second partition, verifying the upgrade data of the second partition;若检验成功,则将目标软件的有效标志位写入至所述第二分区;If the verification is successful, the valid flag of the target software is written into the second partition;若检验失败,则擦除所述第二分区中与所述目标软件相关的数据,重新将所述第一分区的升级数据写入至所述第二分区,并对所述第二分区进行校验,对重试次数进行计数,得到计数值;If the verification fails, erasing the data related to the target software in the second partition, rewriting the upgrade data of the first partition to the second partition, verifying the second partition, counting the number of retries, and obtaining a count value;若所述计数值达到预设阈值或检验成功,则停止将所述第一分区的升级数据写入至所述第二分区。If the count value reaches a preset threshold or the verification is successful, the writing of the upgrade data of the first partition to the second partition is stopped.4.根据权利要求3所述的软件升级方法,其特征在于,还包括:4. The software upgrade method according to claim 3, further comprising:当检测到电子控制单元上电时,检查所述第一分区和所述第二分区的有效标志位;When it is detected that the electronic control unit is powered on, checking the valid flag bits of the first partition and the second partition;若所述第一分区存在所述目标软件的有效标志位,所述第二分区不存在所述目标软件的有效标志位时,则将所述第一分区中与目标软件相关的数据写入至所述第二分区中。If the first partition has a valid flag bit for the target software, and the second partition does not have a valid flag bit for the target software, the data related to the target software in the first partition is written into the second partition.5.根据权利要求3所述的软件升级方法,其特征在于,对所述第二分区进行校验,包括:5. The software upgrade method according to claim 3, wherein verifying the second partition comprises:按数据块形式分别读取所述第一分区和所述第二分区对应地址空间的数据值;Read the data values of the address spaces corresponding to the first partition and the second partition respectively in the form of data blocks;若数据值一致,则校验成功;If the data values are consistent, the verification is successful;若数据值不一致,则校验失败。If the data values are inconsistent, the verification fails.6.根据权利要求1所述的软件升级方法,其特征在于,对所述非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,包括:6. The software upgrade method according to claim 1, characterized in that the non-boot program area is divided to obtain a first partition and a second partition with consistent memory space, comprising:将主存的标定段、数据段、中断向量表和程序段之间的预留区域进行压缩,得到内存空间一致的第一分区和第二分区。The reserved area between the calibration segment, data segment, interrupt vector table and program segment of the main memory is compressed to obtain the first partition and the second partition with consistent memory space.7.根据权利要求1所述的软件升级方法,其特征在于,在将所述第一分区的升级数据写入至所述第二分区之后,还包括:7. The software upgrade method according to claim 1, characterized in that after writing the upgrade data of the first partition to the second partition, it also includes:通过接收机接收等待响应和积极响应;所述等待响应为在写入过程中所述车载芯片发出的响应;所述积极响应为写入完毕后所述车载芯片发出的响应;Receiving a waiting response and a positive response through a receiver; the waiting response is a response issued by the on-board chip during the writing process; the positive response is a response issued by the on-board chip after the writing is completed;根据所述等待响应和所述积极响应确定备份时间;determining a backup time according to the waiting response and the positive response;将所述备份时间与容忍时间进行比较,确定备份是否超时。The backup time is compared with the tolerance time to determine whether the backup has timed out.8.一种软件升级装置,其特征在于,包括:8. A software upgrade device, comprising:预先分区模块,用于预先对车载芯片的主存进行分区设置,得到引导程序区和非引导程序区,对所述非引导程序区进行划分,得到内存空间一致的第一分区和第二分区,所述引导程序区存有引导加载程序;A pre-partitioning module is used to pre-partition the main memory of the vehicle-mounted chip to obtain a boot program area and a non-boot program area, and to divide the non-boot program area to obtain a first partition and a second partition with consistent memory space, wherein the boot program area stores a boot loader;升级模块,用于当接收到目标软件的升级指令时,从空中下载中心下载所述目标软件的升级数据,将所述升级数据下载至所述第一分区;An upgrade module, configured to download upgrade data of the target software from an over-the-air download center upon receiving an upgrade instruction of the target software, and download the upgrade data to the first partition;第一结果模块,用于对所述第一分区内的升级数据进行校验,若校验成功,则将所述第一分区的升级数据写入至所述第二分区;a first result module, configured to verify the upgrade data in the first partition, and if the verification succeeds, write the upgrade data in the first partition into the second partition;第二结果模块,用于若校验失败,则擦除所述第一分区中与所述目标软件相关的数据,并将所述第二分区中所述目标软件升级之前的原数据写入至所述第一分区;A second result module, configured to erase the data related to the target software in the first partition if the verification fails, and write the original data of the target software in the second partition before the upgrade to the first partition;执行模块,用于利用所述引导加载程序运行所述第一分区的所述目标软件。An execution module is used to run the target software of the first partition using the boot loader.9.一种软件升级设备,其特征在于,包括:9. A software upgrade device, comprising:存储器,用于存储计算机程序;Memory for storing computer programs;处理器,用于执行所述计算机程序时实现如权利要求1至7任一项所述的软件升级方法的步骤。A processor, configured to implement the steps of the software upgrade method according to any one of claims 1 to 7 when executing the computer program.10.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机可执行指令,所述计算机可执行指令被处理器加载并执行时,实现如权利要求1至7任一项所述的软件升级方法的步骤。10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, the steps of the software upgrade method according to any one of claims 1 to 7 are implemented.
CN202410794634.2A2024-06-192024-06-19Software upgrading method, device, equipment and computer readable storage mediumPendingCN118503014A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202410794634.2ACN118503014A (en)2024-06-192024-06-19Software upgrading method, device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202410794634.2ACN118503014A (en)2024-06-192024-06-19Software upgrading method, device, equipment and computer readable storage medium

Publications (1)

Publication NumberPublication Date
CN118503014Atrue CN118503014A (en)2024-08-16

Family

ID=92243698

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202410794634.2APendingCN118503014A (en)2024-06-192024-06-19Software upgrading method, device, equipment and computer readable storage medium

Country Status (1)

CountryLink
CN (1)CN118503014A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN119513935A (en)*2024-11-052025-02-25北京长擎软件有限公司 Data change method, device, computer equipment, medium and program product

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN119513935A (en)*2024-11-052025-02-25北京长擎软件有限公司 Data change method, device, computer equipment, medium and program product

Similar Documents

PublicationPublication DateTitle
KR100584338B1 (en) Software update method and system
CN110231952B (en)ECU program backup and cyclic upgrade control method and device
CN103299276B (en) Software Update Process for Embedded Devices
US8196130B2 (en)Tri-phase boot process in electronic devices
US8595716B2 (en)Failsafe firmware updates
CN102360304B (en)Embedded microprocessor system and method for updating firmware thereof
KR100506203B1 (en)Booting and boot code update method and system thereof
US20070055969A1 (en)System and method for updating firmware
CN111813428A (en)Method and device for upgrading terminal firmware, electronic equipment and storage medium
CN102004657B (en)A kind of electronic equipment and upgrade method thereof
CN118503014A (en)Software upgrading method, device, equipment and computer readable storage medium
CN110286932A (en)Program downloading method and device
CN113110891B (en)Firmware loading method and device for solid state disk, computer equipment and storage medium
US7934050B2 (en)Microcomputer for flash memory rewriting
CN114625389A (en)Embedded equipment upgrading method, embedded equipment and storage device
CN118426848A (en)Operating system starting method and device, computing equipment and storage medium
CN109189457B (en)Firmware upgrading system and method of intelligent inertial navigation sensing system
CN115794488A (en)FPGA program backup protection method and system
CN117348910A (en)BootLoader upgrading method and system of intelligent cabin MCU
US20250173138A1 (en)Micro-controller-unit, method and computer program for downgrade prevention
CN118760458B (en)Memory and firmware upgrading method thereof
CN112631637B (en)OTA upgrading method, system, equipment and storage medium based on RTOS
CN119336355A (en) Battery control unit software update method, device, equipment and storage medium
CN117707567A (en)Method for identifying integrity of mcu firmware
CN119025304A (en) Program upgrading method of embedded system, embedded system and electronic equipment

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp