This is the documentation for the latest (main) development branch. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

Application Startup Process

This document will introduce the steps (i.e., the startup process) that the w800 undergoes from power-on to running the main function.

Macroscopically, the startup process can be divided into the following three steps:

graph TB A(Primary Bootloader)-->B[Bootloader program] B-->C[Application]
  1. The primary bootloader is fixed in the internal ROM. When the CPU powers on, it starts executing the fixed program in ROM from address 0x0 , loading the Bootloader program.

  2. The Bootloader program is a small program that runs before the operating system. Through this small program, hardware devices can be initialized to bring the system’s software and hardware environment to a suitable state, ready for eventually calling the operating system. It also loads the partition table from QFlash and decides the location of the application to start.

  3. During the application running stage, the application fetches the necessary configuration for running from files, such as the starting memory address, memory layout, etc.

The following sections provide a more detailed explanation of the above process.

Primary Bootloader program

After power-on, the CPU starts executing the fixed program in ROM, including QFLASH self-check, QFLASH mode switching, application verification, vector table redirection, and OTA.

Bootloader program

The Bootloader mainly completes the following tasks: QFlash work mode switching, application integrity verification, OTA, code decryption setup, and jumping to the user’s application to run.

Application Running

Taking W800 as an example, during the application runtime, it will obtain the entry function of the application from the chip_layout.ld.h in components/wm_soc/w800/ld .

Retrieve the memory layout of the application from memory_layout.c in components/wm_soc/w800/src .

After a series of initializations, it runs the main function, which the user can write as needed.

Automatic Initialization of Components

In addition to manually initializing components before the mian function, we also provide a method for automatic component initialization.

Each component that needs to execute initialization must use WM_COMPONEN_INIT_*(component_init_function) to annotate its component initialization function. The system will automatically call the component initialization function after startup to initialize the component.

The value of * is: 1, 2 , 3, 4, that is:

  • WM_COMPONEN_INIT_1(component_init_function)

  • WM_COMPONEN_INIT_2(component_init_function)

  • WM_COMPONEN_INIT_3(component_init_function)

  • WM_COMPONEN_INIT_4(component_init_function)

The execution order of these four annotated component initialization functions is different, with the execution order being:

graph TB A(......)-->B[WM_COMPONEN_INIT_1] B-->C[WM_COMPONEN_INIT_2] C-->D[WM_COMPONEN_INIT_3] D-->E[WM_COMPONEN_INIT_4] E-->F[......]

Generally, Basic system components use WM_COMPONEN_INIT_1 regular system components use 用WM_COMPONEN_INIT_2`application components use `WM_COMPONEN_INIT_3 , and user components use WM_COMPONEN_INIT_4

  • For example, if the initialization function of the CLI application component is wm_component_cli_init , then add

  • Decorate WM_COMPONEN_INIT_3(wm_component_cli_init)