1# Debugging and Verification 2 3 4When 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: 5 6 71. Using printf to print logs 8 92. Using ASM files to locate panic issues 10 11 12As the example used here is simple, we use the printf method. The following describes the two methods in detail. 13 14 15## printf 16 17Add 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. 18 19 20``` 21void HelloWorld(void) 22{ 23 printf("[DEMO] Hello world.\n"); 24} 25``` 26 27 28## Using ASM Files to Locate Issues 29 30 When 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. 31 32``` 33=======KERNEL PANIC======= 34**Call Stack* 35Call Stack 0 -- 4860d8 addr:f784c 36Call Stack 1 -- 47b2b2 addr:f788c 37Call Stack 2 -- 3e562c addr:f789c 38Call Stack 3 -- 4101de addr:f78ac 39Call Stack 4 -- 3e5f32 addr:f78cc 40Call Stack 5 -- 3f78c0 addr:f78ec 41Call Stack 6 -- 3f5e24 addr:f78fc 42Call Stack end*** 43``` 44 45To 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. 46 471. (Optional) Save the call stack information to a TXT file for editing. 48 492. Open the asm file, search for the addresses in CallStack, and list the corresponding function names. Generally, you only need to find the functions matching the first several stacks to locate issues. 50 51 ``` 52 Call Stack 0 -- 4860d8 addr:f784c -- WadRecvCB 53 Call Stack 1 -- 47b2b2 addr:f788c -- wal_sdp_process_rx_data 54 Call Stack 2 -- 3e562c addr:f789c 55 Call Stack 3 -- 4101de addr:f78ac 56 Call Stack 4 -- 3e5f32 addr:f78cc 57 Call Stack 5 -- 3f78c0 addr:f78ec 58 Call Stack 6 -- 3f5e24 addr:f78fc 59 ``` 60 613. Based on the call stack information, we can conclude that an exception occurs in the **WadRecvCB** function. 62 63  64 654. Check and modify the code. 66