简体   繁体   English

最常见的固件更新协议

[英]Most common firmware update protocol

I am supposed to pick (and may be implement) the firmware update protocol/software/procedure for the embedded device without USB and with limited program memory size. 我应该为没有USB且程序存储器大小有限的嵌入式设备选择(并可以实施)固件更新协议/软件/过程。 That device will work autonomously most of the time but once in a while a technician will be coming and updating the firmware. 该设备在大多数情况下会自动运行,但偶尔会有技术人员来更新固件。

What would be the most common choice for the update protocol if I wanted to use RS232 or CAN? 如果要使用RS232或CAN,更新协议的最常见选择是什么?

The requirements for the update are: complete after interrupted update (boot loader will be needed, I assume), small memory footprint, merge user settings with the newly introduced user data fields (in EEPROM), backup the previous version of the firmware with the possibility to roll the update back, safely update the boot loader itself. 更新的要求是:中断更新后完成(我认为将需要引导加载程序),较小的内存占用量,将用户设置与新引入的用户数据字段(在EEPROM中)合并,用固件备份先前版本的固件。可以回滚更新,安全地更新引导加载程序本身。

It would be nice if the implementation of the boot loader and update client software existed already too (at least for Windows). 如果引导加载程序和更新客户端软件的实现也已经存在(至少对于Windows),那将是很好的。

And just out of curiosity - are there any good alternatives to DFU for devices with USB? 只是出于好奇-对于带有USB的设备,DFU是否有很好的替代品?

Thanks in advance 提前致谢

I am not sure about "most common"; 我不确定“最常见”; I am not sure anyone could answer that authoritatively or whether the answer is even useful. 我不确定有人可以权威地回答这一问题,也不确定答案是否有用。 However I can tell you that I have implemented XMODEM-CRC/XMODEM-1K on a number of devices (ARM 7, ARM Cortem-M, PIC24, TI C55xx for example) in less than 4Kbytes. 但是我可以告诉您,我已经在少于4KB的许多设备(例如ARM 7,ARM Cortem-M,PIC24,TI C55xx)上实现了XMODEM-CRC / XMODEM-1K。 The bootloader sends an XMODEM start request on each port that is to support update, then for each port if a response is received within a short timeout (a few tens of milliseconds), then transfer continues. 引导加载程序会在每个端口上发送一个XMODEM启动请求以支持更新,然后,如果每个端口在很短的超时时间内(几十毫秒)内收到响应,则对每个端口进行发送,然后继续传输。 If no response is received the application is started normally. 如果未收到响应,则应用程序将正常启动。

complete after interrupted update (boot loader will be needed, I assume) 更新在中断更新后完成(我认为将需要引导加载程序)

The approach I have taken is to not program the start address immediatly to flash on receipt but to copy it sideways and then program it last. 我采用的方法是不立即对起始地址进行编程以使收货时闪烁,而是将其横向复制然后最后编程。 The bootloader checks the start address on start-up and if it is 0xFFFFFFFF (ie not programmed) the transfer did not complete, and the bootloader restarts continuously polling for XMODEM start. 引导加载程序会在启动时检查起始地址,如果它是0xFFFFFFFF(即未编程),则传输不会完成,并且引导加载程序会连续不断地重启轮询以启动XMODEM。

merge user settings with the newly introduced user data fields (in EEPROM), 将用户设置与新引入的用户数据字段(在EEPROM中)合并,

In my case I have used Intel HEX files, but EEPROM memory is not commonly memory mapped. 就我而言,我使用了Intel HEX文件,但是EEPROM内存通常不映射到内存。 You could solve that by using a proprietary data format or set the address of the HEX data to an area that is invalid on the processor which the bootloader code will recognise as data to be sent to the EEPROM instead. 您可以通过使用专有数据格式解决此问题,或者将HEX数据的地址设置为处理器上无效的区域,引导加载程序代码会将其识别为要发送到EEPROM的数据。

backup the previous version of the firmware with the possibility to roll the update back, 备份固件的先前版本,并有可能回滚更新,

That is a function of the bootloader implementation rather than the protocol. 这是引导加载程序实现的功能,而不是协议的功能。 It of course requires that you have space to store two copies of the application. 当然,它需要您有空间来存储应用程序的两个副本。 The unused copy could possibly be zipped, but incorporating decompression in the bootloader will increase its size. 可以压缩未使用的副本,但是在引导加载程序中合并解压缩将增加其大小。 A perhaps simpler and least costly approach would be to have the bootloader support output of the current application image via XMODEM allowing the back-up to be stored on the host. 一种可能更简单且成本最低的方法是使引导加载程序通过XMODEM支持当前应用程序映像的输出,从而允许将备份存储在主机上。 However by doing that you are potentially enabling a third party to access your code. 但是,这样做可能使第三方能够访问您的代码。

safely update the boot loader itself. 安全地更新引导加载程序本身。

Again that is a function of your bootloader rather then the protocol. 同样,这是引导加载程序的功能,而不是协议的功能。 If the code runs from RAM (ie the bootloader is copied from ROM to RAM and executed, then it is straightforward. In this case it is safest if possible to load the entire bootloader data into RAM before programming flash memory in order to minimise the time the target has no bootloader and so that sucessful programming does not rely on the host connection being maintained throughout. 如果代码是从RAM运行的(即,引导加载程序从ROM复制到RAM并执行),那么它很简单。在这种情况下,如果可能的话,最安全的做法是将整个引导加载程序数据加载到RAM中,然后再对闪存进行编程,以最大程度地减少时间目标没有引导加载程序,因此成功的编程不依赖于始终保持的主机连接。

If however the bootloader runs from flash, replacing it from the bootloader itself is not possible. 但是,如果引导加载程序从闪存运行,则无法从引导加载程序本身进行替换。 Instead you might load an application that the bootloader runs and which replaces the bootloader before loading (or reloading) the final application. 取而代之的是,您可以加载引导加载程序运行的应用程序,该应用程序会在加载(或重新加载)最终应用程序之前替换引导加载程序。

It would be nice if the implementation of the boot loader and update client software existed already too (at least for Windows). 如果引导加载程序和更新客户端软件的实现也已经存在(至少对于Windows),那将是很好的。

Any terminal emulator software such as TeraTerm, Hyperterminal, PuTTY etc. will support XMODEM transfer. 任何终端仿真器软件,例如TeraTerm,Hyperterminal,PuTTY等,都将支持XMODEM传输。 Implementing your own custom XMODEM sender is relatively straightforward with XMODEM source code widely available. 利用广泛可用的XMODEM源代码,实现自己的自定义XMODEM发送器相对简单。

And just out of curiosity - are there any good alternatives to DFU for devices with USB? 只是出于好奇-对于带有USB的设备,DFU是否有很好的替代品?

What I have done is implement a CDC/ACM device class USB stack in the bootloader so that it appears to the host as a serial port, and then used the same XMODEM code as before to do the data transfer. 我要做的是在引导加载程序中实现CDC / ACM设备类USB堆栈,以便它在主机上显示为串行端口,然后使用与以前相同的XMODEM代码进行数据传输。 This increases the size of the bootloader; 这会增加引导加载程序的大小; in my case to about 12kbytes. 在我的情况下约为12 KB。 It was implemented using a stack and CDC/ACM (virtual COM port) app-note provided by the chip vendor. 它是使用堆栈和芯片供应商提供的CDC / ACM(虚拟COM端口)应用笔记来实现的。 Strictly speaking for this you will need a USB vendor-id (VID) registered to your company; 严格来说,您需要向公司注册一个USB供应商ID(VID); you should not use just any old ID. 您不应该只使用任何旧ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM