当前位置:文档之家› 嵌入式设备远程程序升级的实现_英文

嵌入式设备远程程序升级的实现_英文

Vol.5No.3,Sept.2014Journal of Measurement Science and Instrumentation Sum No.19Realization of remote update technology for embedded equipment based on μC /OS-ⅡMENG Hui ,PAN Lian(School of Information Science and Engineering ,Wuhan University of Science and Technology ,Wuhan 430081,China )Abstract :Aiming at the inaccessible problem of remote embedded devices update and maintenance ,this paper presents a method u-sing general packet radio service (GPRS )to achieve update based on the embedded real-time operating system (RTOS )μC /OS-Ⅱ.It introduces architecture of the system first.And then it uses LPC1768chip as the central processing unit ,SIM900A module for da-ta transmission ,and SST25VF016B to store the data.To ensure accuracy of the data transmission ,cyclic redundancy code (CRC )is adopted.The software uses fixed bootstrap and mutable update program ,and thus the embedded devices can still normally start in case of update failure.Finally ,high stability and extensive adaptability of the system are verified by experimental data.Key words :μC /OS-Ⅱ;remote update ;general packet radio service (GPRS );embedded system CLD number :TP274Document code :AArticle ID :1674-8042(2014)03-0069-04doi :10.3969/j.issn.1674-8042.2014.03.013With the development of communication technology and embedded technology ,remote monitoring system based on wireless communication is more and more widely used.In the process of actual application ,we of-ten need to modify and update the program of the em-bedded system.Because of long-distance terminal e-quipment and poor working environment ,if maintainers have to come to the scene ,the maintenance cost will be very high and the program cannot be updated in real time.This paper puts forward the scheme that utilizes mobile communication technology ,embedded technolo-gy ,computer technology and Internet technology to im-plement a system that can update and monitor remote embedded equipment.It has great realistic significance for many engineering applications.1System compositionFig.1shows the structure of a remote update system.The system is mainly composed of embedded terminal e-quipment ,Internet ,server ,etc.Fig.1Structure of remote update systemThe embedded equipment sends data to remote server by general packet radio service (GPRS )communication module based on transmission control protocol /user dat-agram protocol (TCP /UDP ).On the server side ,the data is received with a matching transceiver.After the data being analyzed ,the server side registers the termi-nal equipment.Users can update and monitor remote embedded equipment by going through the browser.Thus it is easy to implement software download ,debug and update online from the remote terminals.2Hardware design of embedded e-quipmentHardware circuit diagram of embedded equipment is shown in Fig.2.Hardware platform of the control sys-tem is constructed by utilizing LPC1768processor as core.Peripheral circuit of the processor mainly compri-ses six modules :GPRS module ,memory module ,joint test action group (JTAG )debug module ,watchdog*Received date :2014-04-15Corresponding author :MENG Hui (menghui8592@yeah.net )(WTD )module ,data acquisition module and power managementmodule.Fig.2Hardware system of embedded equipmentThe whole working process of hardware system is as follows :Embedded terminal equipment of the processor LPC1768is responsible for control of the peripheral cir-cuit.It sends data to GPRS module via serial port.At the same time ,the server sends data to the processor through GPRS module.GPRS module uses SIM900A with good property and internally installed TCP /UDP protocol.It can send and receive data via GPRS.AT commands are allowed to establish TCP /UDP protocol stacks.All of AT com-mands begin with “AT ”and ends in “CR”to indicate that the instruction is over.By means of RS232asyn-chronous serial communication ,the program is more convenient.SIM900A interface circuit is shown in Fig.3.The storage device utilizes SST25VF016B with serial peripheral interface (SPI ),16Mb storage space and highspeed clock frequency of 80MHz.The SST25VF016B interface circuit is shown in Fig.4.Fig.3SIM 900A interfacecircuitFig.4SST 25VF 016B interface circuit3Embedded equipment program-ming3.1Overall software design schemeAs shown in Fig.5,the update process is as follows :1)GPRS module receives update package from the server when the embedded equipment is running follow-ing the application (APP )program.After the data is verified ,the central controller will write it to external memory.2)When data receiving is completed ,the central con-troller sets the update flag and then jumps to interior memory address of 0x000000to run bootstrap.3)At this moment ,the embedded equipment is star-ted and the central controller reads the update flag.Ac-cording to the flag ,the embedded equipment determines whether it needs to update program.4)If update is needed ,the central controller reads the update package from external memory ,and then writes it to interior memory.5)Once the update is finished ,the central controller automatically cleans up the update flag.The program will jump to interior memory addresses of 0x004000to run the newone.Fig.5Software design scheme3.2Design of bootstrapBootstrap starts running from interior memory at ad-dress 0x000000.Bootstrap is responsible for reading the update package from external memory and then writing it to interior memory.During this process ,the central controller will erase first and then program the internal flash memory ,and the in application programming (IAP )function could be called.Table 1shows the IAP commands.The command handler sends the status code INVALID COMMAND when receiving an undefined command.The IAP routine resides at 0x0x1ffffff0loca-tion.Some key program codes are as follows :1)The IAP function could be called in the following way using C language.#define IAP LOCATION 0x1ffffff1.2)Define data structure or pointers to pass IAP com-mand table and result table to IAP function :7Journal of Measurement Science and Instrumentation Vol.5No.3,Sept.2014Unsigned long command[5];Unsigned long result[3];3)Define pointer to function type,which takes two parameters and returns“void”.Note the IAP returns theresult with the base address of the table residing inR1.Typedef void(*IAP)(unsigned int[],unsigned int[]);IAP iap entry;4)Set function pointeriap entry=(IAP)IAP LOCATION.Whenever you wish to call IAP,you could use the following statement.iap entry(command,result).Table1IAP commandsIAP command CommandcodeDescriptionPrepare sector(s)for“write”opera-tion 50This command must be executed be-fore executing“CopyRAM toFlash”or“Erase sector(s)”com-mandCopyRAM to flash 51This command is used to programthe flash memoryErase sector(s)52This command is used to erase a sector or multiple sectors of on-chip Flash memory3.3Implementation of App programs The App program constitutes embedded real-time op-erating system(RTOS)μC/OS-Ⅱ.It starts executing at address0x00004000.It is primarily responsible for col-lecting data,translating and saving the update package to the external memory,and then setting up the flag which is stored in the external memory of processor.It is core program of the embedded equipment.The entire system is controlled byμC/OS-Ⅱ,which schedules the tasks,and allocates resources for each of the tasks effec-tively.Thus the system reliability is improved.For the update,App program is needed to deal with two aspects of the problems.1)The design of communication protocol.The server will split the update package into smaller chunks on a fixed-size value because the update package is quite large.The size of each chunk is set at512bit.If it is less than512bit,the system will fill up0x00later.Ta-ble2shows the data format of receiving update pack-age.Table2Data format of receiving update packageType Head ID Data CRC Length16bit32bit8bit512ˑ8bit16bit519ˑ8bit After embedded equipment receives the update pack-age,it recalculates cyclic redundancy code(CRC)code and compares the new code with the received code.The same CRC indicates that transmitted data and received data are consistent and embedded equipment will send back an ACK signal to the server.If no ACK signal is received within the certain period of time,the server re-transmission package is in prescribed number.This mechanism could prevent the external interference,so that it provides stability and reliability for the wireless communication between the server and the embedded e-quipment.2)The priority of a task is the key to manage the whole system.In order to implement more complex functionality,the system usually should be divided into multiple modules.These modules mainly have the fol-lowing task functions,as shown in Table3.Table3Task configurationTask nameTaskpriorityStacksize(bit)Task function Data collecting6128Task sampTerminal receiving7128Task uart0revTerminal sending8128Task uart0sendGPRS data sending9128Task send Updating10128Task updat4Measures of improving system stabilityIn the process of remote update,due to some reasons such as distance,the embedded equipment is unable to avoid network congestion and network packet classifica-tion,etc.These faults always lead to updating failure.Reliable program and hardware mechanism can ensure the remote update success.The following measures are taken to guarantee reliability of the system to dispose of network packet classification.Usually,in the period of updating the remote device,server will transmit data to multiple devices at the same time.Network packets will be broken up into smaller ones in the transmission process.A packet data of1024 byte may be separated into two packets of500byte and 524byte.Embedded terminals do not contain reassemb-ling package mechanism.Therefore,the packets sent by the server are set at512byte per frame size.These set-tings can ensure stability of the transmission.For process equipment with unexpected power outage,in the process of the remote terminal updating,unexpected power outage may cause update failure.In order to pre-vent the embedded device from being started because of the power outage,the system uses Boot Loader and App mode.After receiving the whole update package,the e-quipment does the final update to ensure that the equip-ment boots normally in accident cases.17MENG Hui,et al./Realization of remote update technology for embedded equipment based onμC/OS-ⅡBy analyzing a large amount of statistical data ,it can be seen from Fig.6that in the same signal strengths ,the larger the update package ,the longer the updating time.However ,under the different signal strengths ,the stron-ger the signal ,the shorter the transmissiontime.Fig.6Test results of update5ConclusionThe purpose of this paper is to study a convenient and effective application update scheme and solve the issues that need to on-site maintenance in the traditional way.At the same time ,this system effectively realizes remote transmission of information with development of the GPRS mobile communication technology.The system can be widely used in power monitoring ,data collection in harsh environments ,flash warning and agricultural monitoring.Experiments show that the system has good flexibility with low cost to improve quality and efficien-cy of maintenance and management.References[1]JIANG Jian-hu ,ZHANG Zhen-jiang.Water quality monito-ring system based on GPRS and GPS.Techniques of Auto-mation and Applications ,2006,25(8):66-68,81.[2]Altun A A ,BascifciN.A wireless sensor network based onzigbee forECG Monitoring.In :Proceedings of the 5th Inter-national Conference on Application of Information and Com-munication Technologies (AICT ),Baku ,Azerbaijan ,2011:1-5.[3]Philips Semiconductors.Using IAP for LPC2000ARM de-vices.[2013-10-25].http ://www .nxp.com /documents /application note /AN10256.pdf.[4]SUN Hong-yu ,XIANG Yang ,SUN Yao-ru ,et al.Motor i-maginary-based BCI for controlling a remote car.Journal ofMeasurement Science and Instrumentation ,2012,3(2):200-204.[5]ZHAI Shun ,WANG Wei-hong ,ZHANG Kan ,et al.IOTSMS alarm system based on SIM900A.Modern Electronics Technique ,2012,35(5):86-89.[6]CHANG Chao ,XIAN Xiao-dong ,HU Ying.Design of pre-cision agriculture remote environment monitoring systembased on WSN.Chinese Journal of Sensors and Actuators ,2011,24(6):879-883.[7]YU Hong-bo ,LI Hui.Design and implementation of porta-ble GSM wireless gas warning system.Control and Instru-ments in Chemical Industry ,2011,38(11):1360-1363.[8]LIU Run-hua ,ZhANG Ya-nan ,WANG Fei-fei ,et al.Beam-pumping unit operation condition monitoring system design.Computer Measurement and Control ,2011,19(12):2961-2964.[9]YUAN Yao-dong ,ZHANG Ai-jun.Wireless sensing systemfor environmental humidity and temperature monitoring.Journal of Measurement Science and Instrumentation ,2013,4(3):267-271.基于μC /OS-Ⅱ的嵌入式设备远程程序升级的实现孟辉,潘炼(武汉科技大学信息科学与工程学院,湖北武汉430081)摘要:针对远距离嵌入式设备程序升级和维护的繁琐的问题,提出一种基于μC /OS-Ⅱ操作系统平台的GPRS 远程程序升级的设计方案。

相关主题