A method for realizing external SPIFlash initialization of an electrical port module PHY chip
Patent Information
- Application Number
- CN202311103065.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2043-08-30
AI Technical Summary
[0005]有鉴于现有技术的上述缺陷,本发明所要解决的技术问题是现有的电口模块PHY芯片外接SPI Flash初始化时,当image文件烧录出错或PHY芯片初始化image版本更新时,要向Flash中重新写入数据,则需要对Flash进行拆卸,然后再使用Flash编程器,无法反复初始化
[0027]本发明提供了一种实现电口模块PHY芯片的外接SPI Flash初始化的方法,将初始化映像存储在上位机之中,不需要再MCU之中额外占据存储空间去存储映像数据;并且能够在电口模块不拆卸的条件下进行映像的初始化与更新。除特殊情况下(如文件出错、断电、初始化期间拔出等)都可以成功完成初始化;在光模块已经组装完毕的情况下,通过其I2C接口来进行初始化,不需要将Flash拆卸下来。
Smart Images

Figure CN117009277B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electrical port module connection, and more particularly to a method for initializing the external SPI Flash of the PHY chip of an electrical port module. Background Technology
[0002] With the continuous development of the Internet, Ethernet switches, as the connection hubs of network devices, are also constantly evolving. 10 Gigabit switches are divided into two types based on the different transmission media used in their modules: optical modules using fiber optic cables as the transmission medium, and electrical modules using network cables as the transmission medium. Electrical modules are characterized by low power consumption, high performance, and compact design. Electrical modules can directly achieve 10G data transmission rates using existing copper cabling systems.
[0003] The core component of a 10 Gigabit Ethernet module is a PHY chip, used to implement data link layer transmission and reception to the physical medium. Inside the module, an MCU is also required to acquire data from the PHY chip via the MDIO interface and handle communication with the host computer. Since the PHY chip lacks internal ROM or Flash memory for data storage, it needs to store power-on data in external Flash memory for proper operation. The chip reads this data from the Flash memory upon power-up and initializes its internal components.
[0004] PHY chip manufacturers typically provide an initialization image, which the electrical module manufacturer needs to write into the Flash memory before the module can function properly. Currently, Flash data editing is generally done using an SPI Flash programmer. However, if the image file is burned incorrectly or the PHY chip initialization image version is updated, rewriting data into the Flash memory requires disassembling the Flash memory and then using a Flash programmer, which is extremely inconvenient. Summary of the Invention
[0005] In view of the aforementioned shortcomings of the prior art, the technical problem to be solved by the present invention is that when initializing the external SPI Flash of the PHY chip in the existing electrical port module, if the image file is burned incorrectly or the PHY chip initialization image version is updated, data needs to be rewritten to the Flash. This requires disassembling the Flash and then using a Flash programmer, making repeated initialization impossible. The present invention provides a method for initializing the external SPI Flash of the PHY chip in the electrical port module, which allows for repeated updating of SPI Flash data within the 10 Gigabit electrical port module without disassembly, thus achieving the function of repeated initialization of the external SPI Flash of the PHY chip in the electrical port module.
[0006] To achieve the above objectives, the present invention provides a method for initializing the external SPI Flash of the PHY chip in the electrical port module, comprising the following steps:
[0007] Step 1: The host computer sends an initialization command, causing the host computer to switch from the NORMAL state to the WAIT_READY state;
[0008] Step 2: The MCU reads the initialization instruction, transitions from the NORMAL state to the INIT_PREP state, and begins the initialization preparations.
[0009] Step 3: After the MCU completes its initial preparations, it transitions from the INIT_PREP state to the REQ_IMAGE state, waiting for image data to be transmitted from the host computer.
[0010] Step 4: The host computer receives the instruction from the MCU to request an image, transitions from the WAIT_READY state to the SEND_IMAGE state, and begins to transmit a set of image data to the MCU;
[0011] Step 5: After the host computer completes the image data transmission, it transitions from the SEND_IMAGE state to the WAIT_REQ state, waiting for the MCU to request data again;
[0012] Step 6: When the MCU receives a data transmission completion instruction, it transitions from the REQ_IMAGE state to the WRITE_IMAGE state and begins writing a set of data from the MCU to the PHY chip, and then the PHY chip writes it to the SPI Flash.
[0013] Step 7: The MCU has finished writing a set of data. When it does not receive an instruction from the host computer indicating that this set is the last set, it transitions from WRITE_IMAGE to REQ_IMAGE state, waiting for the host computer to send image data, and then repeats the process between steps 4 and 7. When it receives an instruction from the host computer indicating that this set is the last set, it transitions from WRITE_IMAGE to VER_IMAGE state to verify the data written to the SPI Flash.
[0014] Step 8: The host computer receives the start verification command sent by the MCU, transitions from the WAIT_REQ state to the WAIT_VER state, and waits for the MCU's verification result.
[0015] Step 9: MCU verification is complete. The MCU transitions from the VER_IMAGE state to the NORMAL state and begins normal operation.
[0016] Step 10: The host computer receives the verification completion instruction sent by the MCU and transitions from WAIT_VER to NORMAL state. The host computer displays that the initialization was successful. At this point, the external SPI Flash initialization of the PHY chip of the electrical port module is complete.
[0017] Furthermore, the host computer completes the state machine used for initialization, including the following states: NORMAL, WAIT_READY, SEND_IMAGE, WAIT_REQ, WAIT_VER, and ERROR.
[0018] Furthermore, the MCU completes the state machine used for initialization, including the following states: NORMAL, INIT_PREP, REQ_IMAGE, WRITE_IMAGE, VER_IMAGE, and ERROR.
[0019] Furthermore, the system includes a host computer, an MCU, a PHY chip, and an SPI Flash. The host computer interacts with the user, receives user commands to start or stop initialization, and performs various operations based on these commands. The host computer has a state machine that initializes the SPI Flash and works in conjunction with the state machine in the MCU to complete the initialization process. The host computer communicates with the MCU via an I2C interface, controlling the MCU. The MCU communicates with the PHY chip via an MDIO interface, controlling the PHY chip. The PHY chip communicates with the SPI Flash via an SPI interface, controlling the SPI Flash. Upon starting initialization, the host computer issues initialization commands and transmits initialization data. These commands and data are sequentially transmitted to the Flash memory via the MCU and PHY chip.
[0020] Furthermore, the MCU is used to receive various instructions from the host computer and perform various operations according to the instructions; the MCU has an MCU state machine set up inside, which is used to initialize the SPI Flash, and during the initialization process, it works together with the state machine in the host computer to complete the initialization process.
[0021] Furthermore, the MCU includes two communication interfaces, I2C and MDIO. It communicates with the host computer via I2C and with the PHY chip via MDIO.
[0022] Furthermore, the MCU includes status and control registers to store the current state of the MCU for the host computer to read, or to receive control commands from the host computer.
[0023] Furthermore, the status and control register description table of the Flash initialization image defined inside the MCU allows the host computer to determine the MCU's status, send instructions to the MCU, and determine whether the data transmission is complete through three registers implemented in the MCU.
[0024] Furthermore, the three registers implemented in the MCU include: INIT_STATE_CONTROL, MCU_INIT_STATE, and IMAGE_READY; among them, the INIT_STATE_CONTROL register is used to control whether the MCU starts initialization; the MCU_INIT_STATE register is used to indicate the initialization state of the MCU at this time; and the IMAGE_READY register is used to indicate whether the host computer has transferred the image file to the MCU.
[0025] Furthermore, it also includes the design of error codes, specifically several special values in the MCU_INIT_STATE register. If an error occurs during MCU operation during initialization, the MCU will detect it and set these values in the MCU_INIT_STATE register. After the host computer reads these values from the MCU_INIT_STATE register, it will interrupt the initialization process and report the error information to the user.
[0026] Technical effect
[0027] This invention provides a method for initializing the external SPI Flash of the PHY chip in an electrical port module. The initialization image is stored in the host computer, eliminating the need for additional storage space in the MCU to store the image data. Furthermore, image initialization and updates can be performed without disassembling the electrical port module. Initialization can be successfully completed except in special circumstances (such as file errors, power outages, or removal during initialization). When the optical module is already assembled, initialization is performed through its I2C interface without removing the Flash.
[0028] The following will further explain the concept, specific structure, and technical effects of the present invention in conjunction with the accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Attached Figure Description
[0029] Figure 1 This is a schematic diagram of a method for initializing an external SPI Flash of a PHY chip in an electrical port module according to a preferred embodiment of the present invention.
[0030] Figure 2 This is a state transition diagram of the initialization state machine of the host computer for a method of initializing the external SPI Flash of the PHY chip of the electrical port module according to a preferred embodiment of the present invention.
[0031] Figure 3 This is a state transition diagram of the MCU initialization state machine for a method of initializing the external SPI Flash of the PHY chip of the electrical port module according to a preferred embodiment of the present invention.
[0032] Figure 4 This is a description table of the status / control registers of the Flash initialization image defined inside the MCU for a method of initializing the external SPI Flash of the PHY chip of the electrical port module according to a preferred embodiment of the present invention;
[0033] Figure 5 This is a flowchart illustrating a preferred embodiment of the present invention of a method for initializing an external SPI Flash of a PHY chip in an electrical port module. Detailed Implementation
[0034] To make the technical problems to be solved, the technical solutions, and the beneficial effects of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present invention and are not intended to limit the present invention.
[0035] In the following description, specific details, such as particular internal procedures and techniques, are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will appreciate that the invention may be practiced in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of the invention with unnecessary detail.
[0036] like Figure 1 As shown, this invention provides a method for initializing an external SPI Flash of a PHY chip in an electrical port module, including a host computer, an MCU, a PHY chip, and an SPI Flash. The host computer communicates with the MCU via an I2C interface, and the host computer controls the MCU; the MCU communicates with the PHY chip via an MDIO interface, and the MCU controls the PHY chip; the PHY chip communicates with the SPI Flash via an SPI interface, and the PHY chip controls the SPI Flash. At the start of initialization, the host computer issues initialization commands and transmits initialization data. These commands and initialization data are sequentially transmitted to the Flash via the MCU and the PHY chip.
[0037] The host computer interacts with the user, receives user commands to start or stop initialization, and performs various operations based on these commands. Internally, it should implement a state machine (a state machine is one approach in this invention; it actually represents the state transitions of the host computer, typically represented by a state transition diagram containing five elements: state, transition, event, action, and condition, such as...). Figure 2 As shown, this state machine is used to initialize the SPI Flash, and it works in conjunction with the state machine in the MCU to complete the initialization process. The host computer can also determine the current state of the MCU through the control and status registers in the MCU, or issue instructions through the registers. The host computer stores the image file and can input the initialization file into the MCU in batches. In this embodiment, the host computer communicates with the MCU through the MCU's I2C interface. The host computer transmits the image file to the MCU in groups, with each group of data being 512 bytes in size, and the data is stored in a data buffer allocated by the MCU.
[0038] The MCU is used to receive various instructions from the host computer and perform various operations according to the instructions. Internally, it should implement a state machine (the state machine is one approach in this invention; it is actually the state transition of the MCU, usually represented by a state transition diagram containing five elements: state, transition, event, action, and condition, such as...). Figure 3 As shown in the diagram, this state machine is used to initialize the SPI Flash. During initialization, it works in conjunction with the state machine in the host computer to complete the initialization process. The MCU includes a status and control register, which stores the current state of the MCU for the host computer to read or to receive control commands from the host computer. The MCU also includes a data buffer equal in size to each group of data transmitted by the host computer. The MCU includes two communication interfaces: I2C and MDIO. I2C communicates with the host computer, and MDIO communicates with the PHY chip.
[0039] The PHY chip receives data from the MCU via the MDIO interface, while the Flash memory receives data from the PHY chip via the SPI interface. The internal data processing of the PHY chip varies between manufacturers and will not be elaborated upon here.
[0040] This invention provides a method for initializing the external SPI Flash of the PHY chip in an electrical port module, comprising the following steps:
[0041] Step 1: The host computer sends an initialization command, causing the host computer to switch from the NORMAL state to the WAIT_READY state;
[0042] Step 2: The MCU reads the initialization instruction, transitions from the NORMAL state to the INIT_PREP state, and begins the initialization preparations.
[0043] Step 3: After the MCU completes its initial preparations, it transitions from the INIT_PREP state to the REQ_IMAGE state, waiting for image data to be transmitted from the host computer.
[0044] Step 4: When the host computer receives the instruction from the MCU to request an image, it transitions from the WAIT_READY state to the SEND_IMAGE state and begins to transmit a set of image data to the MCU.
[0045] Step 5: After the host computer completes the image data transmission, it transitions from the SEND_IMAGE state to the WAIT_REQ state, waiting for the MCU to request data again;
[0046] Step 6: When the MCU receives a data transmission completion instruction, it transitions from the REQ_IMAGE state to the WRITE_IMAGE state and begins writing a set of data from the MCU to the PHY chip, and then the PHY chip writes it to the SPI Flash.
[0047] Step 7: The MCU has finished writing a set of data. When it does not receive an instruction from the host computer indicating that this set is the last set, it transitions from WRITE_IMAGE to REQ_IMAGE state, waiting for the host computer to send image data, and then repeats the process between steps 4 and 7. When it receives an instruction from the host computer indicating that this set is the last set, it transitions from WRITE_IMAGE to VER_IMAGE state to verify the data written to the SPI Flash.
[0048] Step 8: The host computer receives the start verification command sent by the MCU, transitions from the WAIT_REQ state to the WAIT_VER state, and waits for the MCU's verification result.
[0049] Step 9: MCU verification is complete. The MCU transitions from the VER_IMAGE state to the NORMAL state and begins normal operation.
[0050] Step 10: The host computer receives the verification completion instruction sent by the MCU and transitions from WAIT_VER to NORMAL state. The host computer displays that the initialization was successful. At this point, the external SPI Flash initialization of the PHY chip of the electrical port module is complete.
[0051] like Figure 2 As shown, the state machine used by the host computer to complete initialization in this embodiment of the invention includes six states: NORMAL, WAIT_READY, SEND_IMAGE, WAIT_REQ, WAIT_VER, and ERROR.
[0052] The NORMAL state is the host computer's working state without initialization. When it receives the user's initialization command, it will send an initialization command to the MCU and transition from the NORMAL state to the WAIT_READY state.
[0053] The WAIT_READY state is a state that waits for the MCU initialization to finish. When it receives the instruction from the MCU to finish, it will transition from the WAIT_READY state to the SEND_IMAGE state.
[0054] The SEND_IMAGE state is for transmitting image data. When a set of image data transmission is complete, it transitions from the SEND_IMAGE state to the WAIT_REQ state. Note that in this state, it's important to check if this is the last set of images transmitted. If it is, a command needs to be sent to the MCU to indicate this.
[0055] The WAIT_REQ state is a state that waits for the MCU to request image data. When it receives an instruction from the MCU to request an image, it will transition from the WAIT_REQ state to the SEND_IMAGE state. When it receives an instruction from the MCU to start verifying the image, it will transition from the WAIT_REQ state to the WAIT_VER state.
[0056] The WAIT_VER state is a state that waits for the image verification result. When it receives the instruction that the image verification is over, it will transition from the WAIT_VER state to the NORMAL state.
[0057] The ERROR state is an error state. An error occurs during the operation of any of the WAIT_READY, SEND_IMAGE, WAIT_REQ, or WAIT_VER states, or an error code is read from the MCU during the operation of that state. The error will be displayed on the host computer, and finally the state will be switched to NORMAL, waiting for the user to reinitialize.
[0058] like Figure 3 As shown, the state machine used by the MCU to complete initialization in this embodiment of the invention includes six states: NORMAL, INIT_PREP, REQ_IMAGE, WRITE_IMAGE, VER_IMAGE, and ERROR.
[0059] The NORMAL state is the MCU's working state without initialization. When it receives an initialization command from the host computer, it transitions from the NORMAL state to the INIT_PREP state.
[0060] The INIT_PREP state is the state where initialization preparation work is performed, such as erasing Flash and setting the size of the image transfer buffer in the PHY chip. When the initialization preparation work is completed, it will transition from the INIT_PREP state to the REQ_IMAGE state.
[0061] The REQ_IMAGE state is a state that requests the host computer to send image data. When it is detected that a set of image data has been put into the MCU buffer, it will switch from the REQ_IMAGE state to the WRITE_IMAGE state.
[0062] The WRITE_IMAGE state is the state in which the MCU writes data from the buffer into the PHY chip, and then writes it into the SPI Flash through the PHY chip. When no instruction from the host computer indicating that this is the last group has been received, it transitions from WRITE_IMAGE to REQ_IMAGE; when an instruction from the host computer indicating that this is the last group has been received, it transitions from WRITE_IMAGE to VER_IMAGE.
[0063] The VER_IMAGE state is used to verify the data in the SPI Flash. When the image verification is finished, it will transition from the VER_IMAGE state to the NORMAL state.
[0064] The ERROR state is an error state. If an error occurs during the operation of any of the INIT_PREP, REQ_IMAGE, WRITE_IMAGE, or VER_IMAGE states, the system will switch to the ERROR state and set the error code in the corresponding register. Finally, the system will switch from the VER_IMAGE state to the NORMAL state and wait for the user to reinitialize it.
[0065] like Figure 4 As shown, this is a description table of the status and control registers of the Flash initialization image defined internally by the MCU. The host computer determines the MCU's status, issues commands to the MCU, and the MCU determines whether data transmission is complete by referring to the registers in this table. These registers include: INIT_STATE_CONTROL, MCU_INIT_STATE, and IMAGE_READY. The registers mentioned in this article refer to the three registers in the register description table.
[0066] The INIT_STATE_CONTROL register controls whether the MCU begins initialization. It is set by the host computer, and the MCU reads its value and performs corresponding operations based on that value.
[0067] When no initialization is performed, setting INIT_STATE_CONTROL to 0x0 allows the MCU to operate normally without executing initialization-related commands. Before setting this register to 0x0, both the host computer and the MCU are in ERROR state, or the host computer is in WAIT_VER state and the MCU is in VER_IMAGE state. After the host computer sets this register to 0x0, both the host computer and the MCU enter NORMAL state.
[0068] During initialization, setting INIT_STATE_CONTROL to 0x1 causes the MCU to pause all other operations and enter initialization mode. Before setting this register to 0x0, both the host computer and the MCU are in NORMAL state. After the host computer sets this register to 0x1, the host computer transitions from NORMAL state to WAIT_READY state, and the MCU transitions from NORMAL state to INIT_PREP state.
[0069] The MCU_INIT_STATE register indicates the current initialization state of the MCU. It is set by the MCU, and the host computer reads its value and performs corresponding operations based on that value.
[0070] When the MCU is in normal operating condition and has not been initialized, the MCU sets MCU_INIT_STATE to 0x0. When the host computer reads 0x0, it does not perform any operation. This indicates that the MCU is in a NORMAL state, and the host computer should also be in a NORMAL state at this time.
[0071] If the code from the previous stage of the MCU has not finished executing, it indicates that the MCU is busy, and the MCU sets MCU_INIT_STATE to 0x1. When the host computer reads 0x1, it needs to wait for a period of time before reading again. At this time, the MCU may be in the INIT_PREP, WRITE_IMAGE, or VER_IMAGE states mentioned above, while the host computer should be in the corresponding WAIT_READY, WAIT_REQ, or WAIT_VER states.
[0072] Once the initialization preparations are complete, the MCU sets MCU_INIT_STATE to 0x2. Initialization preparations typically include saving the PHY chip's state values before initialization and erasing Flash memory. When the host computer reads 0x2, it begins transferring the initialization image group to the MCU. Before setting this register to 0x2, the MCU is in the INIT_PREP state, and the host computer is in the WAIT_READY state. After the MCU sets this register to 0x2, the MCU transitions from the INIT_PREP state to the REQ_IMAGE state, and the host computer transitions from the WAIT_READY state to the SEND_IMAGE state.
[0073] When the previous image file has been transferred to Flash, the MCU sets MCU_INIT_STATE to 0x3. When the host computer reads 0x3, it will transfer the next set of data from the image file to the MCU. Before setting this register to 0x3, the MCU is in WRITE_IMAGE state, and the host computer is in WAIT_REQ state. After the MCU sets this register to 0x3, the MCU transitions from WRITE_IMAGE state to REQ_IMAGE state, and the host computer transitions from WAIT_REQ state to SEND_IMAGE state.
[0074] Once the last set of image files has been written to Flash, the MCU sets MCU_INIT_STATE to 0x4. Next, the MCU sends a command to the PHY chip to begin verifying the images in Flash. The host computer does not perform any operation when it reads 0x4. Before setting this register to 0x4, the MCU is in WRITE_IMAGE state, and the host computer is in WAIT_REQ state. After the MCU sets this register to 0x4, the MCU transitions from WRITE_IMAGE state to VER_IMAGE state, and the host computer transitions from WAIT_REQ state to WAIT_VER state.
[0075] When the initialization image file written to Flash is error-free, the MCU sets MCU_INIT_STATE to 0x5. When the host computer reads 0x5, it sets INIT_STATE_CONTROL back to 0x0, indicating that initialization has stopped. Before setting this register to 0x5, the MCU is in VER_IMAGE state, and the host computer is in WAIT_VER state. After the MCU sets this register to 0x5, the MCU transitions from VER_IMAGE state to NORMAL state, and the host computer transitions from WAIT_VER state to NORMAL state.
[0076] Specifically, regarding the value of MCU_INIT_STATE, if an error occurs during code execution during initialization, the values originally set to 0x2, 0x3, 0x4, and 0x5 will be changed to 0x12, 0x13, 0x14, and 0x15 to indicate the error. If the host computer reads 0x12, 0x13, 0x14, and 0x15 from MCU_INIT_STATE, it will set INIT_STATE_CONTROL back to 0x0, indicating cancellation of initialization and displaying the error message. For the state machine, after setting this register to the error code, both the MCU and the host computer, regardless of their previous states, will transition to the ERROR state, wait for the host computer to send the error message, and then use INIT_STATE_CONTROL to transition to the NORMAL state.
[0077] The IMAGE_READY register indicates whether the host computer has transferred the image file to the MCU. It is set by the host computer, and the MCU reads its value and performs the corresponding operation based on that value.
[0078] When a data transmission from the host computer is incomplete, the IMAGE_READY value is set to 0x0. When the MCU reads 0x0, it will wait for a period of time before proceeding with the reading. At this time, the host computer is in the SEND_IMAGE state, and the MCU is in the REQ_IMAGE state.
[0079] When the host computer completes a data transmission for a set of data, and this set of data is not the last set, it sets the IMAGE_READY value to 0x1. When the MCU reads 0x1, it will read the incoming data from the buffer and then write it sequentially into the SPI Flash connected to the PHY chip. After the transmission is complete, it will set MCU_INIT_STATE to 0x3. Before setting this register to 0x1, the host computer is in the SEND_IMAGE state, and the MCU is in the REQ_IMAGE state. After the host computer sets this register to 0x1, the host computer transitions from the SEND_IMAGE state to the WAIT_REQ state, and the MCU transitions from the REQ_IMAGE state to the WRITE_IMAGE state.
[0080] When the host computer completes a data transmission for a set, and this is the last set, it sets the IMAGE_READY value to 0x2. When the MCU reads 0x2, it reads the incoming data from the buffer and writes it sequentially into the SPI Flash connected to the PHY chip. After transmission is complete, it sets MCU_INIT_STATE to 0x4. Before setting this register to 0x2, the host computer is in the SEND_IMAGE state, and the MCU is in the REQ_IMAGE state. After the host computer sets this register to 0x2, the host computer transitions from the SEND_IMAGE state to the WAIT_REQ state, and the MCU transitions from the REQ_IMAGE state to the WRITE_IMAGE state.
[0081] like Figure 5 As shown, this embodiment of the invention provides a method for initializing the external SPI Flash of the PHY chip in the electrical port module. The steps to be performed by the host computer and the MCU during the initialization process include:
[0082] Step 1: The host computer sends an initialization command, setting INIT_STATE_CONTROL to 0x1. The host computer then transitions from the NORMAL state to the WAIT_READY state.
[0083] Step 2: The MCU reads the initialization instruction, specifically, it reads the INIT_STATE_CONTROL value as 0x1 and begins the initialization preparations. The MCU transitions from the NORMAL state to the INIT_PREP state.
[0084] Step 3: After the MCU's initial preparation is complete, set "MCU_INIT_STATE" to 0x2 and wait for image data to be transmitted from the host computer. The MCU transitions from INIT_PREP to REQ_IMAGE state.
[0085] Step 4: When the host computer receives the MCU's image request instruction, i.e., when it reads the "MCU_INIT_STATE" value as 0x2 or 0x3, it begins to transfer a set of image data to the MCU. The host computer then transitions from the WAIT_READY state to the SEND_IMAGE state.
[0086] Step 5: After the host computer completes the image data transmission, it sets "IMAGE_READY" to 0x1 and waits for the MCU to request data again. When this is the last data set, "IMAGE_READY" is set to 0x2, and the host computer waits for the MCU to begin image data verification. The host computer then transitions from the SEND_IMAGE state to the WAIT_REQ state.
[0087] Step Six: When the MCU receives a data transmission completion instruction, i.e., reads an "IMAGE_READY" value of 0x1 or 0x2, it begins writing a set of data from the MCU to the PHY chip, and then the PHY chip writes it to the SPI Flash. The MCU then transitions from the REQ_IMAGE state to the WRITE_IMAGE state.
[0088] Step 7: The MCU has written a set of data from the host computer into the SPI Flash. When the MCU reads that the "IMAGE_READY" value is 0x1, it means that this set of data is not the last set. The MCU sets "MCU_INIT_STATE" to 0x3 and waits for the host computer to send image data. At this time, the MCU switches from WRITE_IMAGE to REQ_IMAGE state and then repeats the process between steps 4 and 7. When the MCU reads that the "IMAGE_READY" value is 0x2, it means that this set of data is the last set. The MCU sets "MCU_INIT_STATE" to 0x4 and starts to verify the data written into the SPI Flash. At this time, the MCU switches from WRITE_IMAGE to VER_IMAGE state.
[0089] Step 8: When the host computer receives the start verification command from the MCU, i.e., when it reads the value of "MCU_INIT_STATE" as 0x4, the host computer does not perform any action and continues to read the value of "MCU_INIT_STATE" in a loop, waiting for the verification result of the image data. The host computer then transitions from the WAIT_REQ state to the WAIT_VER state.
[0090] Step 9: MCU verification is complete. Set "MCU_INIT_STATE" to 0x5, and the MCU will begin normal operation. The MCU transitions from the VER_IMAGE state to the NORMAL state.
[0091] Step 10: When the host computer receives the verification completion command from the MCU, i.e., when it reads the value of "MCU_INIT_STATE" as 0x5, it sets the value of "INIT_STATE_CONTROL" to 0x0, and the host computer displays that initialization was successful. The host computer then transitions from WAIT_VER to NORMAL state.
[0092] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.
Claims
1. A method for initializing an external SPI Flash of a PHY chip in an electrical port module, characterized in that, Includes the following steps: Step 1: The host computer sends an initialization command, causing the host computer to switch from the NORMAL state to the WAIT_READY state; Step 2: The MCU reads the initialization instruction, transitions from the NORMAL state to the INIT_PREP state, and begins the initialization preparations. Step 3: After the MCU completes its initial preparations, it transitions from the INIT_PREP state to the REQ_IMAGE state, waiting for image data to be transmitted from the host computer. Step 4: When the host computer receives the instruction from the MCU to request an image, it transitions from the WAIT_READY state to the SEND_IMAGE state and begins to transmit a set of image data to the MCU. Step 5: After the host computer completes the image data transmission, it transitions from the SEND_IMAGE state to the WAIT_REQ state, waiting for the MCU to request data again; Step 6: When the MCU receives a data transmission completion instruction, it transitions from the REQ_IMAGE state to the WRITE_IMAGE state and begins writing a set of data from the MCU to the PHY chip, and then the PHY chip writes it to the SPI Flash. Step 7: The MCU has finished writing a set of data. When it does not receive an instruction from the host computer indicating that this set is the last set, it transitions from WRITE_IMAGE to REQ_IMAGE state, waiting for the host computer to send image data, and then repeats the process between steps 4 and 7. When it receives an instruction from the host computer indicating that this set is the last set, it transitions from WRITE_IMAGE to VER_IMAGE state to verify the data written to the SPI Flash. Step 8: The host computer receives the start verification command sent by the MCU, transitions from the WAIT_REQ state to the WAIT_VER state, and waits for the MCU's verification result. Step 9: MCU verification is complete. The MCU transitions from the VER_IMAGE state to the NORMAL state and begins normal operation. Step 10: The host computer receives the verification completion instruction sent by the MCU and transitions from WAIT_VER to NORMAL state. The host computer displays that the initialization was successful. At this point, the external SPI Flash initialization of the PHY chip of the electrical port module is complete.
2. The method for initializing the external SPI Flash of the PHY chip in the electrical port module as described in claim 1, characterized in that, The state machine used by the host computer to complete initialization includes the following states: NORMAL, WAIT_READY, SEND_IMAGE, WAIT_REQ, WAIT_VER, and ERROR.
3. The method for initializing the external SPI Flash of the PHY chip in the electrical port module as described in claim 1, characterized in that, The state machine used by the MCU to complete initialization includes the following states: NORMAL, INIT_PREP, REQ_IMAGE, WRITE_IMAGE, VER_IMAGE, and ERROR.
4. The method for initializing the external SPI Flash of the PHY chip in the electrical port module as described in claim 1, characterized in that, The system includes a host computer, an MCU, a PHY chip, and an SPI Flash. The host computer interacts with the user, receives user commands to start or stop initialization, and performs various operations based on these commands. The host computer has a state machine that initializes the SPI Flash and works in conjunction with the state machine in the MCU to complete the initialization process. The host computer communicates with the MCU via an I2C interface, controlling the MCU. The MCU communicates with the PHY chip via an MDIO interface, controlling the PHY chip. The PHY chip communicates with the SPI Flash via an SPI interface, controlling the SPI Flash. Upon initialization, the host computer issues initialization commands and transmits initialization data, which are then sequentially transferred to the Flash memory via the MCU and PHY chip.
5. The method for initializing the external SPI Flash of the PHY chip in the electrical port module as described in claim 4, characterized in that, The MCU is used to receive various instructions from the host computer and perform various operations according to the instructions. The MCU has an MCU state machine, which is used to initialize the SPI Flash. During initialization, it works together with the state machine in the host computer to complete the initialization process.
6. The method for initializing the external SPI Flash of the PHY chip in the electrical port module as described in claim 5, characterized in that, The MCU includes two communication interfaces, I2C and MDIO. It communicates with the host computer via I2C and with the PHY chip via MDIO.
7. The method for initializing the external SPI Flash of the PHY chip in the electrical port module as described in claim 5, characterized in that, The MCU includes status and control registers, which are used to store the current state of the MCU for the host computer to read, or to receive control commands from the host computer.
8. The method for initializing the external SPI Flash of the PHY chip in the electrical port module as described in claim 7, characterized in that, The table describes the status and control registers of the Flash initialization image defined inside the MCU. The host computer uses three registers implemented in the MCU to determine the status of the MCU, send instructions to the MCU, and determine whether the data transmission is complete.
9. A method for initializing the external SPI Flash of the PHY chip in a power port module as described in claim 8, characterized in that, The three registers implemented in the MCU include: INIT_STATE_CONTROL, MCU_INIT_STATE, and IMAGE_READY. Among them, the INIT_STATE_CONTROL register is used to control whether the MCU starts initialization; the MCU_INIT_STATE register is used to indicate the initialization state of the MCU at this time; and the IMAGE_READY register is used to indicate whether the host computer has transferred the image file to the MCU.
10. The method for initializing the external SPI Flash of the PHY chip in the electrical port module as described in claim 9, characterized in that, It also includes the design of error codes, specifically several special values in the MCU_INIT_STATE register. If an error occurs during MCU operation during initialization, the MCU will detect it and set these values in the MCU_INIT_STATE register. After the host computer reads these values from the MCU_INIT_STATE register, it will interrupt the initialization process and report the error information to the user.