A method for upgrading the firmware of a lighting power supply via NFC

Through NFC wireless communication technology, the problem of disassembly and disassembly during the firmware upgrade of lighting power supply is solved, and efficient and low-cost firmware upgrades and software repairs are achieved.

CN119248326BActive Publication Date: 2025-04-04ZHONGSHAN DONE LIGHTING TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411773410.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-04-04
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

When existing lighting power supplies require firmware upgrades, function modifications or software bug repairs, they usually require disassembly of lamps or disassembly of wires, resulting in high cost and low efficiency.

Method used

It uses NFC wireless communication method to interact with the lighting power supply to upgrade the lighting power supply firmware and repair software bugs without disassembling the lamp.

Benefits of technology

Through NFC wireless communication, the efficiency of firmware upgrades is significantly improved, construction costs are reduced, and the upgrade process is simplified.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248326B_ABST
    Figure CN119248326B_ABST
Patent Text Reader

Abstract

A method for upgrading the firmware of a lighting power supply through NFC, comprising a host system and a slave system interacting with each other; the host system comprises the following steps: reading the slave uid, selecting the corresponding card according to the uid, turning on the FTM function of the register, sending data of a specified length to the slave system, judging whether the read register is equal to 1; reading the data length L replied by the slave system, judging whether there is a low pulse event, reading the register is equal to 1, reading the register to obtain the data length L, performing corresponding business processing after receiving the data and preparing a reply, reading the register is equal to 1 or 0, writing the data to be replied to MAILBOX, and completing the reply.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of LED power supply firmware upgrade, and in particular to a method for upgrading the firmware of a lighting power supply via NFC. Background Art

[0002] Drivers for lamps, especially those for outdoor use, are usually sealed with glue for waterproofing. If you need to upgrade functions, change or modify software bugs, you need to remove the shell, which is very expensive. If you upgrade via wired mode, you need to remove the wires, which increases the construction cost. Summary of the invention

[0003] To solve the above problems, the present technical solution provides a method for upgrading the firmware of a lighting power supply via NFC.

[0004] To achieve the above purpose, the technical solution is as follows:

[0005] A method for upgrading the firmware of a lighting power supply via NFC, comprising a host system and a slave system interacting with each other;

[0006] The host system comprises the following steps:

[0007] S101, read the slave uid in interaction with the slave system, if the reading is successful, start the next step, if the reading is unsuccessful, repeat the reading;

[0008] S102, select the corresponding card according to the uid;

[0009] S103, set the MB_EN bit of the register MB_CTRL_Dyn to 1 to enable the FTM function;

[0010] S104, send a Write Message using the 0xAA command to send data of the specified length to the slave system;

[0011] S105, determine whether the HOST_PUT_MSG bit and the HOST_CURRENT_MSG bit of the read register MB_CTRL_Dyn are equal to 1, if so, it indicates that there is data returned to start the next step, if not, repeat this step;

[0012] S106, use the 0xAB command to read the data length L replied by the slave system;

[0013] S107, use 0xAC command to read the data replied by the slave, the length is L;

[0014] The slave system comprises the following steps:

[0015] S201, determine whether the gpo pin has a low pulse event, if yes, start the next step, if not, repeat this step;

[0016] S202, read the MB_EN bit of the register MB_CTRL_Dyn, whether the HOST_PUT_MSG bit and the HOST_CURRENT_MSG bit are equal to 1, if yes, start the next step, if not, repeat the step;

[0017] S203, read register MB_LEN_DYN to obtain data length L;

[0018] S204, read data with a length of L from MAILBOX;

[0019] S205, after receiving the data, perform corresponding business processing and prepare a reply;

[0020] S206, read the MB_EN bit, HOST_PUT_MSG bit and RF_PUT_MSG bit of the register MB_CTRL_Dyn, check whether MB_EN is equal to 1, HOST_PUT_MSG and RF_PUT_MSG are equal to 0, if yes, start the next step, if no, repeat the step;

[0021] S207, write the data to be replied to into MAILBOX, and the reply is completed.

[0022] In some embodiments, it also includes a region selection operation step;

[0023] S301, runs in the boot area after power-on;

