CN106708592B - Microcontroller and code burning method for microcontroller - Google Patents

Microcontroller and code burning method for microcontroller Download PDF

Info

Publication number
CN106708592B
CN106708592B CN201710056600.3A CN201710056600A CN106708592B CN 106708592 B CN106708592 B CN 106708592B CN 201710056600 A CN201710056600 A CN 201710056600A CN 106708592 B CN106708592 B CN 106708592B
Authority
CN
China
Prior art keywords
program storage
storage unit
burning
bytes
code file
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.)
Active
Application number
CN201710056600.3A
Other languages
Chinese (zh)
Other versions
CN106708592A (en
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.)
Beijing Epcmicro Technology Co ltd
Original Assignee
Beijing Epcmicro Technology 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 Beijing Epcmicro Technology Co ltd filed Critical Beijing Epcmicro Technology Co ltd
Priority to CN201710056600.3A priority Critical patent/CN106708592B/en
Publication of CN106708592A publication Critical patent/CN106708592A/en
Application granted granted Critical
Publication of CN106708592B publication Critical patent/CN106708592B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/654Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Test And Diagnosis Of Digital Computers (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a microcontroller and a code burning method for the microcontroller, wherein the method comprises the following steps: a communication interface for communicating with an external processing unit; a first program storage unit for storing an operation code file; a second program storage unit for storing a code file identical to the code file; and the program storage control unit is used for controlling a communication interface to be connected with the first program storage unit or the second program storage unit. The invention realizes that the first program storage unit is automatically switched to the second program storage unit when the first program storage unit is broken, thereby reducing the reject ratio of the MCU chip. A spare second program storage unit is formed through one-time burning, when the first program storage unit is broken down, burning is not needed to be conducted again, and burning times are reduced.

Description

Microcontroller and code burning method for microcontroller
Technical Field
The invention relates to the technical field of internet, in particular to a microcontroller and a code burning method for the microcontroller.
Background
A Micro Control Unit (MCU), also called a single-chip microcomputer or a single-chip microcomputer, is a computer that properly reduces the frequency and specification of a central processing Unit, and integrates peripheral interfaces such as a memory, a counter, a USB, an a/D conversion, a UART, a PLC, a DMA, and the like, even an LCD driving circuit, on a single chip to form a chip-level computer, which is used for different combined control in different application occasions. Such as mobile phones, PC peripherals, remote controls, automotive electronics, industrial stepper motors, robotic arm controls, etc., see the silhouette of the MCU. The MCU comprises a built-in program memory for storing programs executed by the MCU. The program memory can be a read-only memory or a flash memory, the flash memory is widely applied at present, the existing burning software burns codes to one position of the flash memory during burning, the flash memory is easy to damage after repeated erasing or in a severe environment, and the yield of the built-in flash memory is an important factor directly influencing the yield of the MCU. In order to improve the yield of the MCU, it is necessary to reduce the influence of the defective rate of the embedded flash memory on the MCU.
Disclosure of Invention
In view of the above, the present invention has been made to provide a microcontroller and a burning method for the microcontroller that overcome or at least partially solve the above problems.
According to an aspect of the present invention, there is provided a microcontroller comprising:
a communication interface for communicating with an external processing unit;
a first program storage unit for storing an operation code file;
a second program storage unit for storing a code file identical to the code file;
and the program storage control unit is used for controlling a communication interface to be connected with the first program storage unit or the second program storage unit.
Optionally, the program storage control unit includes:
the detection subunit is used for detecting the number of bytes stored in the first program storage unit when the microcontroller is powered on;
and the comparison unit is used for comparing the detected byte number with a preset threshold value, controlling the communication interface to be connected with the first program storage unit if the detected byte number is consistent with the preset threshold value, and controlling the communication interface to be connected with the second program storage unit if the detected byte number is inconsistent with the preset threshold value.
The invention also provides a code burning method for the microcontroller, which is characterized by comprising the following steps:
sending the code file to a microcontroller;
burning bytes in the code file into a first program storage unit through a program storage control unit;
and burning the bytes in the code file into a second program storage unit through a program storage control unit.
Optionally, burning bytes in the code file into the first program storage unit; burning bytes in the code file into the first program storage unit specifically includes: s1, burning a predetermined number of bytes in the code file into the first program storage unit, and burning a predetermined number of bytes into the second program storage unit; and S2, repeating the step S1, and burning the codes in the code file in sequence until the codes in the code file are all burned in the first program storage unit and the second program storage unit.
Optionally, the predetermined number of bytes is 1 byte.
Optionally, burning bytes in the code file into the first program storage unit; burning bytes in the code file into a second program storage unit specifically comprises: burning bytes in the code file into a first program storage unit; after all bytes in the code file are burned into the first program storage unit, the bytes in the code file are burned into the second program storage unit.
The technical scheme provided in the embodiment of the application at least has the following technical effects or advantages:
the flash memory built in the MCU is designed into a double-memory structure, so that when the first program storage unit is damaged, the second program storage unit is automatically switched to, and the reject ratio of the MCU chip is reduced.
A spare second program storage unit is formed through one-time burning, when the first program storage unit is broken down, burning is not needed to be conducted again, and burning times are reduced.
In the embodiments of the present invention, the above description is only an outline of the technical solution of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood, and the above and other objects, features and advantages of the present invention will be more clearly understood.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 shows a block diagram of a microcontroller according to the invention;
FIG. 2 is a flow chart of a code burning method proposed by the present invention;
FIG. 3 shows a specific code burning method proposed by the present invention;
fig. 4 shows a code burning method according to a specific embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The present application provides a microcontroller, as shown in fig. 1, comprising:
a communication interface 100 for communicating with an external processing unit;
a first program storage unit 200 for storing an operation code file;
a second program storage unit 300 for storing the same code file as the above-mentioned code file;
a program storage control unit 400 for controlling a communication interface to be connected with the first program storage unit or the second program storage unit.
JTAG is used for testing chips at first, and the basic principle of JTAG is to define a TAP (Test Access Port) inside a device to Test internal nodes through a special JTAG Test tool. JTAG test allows a plurality of devices to be connected in series through JTAG interfaces to form a JTAG chain, and can realize the test of each device. Nowadays, the JTAG interface is also commonly used to implement ISP (In-System programming) and burn FLASH and other devices. In consideration of the fact that codes are burned in the program memory when the MCU chip is manufactured and the program memory is tested when the MCU is powered on, the JTAG interface is preferably used as the communication interface, and other communication interfaces can be used.
And each time the MCU is powered on, the program storage control unit detects the first program storage unit and determines whether to switch the communication interface to be connected with the second program storage unit or not according to the detection result. According to the method and the device, the program memory inside the microcontroller is designed into a double-memory structure, so that when internal hardware detects that the first program memory is replaced, the program memory is automatically switched to the second program memory unit. The structural design of the dual memory can reduce the reject ratio of chip production.
The number of bytes of the code stored in the actual program storage unit is generally fixed, and if the number of bytes stored in the program storage unit changes, the code can be considered to be damaged. As a preferred embodiment, the program storage control unit includes:
the detection subunit is used for detecting the number of bytes stored in the first program storage unit when the microcontroller is powered on;
and the comparison unit is used for comparing the detected byte number with a preset threshold value, controlling the communication interface to be connected with the first program storage unit if the detected byte number is consistent with the preset threshold value, and controlling the communication interface to be connected with the second program storage unit if the detected byte number is inconsistent with the preset threshold value.
Through the embodiment, whether the first program storage unit is bad or not can be quickly and efficiently determined, and the first program storage unit is automatically switched to the second program storage unit under the condition that the first program storage unit is bad, so that the normal work of the MCU chip is ensured.
In order to implement the dual-program storage structure of the microcontroller, as shown in fig. 2, the present application further provides a code burning method, which specifically includes:
s01, sending a code file to the microcontroller;
s02, burning bytes in the code file into a first program storage unit through a program storage control unit;
and S03, burning the bytes in the code file into a second program storage unit through a program storage control unit.
The burning method can be realized through burning software which runs on a PC.
As a burning method, burning bytes in a code file into a first program storage unit; burning the bytes in the code file into the first program storage unit may specifically include: s1, burning a predetermined number of bytes in the code file into the first program storage unit, and burning a predetermined number of bytes into the second program storage unit; and S2, repeating the step S1, and burning the codes in the code file in sequence until the codes in the code file are all burned in the first program storage unit and the second program storage unit.
One specific embodiment implemented according to the burning method is shown in fig. 4:
s21, running burning software;
s22, opening a BIN file;
s23, instructing to read a byte from the BIN file;
s24, judging whether reading is successful or not;
s25, if the reading is successful, burning the read byte into a first program storage unit;
s26, if the reading is not successful, the burning software is closed;
s27, after the step S25, burning the bytes into a second program storage unit, and then repeatedly executing the step S3 until the burning software is closed.
In this embodiment, a byte-by-byte burning method is adopted, and the first program storage unit and the second program storage unit are alternately burned, so that the burning of the first program storage unit is completed, and then the burning of the second program storage unit is completed. In a variant embodiment, instead of programming byte by byte, programming every few bytes may be used, which may be determined by the hardware conditions of the device.
As another burning method, burning bytes in the code file into a first program storage unit; burning bytes in the code file into a second program storage unit specifically comprises: burning bytes in the code file into a first program storage unit; after all bytes in the code file are burned into the first program storage unit, the bytes in the code file are burned into the second program storage unit.
The burning time of the burning mode is slightly long, but the burning hardware does not need to be switched back and forth between the first program storage unit and the second program storage unit, so that the consumption of the burning hardware is reduced.
By the burning method, programming can be performed at one time, and the codes can be burned into the 2 storage units simultaneously, so that when the first program storage unit is damaged, burning is not required to be performed again, and the first program storage unit is directly switched to the second program storage unit.
Based on the microcontroller and the burning method for the microcontroller described in the embodiments of the present application, those skilled in the art can understand that other embodiments of the microcontroller and its various modifications belong to the scope of the present application.
The technical scheme provided in the embodiment of the application at least has the following technical effects or advantages:
the algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the components of a gateway, proxy server, system according to embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (3)

1. A microcontroller, wherein a program memory inside the microcontroller is designed as a dual memory structure, comprising:
a communication interface for communicating with an external processing unit;
a first program storage unit for storing an operation code file;
a second program storage unit for storing a code file identical to the code file;
the program storage control unit is used for controlling a communication interface to be connected with the first program storage unit or the second program storage unit, and is also used for burning bytes in the code file into the first program storage unit; burning bytes in the code file into a first program storage unit specifically comprises: s1 burning a predetermined number of bytes in the code file into the first program storage unit and burning a predetermined number of bytes into the second program storage unit at the same time, S2 repeating the step S1, and burning the code files in sequence until the codes in the code file are all burned into the first program storage unit and the second program storage unit; or
Burning bytes in the code file into a first program storage unit, and burning the bytes in the code file into a second program storage unit after burning the bytes in the code file into the first program storage unit;
the program storage control unit detects the first program storage unit when the microcontroller is powered on each time, and if the number of bytes stored in the first program storage unit changes, the communication interface is switched to be connected with the second program storage unit;
the program storage control unit includes:
the detection subunit is used for detecting the number of bytes stored in the first program storage unit when the microcontroller is powered on;
and the comparison unit is used for comparing the detected byte number with a preset threshold value, controlling the communication interface to be connected with the first program storage unit if the detected byte number is consistent with the preset threshold value, and controlling the communication interface to be connected with the second program storage unit if the detected byte number is inconsistent with the preset threshold value.
2. A method for burning codes into a microcontroller as claimed in claim 1, wherein the program memory inside the microcontroller is designed as a dual memory structure, the method comprising:
sending the code file to a microcontroller;
burning bytes in the code file into a first program storage unit through a program storage control unit;
burning bytes in the code file into a second program storage unit through a program storage control unit;
when the microcontroller is powered on each time, the first program storage unit is detected, and if the number of bytes stored in the first program storage unit changes, the communication interface is switched to be connected with the second program storage unit, which specifically comprises the following steps: when the microcontroller is powered on, detecting the number of bytes stored in the first program storage unit, comparing the detected number of bytes with a preset threshold value, if the detected number of bytes is consistent with the preset threshold value, controlling the communication interface to be connected with the first program storage unit, and if the detected number of bytes is inconsistent with the preset threshold value, controlling the communication interface to be connected with the second program storage unit;
burning bytes in the code file into a first program storage unit; burning bytes in the code file into a first program storage unit specifically comprises: s1 burning a predetermined number of bytes in the code file into the first program storage unit and burning a predetermined number of bytes into the second program storage unit at the same time, S2 repeating the step S1, and burning the code files in sequence until the codes in the code file are all burned into the first program storage unit and the second program storage unit; or
The method comprises the steps of burning bytes in a code file into a first program storage unit, and burning the bytes in the code file into a second program storage unit after the bytes in the code file are all burned into the first program storage unit.
3. The code burning method of claim 2, further characterized in that the predetermined number of bytes is 1 byte.
CN201710056600.3A 2017-01-25 2017-01-25 Microcontroller and code burning method for microcontroller Active CN106708592B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710056600.3A CN106708592B (en) 2017-01-25 2017-01-25 Microcontroller and code burning method for microcontroller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710056600.3A CN106708592B (en) 2017-01-25 2017-01-25 Microcontroller and code burning method for microcontroller

Publications (2)

Publication Number Publication Date
CN106708592A CN106708592A (en) 2017-05-24
CN106708592B true CN106708592B (en) 2021-12-03

Family

ID=58909042

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710056600.3A Active CN106708592B (en) 2017-01-25 2017-01-25 Microcontroller and code burning method for microcontroller

Country Status (1)

Country Link
CN (1) CN106708592B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622253A (en) * 2012-03-09 2012-08-01 瑞斯康达科技发展股份有限公司 Singlechip and method for upgrading singlechip on line
CN102855151A (en) * 2012-08-21 2013-01-02 武汉电信器件有限公司 Optical module firmware in-application upgrading method capable of not interrupting service
CN102890657A (en) * 2012-10-10 2013-01-23 深圳市航盛电子股份有限公司 Method for reducing data read-write errors of EEPROM (electrically erasable programmable read-only memory)

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW535161B (en) * 1999-12-03 2003-06-01 Nec Electronics Corp Semiconductor memory device and its testing method
JP4184586B2 (en) * 2000-09-28 2008-11-19 株式会社東芝 Semiconductor memory device
CN102364430B (en) * 2010-09-17 2013-07-31 杭州士兰微电子股份有限公司 Microcontroller for supporting multi-programming on one time programmable memory and programming method
US8839039B2 (en) * 2012-01-24 2014-09-16 Nvidia Corporation Initialization of GPU using ROM-based initialization unit and programmable microcontroller
WO2013141308A1 (en) * 2012-03-22 2013-09-26 日本電気株式会社 Distributed storage system, storage control method and program
CN103744689A (en) * 2013-12-04 2014-04-23 苏州佳世达光电有限公司 Electronic device and starting method thereof
CN103914393B (en) * 2014-04-11 2017-01-11 四川华拓光通信股份有限公司 MCU-based (microprogrammed control unit-based) non-loss FLASH storage update method
CN105243708B (en) * 2015-09-22 2017-08-29 中国船舶重工集团公司第七一八研究所 Blocking routine and Redundant Control framework in a kind of smart lock
CN105354061A (en) * 2015-11-05 2016-02-24 邦彦技术股份有限公司 Method and system for protecting MCU working program
CN105740034A (en) * 2016-04-13 2016-07-06 深圳市高巨创新科技开发有限公司 System and method for upgrading firmware of MCU on line
CN105975322A (en) * 2016-06-15 2016-09-28 珠海格力电器股份有限公司 Device and method for program update and microcontroller

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622253A (en) * 2012-03-09 2012-08-01 瑞斯康达科技发展股份有限公司 Singlechip and method for upgrading singlechip on line
CN102855151A (en) * 2012-08-21 2013-01-02 武汉电信器件有限公司 Optical module firmware in-application upgrading method capable of not interrupting service
CN102890657A (en) * 2012-10-10 2013-01-23 深圳市航盛电子股份有限公司 Method for reducing data read-write errors of EEPROM (electrically erasable programmable read-only memory)

Also Published As

Publication number Publication date
CN106708592A (en) 2017-05-24

Similar Documents

Publication Publication Date Title
CN103823698A (en) Method and device for programming and starting FPGA target program and DSP target program
CN101211266A (en) FPGA automatic downloading and on-line upgrading process
US11113222B2 (en) NAND switch
CN107479918B (en) Reconfigurable FPGA (field programmable Gate array) model for MCU (microprogrammed control Unit) burning
US20140149815A1 (en) System and method for programming chips on circuit board through boundary scan technology
JPS62249264A (en) Data processor
CN105278974A (en) Chip starting method and device
CN103455419A (en) Field programmable gate array platform and testing method thereof
CN106708592B (en) Microcontroller and code burning method for microcontroller
CN112256514B (en) SDIO interface test method and device, storage medium and terminal
US20080071979A1 (en) Automatically detecting types of external data flash devices
CN205103653U (en) Vehicle control unti data process system
CN104111845A (en) Processing device and system program changing method
CN105242664A (en) Automobile controller data processing system and method
CN104142839A (en) Method for avoiding initialization failure of audio frequency chip
CN202331426U (en) Dynamic loading system of field programmable gate array
KR102523270B1 (en) eFuse OTP memory supporting I2C communication and operating method thereof
CN213690596U (en) Program detection device and electronic equipment
JP6062795B2 (en) Semiconductor device
CN111596199B (en) Test chip, integrated circuit test method and system and detection equipment
CN204272318U (en) EMMC tool and television system
CN106293620A (en) The method of parameter in intel detection of platform Flash Rom
CN202257570U (en) FPGA (Field Programmable Gate Array) configuration system based on singlechip
CN112395224A (en) Data processing method and system, concatenation device and electronic equipment
CN112464613A (en) Digital circuit robustness verification method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant