quickstart-pkg-3861-running.md 4.7 KB
Newer Older
E
ester.zhou 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
# Running an Image


## Networking Configuration

After you have completed building and burning, perform the following to connect the Hi3861 WLAN module to the Internet.

1. While the Windows workbench is connected to the Hi3861 WLAN module, ensure that the serial port terminal is displayed properly.

2. Reset the Hi3861 WLAN module. The message **ready to OS start** is displayed on the **TERMINAL** panel, indicating that the WLAN module is started successfully.
   
   **Figure 1** Successful resetting of the Hi3861 WLAN module 
  
   ![quickstart-pkg-3861-running-restart](figures/quickstart-pkg-3861-running-restart.png)

3. Run the following AT commands in sequence to enable the STA mode, connect to the specified AP, and enable the DHCP function:
   
   ```
   AT+STARTSTA                             # Start the STA mode.
   AT+SCAN                                 # Scan for available APs.
   AT+SCANRESULT                           # Display the scanning result.
   AT+CONN="SSID",,2,"PASSWORD"            # Connect to the specified AP. (SSID and PASSWORD represent the name and password of the hotspot to be connected, respectively.)
   AT+STASTAT                              # View the connection result.
   AT+DHCP=wlan0,1                         # Request the IP address of wlan0 from the AP using DHCP.
   ```

4. Check whether the Hi3861 WLAN module is properly connected to the gateway, as shown in the following figure.
   
   ```
   AT+IFCFG                                # View the IP address assigned to an interface of the module.
   AT+PING=X.X.X.X                         # Check the connectivity between the module and the gateway. Replace X.X.X.X with the actual gateway address.
   ```

   **Figure 2** Successful networking of the Hi3861 WLAN module 
   ![quickstart-pkg-3861-running-success](figures/quickstart-pkg-3861-running-success.png)


## Verification

When the burning and networking are complete, you can use either of the following methods to debug and verify whether the source code has been burnt correctly:

1. Using printf to print logs

2. Using ASM files to locate panic issues

As the example used here is simple, we use the printf method. The following describes the two methods in detail.


### Using printf to Print Logs

Add the printf function to the code, which helps print data to the serial port. You can add log printing in key service paths or service exception locations, as shown in the following figure.


```
void HelloWorld(void)
{
    printf("[DEMO] Hello world.\n");
}
```


### Using ASM Files to Locate Issues

If the system exits abnormally, the call stack information about the abnormal exit is displayed on the serial port. Analyze the displayed information to troubleshoot and pinpoint issues.

```
=======KERNEL PANIC=======
**Call Stack*
Call Stack 0 -- 4860d8 addr:f784c
Call Stack 1 -- 47b2b2 addr:f788c
Call Stack 2 -- 3e562c addr:f789c
Call Stack 3 -- 4101de addr:f78ac
Call Stack 4 -- 3e5f32 addr:f78cc
Call Stack 5 -- 3f78c0 addr:f78ec
Call Stack 6 -- 3f5e24 addr:f78fc
Call Stack end***
```

To analyze the call stack information, the **Hi3861_wifiiot_app.asm** file is required. This file records the symbol addresses of the functions in the code in the flash memory and the disassembly information. The ASM file is built and output together with the version software package and is stored in the **./out/wifiiot/** directory.

1. (Optional) Save the call stack information to a TXT file for editing.

2. Open the ASM file, search for the function address in each call stack, and list the corresponding function. Generally, you only need to find the functions matching the first several stacks to locate issues.
   
   ```
   Call Stack 0 -- 4860d8 addr:f784c -- WadRecvCB
   Call Stack 1 -- 47b2b2 addr:f788c -- wal_sdp_process_rx_data
   Call Stack 2 -- 3e562c addr:f789c
   Call Stack 3 -- 4101de addr:f78ac
   Call Stack 4 -- 3e5f32 addr:f78cc
   Call Stack 5 -- 3f78c0 addr:f78ec
   Call Stack 6 -- 3f5e24 addr:f78fc
   ```

3. Based on the above call stack information, it can be determined that an exception occurs in the **WadRecvCB** function.
  
   ![hi3861-test](figures/hi3861-test.png)

4. Check and modify the code.


## Execution Result Examination

After the sample code is compiled, burnt, run, and debugged, restart the development board. If the following messages are displayed, the image is running correctly:


```
ready to OS start
FileSystem mount ok.
wifi init success!
[DEMO] Hello world.
```

Next

Congratulations! You have finished all steps! Proceed to develop samples to better familiarize yourself with OpenHarmony development:

E
ester.zhou 已提交
118
- [LED Peripheral Control](../guide/device-wlan-led-control.md)
E
ester.zhou 已提交
119

E
ester.zhou 已提交
120
- [Third-Party SDK Integration](../guide/device-wlan-sdk.md)