[0024] S302, check the integrity of the AP area, if it is complete, start the next step, if not, check whether the host computer online detection command is received, if the command is detected, start the firmware update, if not, return;

[0025] S303, if the host computer online detection command is not received within 0.2 seconds, jump to the APP area to run, and then check whether the host computer online detection command is received. If so, start the firmware update, if not, return.

[0026] In some embodiments, the area selection operation step adopts a communication protocol format of 1 byte command, 2 bytes serial number, variable length data, and 2 bytes of check CRC16-CCITT1021.

[0027] In some embodiments, a firmware update process is also included;

[0028] S401, the host computer software is opened and run;

[0029] S402, loading the MCU firmware into the memory, and calculating the size and checksum of the firmware;

[0030] S403, send an online detection command to determine whether the lower computer has a reply, if yes, start the next step, if no, re-receive;

[0031] S404, send a handshake command, and determine whether the lower computer has a reply. If yes, start the next step, if no, start receiving again;

[0032] S405, send a command to obtain the bootloader version number, and determine whether the lower computer has a reply. If yes, start the next step, if not, receive again;

[0033] S406, send an erase AP area command, and determine whether the lower computer has a reply, if yes, start the next step, if no, receive again;

[0034] S407, send a command to write the AP area firmware, and determine whether the lower computer has a reply. If yes, start the next step, if no, receive again;

[0035] S408, send a command to write the AP area firmware, and determine whether the lower computer has a reply. If yes, start the next step, if no, receive again;

[0036] S409, confirm whether all firmware data has been sent, if yes, send a verification command, if no, return to step S408;

[0037] S410, re-read the data written to the AP area, calculate the check value, compare it with the check value of the host computer, and determine whether it is consistent.

[0038] The beneficial effects of this application are:

[0039] This application uses NFC wireless communication with the lamp, and then upgrades the lamp program and corrects software bugs without disassembling the lamp, greatly improving the upgrade efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for describing the embodiments are briefly introduced below.

[0041] Figure 1 is a schematic diagram of the framework structure of an embodiment of the present invention;

[0042] Figure 2 is a schematic diagram of a host system flow chart of an embodiment of the present invention;

[0043] Figure 3 is a schematic diagram of a slave system flow chart of an embodiment of the present invention;

[0044] Figure 4is a schematic diagram of firmware update steps in an embodiment of the present invention;

[0045] Figure 5 It is a schematic diagram of the firmware update process of an embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to make the technical problems, technical solutions and beneficial effects solved by the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0047] Please refer to Figure 1-5 As shown in the figure, a method for upgrading the firmware of a lighting power supply via NFC is provided, which uses the Fast transfer mode of the ST25DV04KC chip and the bidirectional data transmission between the NFC host and the slave as the basis to realize the firmware upgrade of the lighting power supply via NFC wireless mode.

[0048] This application adopts NFC near-field communication. You can use a mobile phone or Donlim Power's NFC programmer to upgrade the lighting power firmware. The communication protocol standard is ISO15693, and the power supply end NFC is based on the ST25DV04KC chip.

[0049] The whole system consists of two parts: a mobile phone with NFC function and APP or a programmer with NFC function, and a lamp driver.

[0050] Fast transfer mode implementation method (host system):

[0051] The master reads the slave's UID.

[0052] Select the card based on UID.

[0053] Set the MB_EN bit in the MB_CTRL_Dyn register to 1 to enable the FTM function.

[0054] Send a Write Message with the 0xAA command to send data of the specified length to the slave.

[0055] Read the HOST_PUT_MSG bit and HOST_CURRENT_MSG bit of the MB_CTRL_Dyn register. Are they both equal to 1? If yes, it means that there is data returned. If not, repeat this operation.

[0056] Use the 0xAB command to read the data length L replied by the slave.

[0057] Use the 0xAC command to read the data replied by the slave, the length is L.

[0058] Fast transfer mode implementation method (slave system):

[0059] Is there a low pulse event on the GPO pin? If not, continue waiting.

[0060] Read the MB_EN bit, HOST_PUT_MSG bit and HOST_CURRENT_MSG bit of the MB_CTRL_Dyn register. Are they all equal to 1? If not, return to 1.

[0061] Read register MB_LEN_DYN to obtain the data length L.

[0062] Read data of length L from MAILBOX.

