nt9856x/rtos/code/application/source/cardv/gprof_user_guide.txt
2023-03-28 15:07:53 +08:00

48 lines
1.4 KiB
Plaintext
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

1. 確認有替換 lds, 讓 gprof 可以正常運作
在 code/application/source/cardv/OutputImg.mk
將 LDSCRIPT = rtos-main.lds 替換為
=> LDSCRIPT = rtos-main.gprof.lds
2. 在 code/application/source/cardv/OutputImg.mk
加上 -lgprof如下:
# code/lib
EXTRA_LIB += \
-lgprof \
3. build fw, update fw to your machine
4. 開機後, 參考下列方式, 在 run-time 使用 gprof cmd, 它會把 gmon.out 量測紀錄檔寫到 sd 卡
> gprof start
gprof open
Profile from 018038e0..01d4327c in 343962 buckets of size 16
> gprof stop
gprof pause
> gprof dump
gprof dump result
=> [A:\gmon.out] write ok, file size = 687977
gprof end
如果 gprof dump result 卡住出不來,有可能是有 high priority 的 task 在 busy loop
造成 FileSysTsk 沒有機會存檔,所以才會卡住,此時必須把 FileSysTsk 的 priority 拉高。
可以透過 FS_INIT_PARAM 的 TskPriority 欄位來設定。
5. CD目錄到這邊
code/application/source/cardv/output/
6. 確認此目錄下有
code/application/source/cardv/output/rtos-main.img
7. 把 sd 卡的 gmon.out 檔 copy 到此目錄
gmon.out copy 到 => code/application/source/cardv/output/gmon.out
8. 執行 gprof command, 由 gmon.out 量測紀錄檔, 可以產生 gprof.txt 分析檔
/opt/ivot/gcc-linaro-6.4.1-2018.05-x86_64_arm-eabi/bin/arm-eabi-gprof --no-static --no-graph --demangle=auto rtos-main.img gmon.out > gprof.txt
9. 打開此 gprof.txt 分析檔, 可以觀察由 [gprof start] 到 [gprof stop] 期間的 function 使用量排名
code/application/source/cardv/output/gprof.txt