【ATU Book-i.MX8系列 -Power Measurement】實際應用 - 軟體驗證(二)

一.   概述

本篇章將介紹恩智浦原廠所提供一套電源管理套件,能夠透過軟體遠端操作的方式,進行電壓、電流等量測。能夠幫助用戶快速取得晶片中各腳位的電源狀態 !! 非常便利 !! 但此套件需要搭配特定的電源量測晶片 “PAC1934” 才能運行,故僅支援特定型號的晶片,如下所示。

BCU 套件支援的特定晶片與 EVM 型號示意圖

 

其中,在這系列所提供的電源管理套件,可以細分成 Board Remote Control Utilities (BCU) 與 Power Measurement tool (PMT) 兩個套件,前者提供主要的遠端操作技術,後者則是將 BCU 整合 GUI,使得介面變得更強大。然而,後續章節將會介紹幾種「使用場景」,讀者僅需要依照各應用場景的步驟操作,並使用 BCU 或 PMT 來測量電壓即可。在每一個場景中,將會提供原廠的標準電壓數據,請測量完數據後,進行比對。故此章節將從 實際應用 - 軟體驗證(二) 來分享操作。

 大大通精彩博文   【ATU Book-i.MX8系列】博文索引

Power Measurement 系列博文-文章架構示意圖

 

 

 

二.  Power Measurement Tool (PMT)

Power Measurements 顧名思義就是電源量測,此章節將結合 BCU 或 PMT 兩個軟體,來測量各樣的應用分析的電源數據,比如說使用 NPU / GPU 使用的耗電量測、雙鏡頭的耗電量測等等。

 環境操作   i.MX8M PLUS EVK , BSP L5.15.71

 1. 測量方式

 開發板搭載 PAC1934 的電源量測晶片,結合既有的電阻元件資訊,即可透過 BCU 與 PMT 工具來量測各個節點之間的電壓、電流、功率等等。其中能檢測的節點,如下  PMIC 所量測的各節點電壓之示意圖 所示。


   圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

(1) 各電壓節點名詞解釋 :

 
圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

(2) 各電壓節點,在不同模式的電源狀態 :

共 Nominal mode / Overdrive mode / Super Overdrive mode 三種模式。


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

(3) 測量項目 : 

◆ CPU ( ARM ) 電壓、電流。
◆ DRAM、LPDDR4 電壓、電流。
◆ System 電壓、電流。
◆ SoC 電壓、電流。
◆ SD Card 電壓、電流。
◆ LVDS、HDMI 電壓、電流。
◆ USB、PCI、MIPI 電壓、電流。

 

 

2. 使用場景

以下實驗請連接螢幕與網路進行操作,設定完成場景後,請使用 BCU 或 PMT 測量電源。
因測量電壓、電流數據繁多,將不易於圖形呈現,故以 csv 檔案呈現,還請讀者自行比對數據,謝謝。

(1) Heavy Load use cases 

 視頻解碼 (VPU)  

操作方式 :

 $ bash setup_video.sh

#!/bin/bash
export WL_EGL_SWAP_INTERVAL=0
cpufreq-set -g performance
partitions=`lsblk |awk '$1 !~/-/{print $1}' |grep 'blk2boot\|sd'`
for partition in $partitions; do
echo 512 > /sys/block/$partition/queue/read_ahead_kb
done
ifconfig eth0 down
ifconfig eth1 down
echo 1 > /sys/class/graphics/fb0/blank
echo 0 > /sys/class/graphics/fb0/blank

 $ bash vpu_g2dec.sh

EXT_LOOP=10000
FILE=HEVC_1920x1080_29.97fps_AACLC_44.1Khz_2ch.mkv
export LD_LIBRARY_PATH=/unit_tests/VPU/hantro/:$LD_LIBRARY_PATH
while true;do
cnt=1
while [ $cnt -le $EXT_LOOP ]
do
/unit_tests/VPU/hantro/g2dec -P -Ers -ibs -N200 -X -b $FILE
cnt=$(($cnt+1));
done
done

 

測量數據 :


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

測試結果 : 請查閱

 

 Coremark + GLmark 測試程式 

操作方式 :

$ bash setup_video.sh

#!/bin/bash
export WL_EGL_SWAP_INTERVAL=0
cpufreq-set -g performance
partitions=`lsblk |awk '$1 !~/-/{print $1}' |grep 'blk2boot\|sd'`
for partition in $partitions; do
echo 512 > /sys/block/$partition/queue/read_ahead_kb
done
ifconfig eth0 down
ifconfig eth1 down
echo 1 > /sys/class/graphics/fb0/blank
echo 0 > /sys/class/graphics/fb0/blank

$ bash Coremark_loop.sh

while true; do
./Coremark.exe > /dev/null 2>&1
done

$ bash gpu_glmark.sh

while true;do
glmark2-es2-wayland --fullscreen
done

 

測量數據 :


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

測試結果 : 請查閱

 

 

(2) Memory

 記憶體設置( Memset )

操作方式 :

$ bash setup.sh

#!/bin/bash
systemctl stop weston.service
cpufreq-set -g performance
echo 1 > /sys/class/graphics/fb0/blank
partitions=`lsblk |awk '$1 !~/-/{print $1}' |grep 'blk\|sd'`
for partition in $partitions; do
echo 512 > /sys/block/$partition/queue/read_ahead_kb
done
ifconfig eth0 down
ifconfig eth1 down

$ bash memset_loop.sh

while true; do
perf bench -f simple mem memset -l10000 -s 1024MB
done

 

測量數據 :


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

測試結果 : 請查閱

 

  記憶體複製( Memcpy )  

操作方式 :

             $ bash setup.sh

#!/bin/bash
systemctl stop weston.service
cpufreq-set -g performance
echo 1 > /sys/class/graphics/fb0/blank
partitions=`lsblk |awk '$1 !~/-/{print $1}' |grep 'blk\|sd'`
for partition in $partitions; do
echo 512 > /sys/block/$partition/queue/read_ahead_kb
done
ifconfig eth0 down
ifconfig eth1 down

$ bash memcpy_loop.sh

while true; do
perf bench -f simple mem memcpy -l10000 -s 1024MB
done

 

測量數據 :


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

測試結果 : 請查閱

 

(3) SD Card

 讀取測試( DD_RD_SDCARD ) 

操作方式 :

        $ bash setup.sh

#!/bin/bash

systemctl stop weston.service
cpufreq-set -g performance
echo 1 > /sys/class/graphics/fb0/blank
partitions=`lsblk |awk '$1 !~/-/{print $1}' |grep 'blk\|sd'`
for partition in $partitions; do
echo 512 > /sys/block/$partition/queue/read_ahead_kb
done
ifconfig eth0 down
ifconfig eth1 down

$ bash dd_read_SD10.sh

#!/bin/bash
# Since we're dealing with dd, abort if any errors occur
set -e
TEST_FILE=${1:-dd_ibs_testfile}
if [ $EUID -ne 0 ]; then
echo "NOTE: Kernel cache will not be cleared between tests without sudo. This will likely cause
inaccurate results." 1>&2
fi
# Create a test file
# Header
PRINTF_FORMAT="%8s : %s\n"
printf "$PRINTF_FORMAT" 'block size' 'transfer rate'
# Block sizes of 512b 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M
for BLOCK_SIZE in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152
4194304 8388608 16777216 33554432 67108864
do
# Clear kernel cache to ensure more accurate test
[ $EUID -eq 0 ] && [ -e /proc/sys/vm/drop_caches ] && echo 3 > /proc/sys/vm/drop_caches
# Read test file out to /dev/null with specified block size
DD_RESULT=$(dd if=$TEST_FILE of=/dev/null bs=$BLOCK_SIZE 2>&1 1>/dev/null)
# Extract transfer rate
TRANSFER_RATE=$(echo $DD_RESULT | \grep --only-matching -E '[0-9.]+ ([MGk]?B|bytes)/s(ec)?')
printf "$PRINTF_FORMAT" "$BLOCK_SIZE" "$TRANSFER_RATE"
done

 

測量數據 :


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

測試結果 : 請查閱

 

 寫入測試( DD_WRT_SDCARD ) 

操作方式 :

$ bash setup.sh

#!/bin/bash
systemctl stop weston.service
cpufreq-set -g performance
echo 1 > /sys/class/graphics/fb0/blank
partitions=`lsblk |awk '$1 !~/-/{print $1}' |grep 'blk\|sd'`
for partition in $partitions; do
echo 512 > /sys/block/$partition/queue/read_ahead_kb
done
ifconfig eth0 down
ifconfig eth1 down

$  bash dd_write_SD10.sh

#!/bin/bash
# Since we're dealing with dd, abort if any errors occur
set -e
TEST_FILE=${1:-dd_obs_testfile}
TEST_FILE_EXISTS=0
if [ -e "$TEST_FILE" ]; then TEST_FILE_EXISTS=1; fi
TEST_FILE_SIZE=3221225472
if [ $EUID -ne 0 ]; then
echo "NOTE: Kernel cache will not be cleared between tests without sudo. This will likely cause
inaccurate results." 1>&2
fi
# Header
PRINTF_FORMAT="%8s : %s\n"
printf "$PRINTF_FORMAT" 'block size' 'transfer rate'
# Block sizes of 512b 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M
for BLOCK_SIZE in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152
4194304 8388608 16777216 33554432 67108864
do
# Calculate number of segments required to copy
COUNT=$(($TEST_FILE_SIZE / $BLOCK_SIZE))
if [ $COUNT -le 0 ]; then
echo "Block size of $BLOCK_SIZE estimated to require $COUNT blocks, aborting further tests."
break
fi
# Clear kernel cache to ensure more accurate test
[ $EUID -eq 0 ] && [ -e /proc/sys/vm/drop_caches ] && echo 3 > /proc/sys/vm/drop_caches
# Create a test file with the specified block size
DD_RESULT=$(dd if=/dev/zero of=$TEST_FILE bs=$BLOCK_SIZE count=$COUNT conv=fsync 2>&1 1>/dev/null)
# Extract the transfer rate from dd's STDERR output
TRANSFER_RATE=$(echo $DD_RESULT | \grep --only-matching -E '[0-9.]+ ([MGk]?B|bytes)/s(ec)?')
## Clean up the test file if we created one
# Output the result
printf "$PRINTF_FORMAT" "$BLOCK_SIZE" "$TRANSFER_RATE"
done

 

測量數據 :


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

測試結果 : 請查閱

 

(4) Product use case

 Machine vision (1xISP) 

操作方式 :

$ bash coremark_cpu_limit.sh 50

#!/bin/bash
while true; do
./coremark.exe &
pid=$!
taskset -cp 3 $pid
./cpulimit -l $1 -p $pid
done

$ bash ML.sh

#!/bin/bash
rep=$1
cd /usr/bin/tensorflow-lite-2.3.1/examples
for i in $( eval echo {1..$rep} )
do
/usr/bin/tensorflow-lite-2.3.1/examples/benchmark_model --
graph=mobilenet_v1_1.0_224_quant.tflite --num_runs=22000 --use_nnapi=true &
done

運行 GStreamer 範例程式 ( 1080p w/ ISP , HEVC encode )  :

$ gst-launch-1.0 v4l2src device=/dev/video3 !  imxvideoconvert_g2d !  "video/x-raw,width=640,height=480,framerate=30/1"! vpuenc_hevc qos=false ! mpegtsmux ! filesink location=./test_h265.ts

 

測量數據 :


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

測試結果 : 請查閱

 

 eIQ Benchmarking tests 

操作方式 :

$ /usr/bin/tensorflow-lite-2.3.1/examples/ML.sh

#!/bin/bash
cd /usr/bin/tensorflow-lite-2.9.1/examples
/usr/bin/tensorflow-lite-2.9.1/examples/benchmark_model --graph=mobilenet_v1_1.0_224_quant.tflite --num_runs=22000 --use_nnapi=true &

 

測量數據 :


圖文來源 :  i.MX 8M Plus Power Consumption Measurement

 

測試結果 : 請查閱

 

 

三.  結語

如同上一章節所述,這裡復刻了原廠所提供的應用場景,讀者僅須要輸入相應的指令操作即可復現。並可以搭配 BCU 或 PMT 工具的結果來比對當前電壓電流數據與原廠提供的標準數據是否相符。同時,作者也分享數個實際測試的數據,有興趣的讀者可以點選連結來查閱比對數據。下一篇,將由專業的硬體工程師來介紹 “實際應用 - 硬體驗證”。敬請期待 !!

 

 

四.  參考文件

[1] 官方文件 - Board Remote Control Utilities (BCU) Release Notes
[2] 官方文件 - BCU 原始代碼
[3] 官方文件 - i.MX 8M Plus Power Consumption Measurement
[4] 官方文件 - i.MX 8M Plus Power Measurement Board User's Guide
[5] 官方文件 - i.MX 8M Plus Power Consumption Measurement
[6] 官方文件 – PMT 原始代碼

如有任何相關 Power Measurement 進階技術問題,歡迎至博文底下留言提問 !!
接下來還會分享更多技術文章 !!敬請期待 【ATU Book-i.MX8系列 – Power Measurement】 !!

  

★博文內容均由個人提供,與平台無關,如有違法或侵權,請與網站管理員聯繫。

★文明上網,請理性發言。內容一周內被舉報5次,發文人進小黑屋喔~

評論