[0063] After receiving the data, perform corresponding business processing and prepare a reply.

[0064] Read the MB_EN bit, HOST_PUT_MSG bit and RF_PUT_MSG bit of the MB_CTRL_Dyn register. Are MB_EN equal to 1 and HOST_PUT_MSG and RF_PUT_MSG equal to 0? If not, repeat this operation.

[0065] Write the data that needs to be replied to into MAILBOX and the reply is completed.

[0066] Application layer communication protocol, a protocol based on the Fast transfer mode protocol;

[0067] Protocol format: command (1 byte) + serial number (2 bytes) + data (variable length) + CRC16 (CCITT1021) checksum (2 bytes);

[0068] Command explanation of the application layer protocol: Note that the integer data has the high byte first;

[0069] Detect whether the device is online:

[0070] Master to slave: command 0X96, no data.

[0071] The slave responds to the master: command 0X96, no data. Note that if the program is running in the app area, it will not respond after receiving the command but will directly jump to the boot area to wait for the firmware update.

[0072] shake hands:

[0073] Host to slave: command 0X9F, encryption mode (1 byte), 0 means the firmware is not encrypted, 1 means the firmware is encrypted;

[0074] The slave device replies to the host: command 0X9F, device type (2 bytes), and the firmware update is performed only when the firmware type is consistent with the hardware device type being updated.

[0075] Query the version number:

[0076] Master to slave: command 0X9D, no data.

[0077] The slave device replies to the master device: command 0X9D, the data is a 2-byte version number + a 2-byte number of bytes of flash in a frame of data (expressed as PL).

[0078] Erase flash:

[0079] Host to slave: command 0X9C, data is 4 bytes, the number of bytes to be erased.

[0080] The slave device replies to the master device: command 0X9C, data is 1 byte, 1 indicates success, 0 indicates failure.

[0081] Write flash:

[0082] Master to slave: command 0X9B, data is a 4-byte address, 4-byte data length, and PL byte is the data to be written into the flash.

[0083] The slave device replies to the master device: command 0X9B, no data.

[0084] check:

[0085] Host to slave: command 0X99, data is 4 bytes of data length to be verified + 4 bytes of check value.

[0086] The slave replies to the host: command 0X99, the data is a 4-byte checksum value (calculated by the microcontroller itself), and the checksum is the cumulative sum of all bytes.

[0087] quit:

[0088] Host to slave: command 0X98, no data, after receiving the command, jump to the app area to run the app program.

[0089] The slave responds to the master: command 0X98, no data.

[0090] The main workflow:

[0091] Read the MCU firmware file:

[0092] The firmware supports original bin format and encrypted bin format. The original bin file format is the data image in the flash.

[0093] The 4 bytes starting from 0x200 stored in flash are the checksum, and the 3 bytes starting from 0x204 stored in flash are the size of the firmware. CHECKSUM refers to the cumulative sum of all bytes of the entire program but does not include the 8 bytes 0x200~0x207. The bit0 of the FLAG of the byte 0x207 is used to mark the integrity of the firmware. 0x208~0x209 are the device type DEVICETYPE.

[0094] Since the C compiler cannot write the checksum and size of the firmware into the firmware, two 4-byte constants (CHECKSUM and SIZE) are used in the code to occupy the address 0x200~0x207 to prevent the code from overwriting. The default value of CHECKSUM is 0x12345678 (the data corresponding to addresses 0x200~0x203 are 0x78, 0x56, 0x34, 0x12). The default value of SIZE is 0xfe000000 (the data corresponding to addresses 0x204~0x207 are 0x00, 0x00, 0x00, 0xfe). The default value of DEVICETYPE is 0x0001 (the data corresponding to addresses 0x208~0x209 are 0x01, 0x00) Note that this value is different for each type of device, which is used to tell the host computer software not to download the wrong firmware to the machine.

[0095] Note: CHECKSUM refers to the cumulative sum of all bytes in the entire firmware, excluding the 8 bytes 0x200~0x207. CHECKSUM, SIZE and DEVICETYPE use the little-endian storage format with the low byte first and the high byte last.

[0096] 0x200 CHECKSUM lowest byte

[0097] 0x201 CHECKSUM lower byte

