Skip to content

Ota pgrade Porting Guide*

The OTA upgrade of the GX8002 supports two connection modes: UART and I2C.

The GX8002 supports empty chip upgrades, which means that the GX8002 can be upgraded over OTA without having burned any firmware itself. Therefore, this upgrade is safe and reliable. If the equipment becomes bricked due to power interruption or abnormal during the upgrade process, it can still be re-powered and reset and OTA again.

Our upgrade code has been solidified in ROM inside the GX8002 chip, so it can support the empty chip upgrade. The upgrade process has nothing to do with the internal firmware of the GX8002 itself.

1. Serial port upgrade*

The host can upgrade the 8002 through the serial port in the following ways

Both UART0 and UART1 of the GX8002 can be upgraded

1.1 Reference code download*

uart_ota_pc_demo.zip (http://yun.nationalchip.com:10000/l/yFs2dm)

Update routine code description:

  • main.c Main code
  • porting.c The main port interface
  • grus.boot bootloader image
  • 0922_siri_mcu_nor.bin Firmware to be upgraded
  • Readme.md Need to read attention

1.2 Develop board verification methods*

1.2.1 Windows environment testing*

  • For Windows, you need to install the gcc compiler mingw and configure the environment variables

  • decompress uart_ota_pc_demo.zip

  • Go to the uart_ota_pc_demo directory. Ensure that the current path does not contain Chinese characters. Open the cmd command window and enter mingw32-make windows to generate the executable file main.exe

    mingw32-make windows
    
  • Connect development board 8002 to PC as shown in the following figure. Both UART0 and UART1 can be used.

  • After running the following command, flip the switch in the red box (left indicates off, right indicates on) to power on the 8002 development board again. You can upgrade the firmware. The serial port device number cannot be set to COM0.

    .\main.exe COM0 1500000 grus.boot 0922_siri_mcu_nor.bin
    
  • If flash image ok is displayed, the firmware upgrade is successful.

  • Call "Hi siri" to 8002 development board, and you can see the wake up message through serial port 1 (as shown below).

1.2.2 Test the Ubuntu linux environment*

  • decompress uart_ota_pc_demo.zip

  • Go to the uart_ota_pc_demo directory and compile

    make linux
    
  • Connect the 8002 development board to the PC, run the following command, and then power on the 8002 development board to upgrade the firmware. The serial port device number varies from ttyUSB0 to the PC. Permission is required to operate the serial port, so use the sudo command

    sudo ./main.elf /dev/ttyUSB0 1500000 grus.boot 0922_siri_mcu_nor.bin
    
  • The next steps are the same as for windows

1.3 Video demonstration teaching*

OTA presentation video: https://www.bilibili.com/video/BV1XK4y1Z7J6

1.4 Upgrade flow chart*

1.5 Migration considerations*

  • The upgrade process is divided into two stages. The first stage is to load the bootloader, and then load the firmware to be burned after the bootloader starts. Therefore, developers need to solidify grus.boot into their own upgrade code, or save it to the master flash. grus.boot 45K size.

  • In the upgrade process, the serial port baud rate can be first recommended by our code. If it is found unstable, the baud rate can be reduced and then tested to find an appropriate baud rate.

  • Upgrade the protocol process, developers can do not need to pay attention to, directly transplant. However, you should pay attention to porting.c, and replace the serial port receiving interface in it with that of your own platform. This set of code for customer reference, successfully transplanted in Jie Li, China Science Blue Xun, Qualcomm, HengXuan SOC, and mass production.

  • Note the timing when powering on and resetting the GX8002. Power on the core later than the I/O. It is recommended that you power on the I/O for at least 10 milliseconds

    lvp_tws/app/sample/lvp_app_sample.c
    1
    2
    3
    4
    5
    6
    void gx8002_power_on(void)
    {
      gx8002_vdd_io_ctrl(1);
      os_time_delay(10); // 10ms
      gx8002_vdd_core_ctrl(1);
    }
    
  • After the GX8002 is powered on, do not send any data to the GX8002 through the serial port for about 1 second during the power-on period. Otherwise, the GX8002 may enter the upgrade mode and fail to work properly.

  • When migrating, it is recommended to use the timeout given in our reference example. The examples are given a long time, so it's more stable. And that time, normally in OTA, is very short. If an exception does occur that causes a failure, this timeout is a very short time compared to the overall OTA process.

  • When transplantation, it is highly recommended to take our development board flying line, debugging, so as to eliminate the interference of PCBA hardware problems, on this basis, after successful debugging, then to the PCBA test. In the development board debugging problems, can be very convenient to catch the development board log for our analysis and positioning.

  • If the handshake phase fails, ensure that the power-on sequence is correct, and then try to set the handshake timeout period as long as possible, for example, 5 seconds.

2. I2C upgrade*

The GX8002 also supports the I2C upgrade and uses the I2C0

2.1 Reference code download*

i2c_ota_pc_demo.zip (http://yun.nationalchip.com:10000/l/yFs2dm)

In the code directory, peruse the internal readme documentation. There are two examples, one is under windows verification, one is under linux verification, reference to which can be.

2.2 Ubuntu linux environment development board verification method*

  • Decompress i2c_ota_pc_demo.zip, install the CH341A driver in Linux, connect the I2C read/write tool, and check whether /dev/ch34x_pis is identified.
  • Enter the directory i2c_ota_pc_demo, decompress i2c_ota_pc_linux_demo, enter the code directory, and run the command make to compile and generate iic.load.
  • Connect the I2C tool to the 8002 development board on the PC, connect the I2C tool to the I2C0 pin on the development board, and run the sudo./iic.load command to upgrade the firmware.
  • If flash image appears ok ! is displayed, the upgrade is successful!

2.3 Migration considerations*

  • The frequency of I2C, we've tested 400K or higher.

  • The upgrade process is divided into two stages. The first stage is to load the bootloader, and then load the firmware to be burned after the bootloader starts. Therefore, developers need to solidify grus.boot into their own upgrade code, or save it to the master flash. grus.boot 45K size.

  • Upgrade the protocol process, developers can do not need to pay attention to, directly transplant. However, you need to change the I2C receiving interface inside to your own platform. This set of code for customer reference, successfully transplanted in the original phase, MTK, RK, China Science Blue Xun SOC, and mass production.

  • If the startup handshake is easy to fail, we need to strictly follow our example first, reset 8002, immediately try to write EF, write successfully, read. If the write fails or read fails, try again at an interval of one millisecond. If the handshake fails after five seconds, it is considered that the handshake failed. Once the run is steady, try shortening the 5 seconds to a reasonable position, like 1 or 2 seconds.

  • When transplantation, it is highly recommended to take our development board flying line, debugging, so as to eliminate the interference of PCBA hardware problems, on this basis, after successful debugging, then to the PCBA test. In the development board debugging problems, can be very convenient to catch the development board log for our analysis and positioning.

  • When migrating, it is recommended to use the timeouts and delays given in our reference examples. The examples are given a long time, so it's more stable. And that time, normally in OTA, is very short. If an exception does occur that causes a failure, this timeout is a very short time compared to the overall OTA process.

  • Note the timing when powering on and resetting the GX8002. Power on the core later than the I/O. It is recommended that you power on the I/O for at least 10 milliseconds.

    lvp_tws/app/sample/lvp_app_sample.c
    1
    2
    3
    4
    5
    6
    void gx8002_power_on(void)
    {
      gx8002_vdd_io_ctrl(1);
      os_time_delay(10); // 10ms
      gx8002_vdd_core_ctrl(1);
    }
    
  • In this example, the device address of I2C download channel 7 is 0x36. The device address depends on the behavior of the hardware, whether it is 0x36 or 0x35, depending on the behavior of GPIO02.