[0098] 0x202 CHECKSUM upper byte

[0099] 0x203 CHECKSUM Highest Byte

[0100] 0x204 SIZE Lowest byte

[0101] 0x205 SIZE lower byte

[0102] 0x206 SIZE higher byte, the highest byte defaults to 0

[0103] 0x207 FLAG, bit0 is used to mark the integrity of the firmware. 0 means complete

[0104] 0x208 DEVICETYPE low byte

[0105] 0x209 DEVICETYPE high byte

[0106] Processing of firmware data

[0107] After the mobile phone APP reads the firmware into the memory, it calculates the firmware checksum (excluding the 8 bytes 0x200~0x207) and writes it to the location corresponding to CHECKSUM, and writes the firmware size to the location corresponding to SIZE. Write 0xff to the location of FLAG. After the firmware deposit is processed, it can be downloaded to the lower computer through NFC.

[0108] Command sequence:

[0109] 0x96 Detect whether the device is online. If there is a legal return, it means the device is online;

[0110] 0x9f Handshake. Tell the lower computer whether the firmware needs to be decrypted. The lower computer returns the device type. The upper computer decides the next action based on whether the firmware's DEVICETYPE is consistent with the device type returned by the lower computer.

[0111] 0x9d Get the version number of the bootloader;

[0112] 0x9c erase chip flash;

[0113] 0x9b Write data. Send the data processed in point 2 (processing of firmware data) to the lower computer, and send PL bytes each time. If the firmware is encrypted, send the data after byte 16 in point 4 (firmware encryption format).

[0114] 0x99 checksum. After receiving the checksum and length, the lower computer calculates the checksum based on the length and compares it with the checksum sent by the upper computer. If they are consistent, write 0 to the 0th bit of the FLAG position of the microcontroller. When the bootloader starts, check this position to know whether the program is complete. For processors such as ARM that read flash quickly, the checksum can be calculated in real time based on the SIZE size of the entire area to determine whether it is complete. If the 8-bit microcontroller reads flash slowly, only the 0th bit of FLAG is judged.

[0115] 0x98 Exit. After receiving the command, the lower computer jumps from the boot area to the app area to run the app area program.

[0116] Firmware encryption format:

[0117] The first 16 bytes are encrypted information. Among these 16 bytes, byte0~3 are all 0x88. Byte4 is the version number (currently 0x01, reserved for algorithm upgrades), byte5~7 is the length of the firmware (high byte first), byte8~11 is the firmware check value (high byte first), byte12~13 is the device type (high byte first), byte14~15 is the CRC (CCITT) check value of the entire encrypted file, the high byte is first, and these two bytes are written as 0 when calculating the check value. From byte16 onwards is the encrypted data. When operating the firmware update, send the 16th byte and subsequent data. The following is the data analysis of the first 16 bytes:

[0118] 0x00 Constant 0x88

[0119] 0x01 constant 0x88

[0120] 0x02 Constant 0x88

[0121] 0x03 Constant 0x88

[0122] 0x04 Version Number

[0123] 0x05 Firmware length, higher byte, the highest byte defaults to 0

[0124] 0x06 Firmware length, lower byte

[0125] 0x07 Firmware length, lowest byte

[0126] 0x08 Firmware checksum, highest byte

[0127] 0x09 Firmware checksum, higher byte

[0128] 0x0a Firmware checksum, lower byte

[0129] 0x0b Firmware checksum, lowest byte

[0130] 0x0c Device type, high byte

[0131] 0x0d Device type, low byte

[0132] 0x0e CRC (CCITT) checksum of the entire encrypted file, high byte

[0133] 0x0f CRC (CCITT) checksum of the entire encrypted file, low byte.

[0134] Bootloader operation logic

[0135] After the microcontroller is powered on, it will first run in the boot area. The program will first read the CHECKSUM and SIZE of APROM. If CHECKSUM is 0x12345678, it means it is native firmware. It will wait for the host computer to send a command for 0.2 seconds. If it does not receive a command within 0.2 seconds, it will jump to the app area. If CHECKSUM is another value, the program will calculate the actual check value based on SIZE. If it is equal to the read CHECKSUM, it will wait for the host computer to send a command for 0.2 seconds. If it does not receive a command within 0.2 seconds, it will jump to the app area. If it is not equal to the read CHECKSUM, it means that the app area program is incomplete, and the program will stay in the boot area waiting for the host computer's command. Note that some chips with slow flash reading speeds, such as 8-bit microcontrollers, only check whether the 0th bit of FLAG is equal to 0. If it is equal to 0, it means it is complete.

[0136] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of implementation of the present application. Other principles and basic structures that are the same or similar to those of the present application are within the protection scope of the present application.

Claims

1. A method for upgrading the firmware of a lighting power supply via NFC, characterized in that: Includes host systems and slave systems that interact with each other; The host system comprises the following steps: S101, read the slave uid in interaction with the slave system, if the reading is successful, start the next step, if the reading is unsuccessful, repeat the reading; S102, select the corresponding card according to the uid; S103, set the MB_EN bit of the register MB_CTRL_Dyn to 1 to enable the FTM function; S104, send a Write Message using the 0xAA command to send data of the specified length to the slave system; S105, determine whether the HOST_PUT_MSG bit and the HOST_CURRENT_MSG bit of the read register MB_CTRL_Dyn are equal to 1, if so, it indicates that there is data returned to start the next step, if not, repeat this step; S106, use the 0xAB command to read the data length L replied by the slave system; S107, use 0xAC command to read the data replied by the slave, the length is L; The slave system comprises the following steps: S201, determine whether the gpo pin has a low pulse event, if yes, start the next step, if not, repeat this step; S202, read the MB_EN bit, HOST_PUT_MSG bit and HOST_CURRENT_MSG bit of the register MB_CTRL_Dyn, and determine whether they are all equal to 1. If so, start the next step, if not, repeat the step; S203, read register MB_LEN_DYN to obtain data length L; S204, read data with a length of L from MAILBOX; S205, after receiving the data, perform corresponding business processing and prepare a reply; S206, read the MB_EN bit, HOST_PUT_MSG bit and RF_PUT_MSG bit of the register MB_CTRL_Dyn, determine whether MB_EN is equal to 1, HOST_PUT_MSG and RF_PUT_MSG are equal to 0, if yes, start the next step, if not, repeat the step; S207, write the data to be replied into MAILBOX, and reply is completed; It also includes the firmware update process; S401, the host computer software is opened and run; S402, loading the MCU firmware into the memory, and calculating the size and checksum of the firmware; S403, send an online detection command to determine whether the lower computer has a reply, if yes, start the next step, if no, re-receive; S404, send a handshake command, and determine whether the lower computer has a reply. If yes, start the next step, if no, start receiving again; S405, send a command to obtain the bootloader version number, and determine whether the lower computer has a reply. If yes, start the next step, if not, receive again; S406, send a command to erase the AP area, and determine whether the lower computer has a reply. If yes, start the next step, if no, receive again; S407, send a command to write the AP area firmware, and determine whether the lower computer has a reply. If yes, start the next step, if no, receive again; S408, send a command to write the AP area firmware, and determine whether the lower computer has a reply. If yes, start the next step, if no, receive again; S409, confirm whether all firmware data has been sent, if yes, send a verification command, if no, return to step S408; S410, re-read the data written to the AP area, calculate the check value, compare it with the check value of the host computer, and determine whether it is consistent.

2. A method for upgrading the firmware of a lighting power supply via NFC according to claim 1, characterized in that: It also includes a region selection operation step; S301, runs in the boot area after power-on; S302, check the integrity of the AP area, if it is complete, start the next step, if not, check whether the host computer online detection command is received, if the command is detected, start the firmware update, if not, return; S303, if the host computer online detection command is not received within 0.2 seconds, jump to the AP area to run, and then check whether the host computer online detection command is received. If so, start the firmware update, if not, return.

3. A method for upgrading the firmware of a lighting power supply via NFC according to claim 2, characterized in that: The area selection operation step adopts a communication protocol format of: 1 byte of command, 2 bytes of serial number, variable length of data, and 2 bytes of check CRC16-CCITT1021.

Citation Information

Patent Citations

  • Firmware upgrading method and battery management system

    CN113692065A

  • Lamp driver firmware upgrading scheme based on dali bus and dimming line

    CN117742754A