Fix compile.sh and remove build folder

This commit is contained in:
miketsai 2026-04-13 14:31:12 +08:00
parent 548cec2d4f
commit b6928e3ee7
22 changed files with 2 additions and 328 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,46 +0,0 @@
#!/bin/sh
set -e
BIN_DIR=/mnt/flash/plus/kp_firmware/kp_firmware_0/kp_firmware/bin
FW=/mnt/flash/vienna/kp_firmware_host_stream
INI=$BIN_DIR/ini/host_stream.ini
cd $BIN_DIR
# Load hardware drivers if not already loaded (required for EDMC/NPU)
[ -e /dev/vpl_edmc ] || (cd /mnt/flash/vienna/drivers && sh driver.sh 2>/dev/null && sleep 1)
killall -9 kp_firmware_host_stream 2>/dev/null || true
killall -9 rtsps 2>/dev/null || true
sleep 1
rm -f /dev/shm/*
# Optional override: PIXFMT=NV21 MODEL_PATH=nef/other.nef MODEL_ID=xxxxx JOB_ID=yyy ./demo_hdmi.sh
PIXFMT=${PIXFMT:-NV12}
# Model settings — read from INI as default, env var overrides at runtime
_ini_val() { grep "^$1" "$INI" | sed 's/.*= *//' | tr -d '"' | awk '{print $1}'; }
MODEL_PATH=${MODEL_PATH:-$(_ini_val ModelPath)}
MODEL_ID=${MODEL_ID:-$(_ini_val ModelId)}
JOB_ID=${JOB_ID:-$(_ini_val JobId)}
# HDMI demo profile: inference on stream1 (724x362) + HDMI output from stream0 (1920x1080).
# InferenceStream=1: NPU receives 724x362 frames (model native res) — ~8x faster than InferenceStream=0.
# StreamCount=2: creates both stream0 (1920x1080, draw_box+HDMI) and stream1 (724x362, inference) SSMs.
sed -i 's/^NnmSource.*/NnmSource = 0/' $INI
sed -i 's/^GetImageBufMode.*/GetImageBufMode = 0/' $INI
sed -i 's/^InferenceStream.*/InferenceStream = 1/' $INI
sed -i 's/^StreamCount.*/StreamCount = 2/' $INI
sed -i 's/^voc_enable.*/voc_enable = 1/' $INI
sed -i "s/^PixFmt.*/PixFmt = ${PIXFMT}/" $INI
# DrawBoxEnable: respect INI value set by web UI (do not override)
echo "=== HDMI Demo INI ==="
grep -E "ModelPath|ModelId|JobId|NnmSource|GetImageBufMode|InferenceStream|StreamCount|voc_enable|PixFmt" $INI
echo "=== Model (runtime): MODEL_PATH=$MODEL_PATH MODEL_ID=$MODEL_ID JOB_ID=$JOB_ID ==="
echo "=== Start Firmware (HDMI demo) ==="
LD_LIBRARY_PATH=/mnt/flash/vienna/lib $FW -m "$MODEL_PATH" -i "$MODEL_ID" -j "$JOB_ID" &
FW_PID=$!
echo "Firmware PID: $FW_PID"
wait $FW_PID

Binary file not shown.

View File

@ -1,56 +0,0 @@
#!/bin/sh
set -e
BIN_DIR=/mnt/flash/plus/kp_firmware/kp_firmware_0/kp_firmware/bin
FW=/mnt/flash/vienna/kp_firmware_host_stream
INI=$BIN_DIR/ini/host_stream.ini
cd $BIN_DIR
# Load hardware drivers if not already loaded (required for EDMC/NPU)
[ -e /dev/vpl_edmc ] || (cd /mnt/flash/vienna/drivers && sh driver.sh 2>/dev/null && sleep 1)
killall -9 kp_firmware_host_stream 2>/dev/null || true
killall -9 rtsps 2>/dev/null || true
sleep 1
rm -f /dev/shm/*
# Optional overrides:
# PIXFMT=NV21 INF_STREAM=0 MODEL_PATH=nef/other.nef MODEL_ID=xxxxx JOB_ID=yyy ./demo_rtsp.sh
PIXFMT=${PIXFMT:-NV12}
INF_STREAM=${INF_STREAM:-1}
# Model settings — read from INI as default, env var overrides at runtime
_ini_val() { grep "^$1" "$INI" | sed 's/.*= *//' | tr -d '"' | awk '{print $1}'; }
MODEL_PATH=${MODEL_PATH:-$(_ini_val ModelPath)}
MODEL_ID=${MODEL_ID:-$(_ini_val ModelId)}
JOB_ID=${JOB_ID:-$(_ini_val JobId)}
# RTSP demo profile: single-process source + one encoder stream + RTSP server.
sed -i 's/^NnmSource.*/NnmSource = 0/' $INI
sed -i 's/^GetImageBufMode.*/GetImageBufMode = 0/' $INI
sed -i "s/^InferenceStream.*/InferenceStream = ${INF_STREAM}/" $INI
sed -i 's/^StreamCount.*/StreamCount = 2/' $INI
sed -i "s/^PixFmt.*/PixFmt = ${PIXFMT}/" $INI
sed -i 's/^voc_enable.*/voc_enable = 0/' $INI
# DrawBoxEnable: respect INI value set by web UI (do not override)
echo "=== RTSP Demo INI ==="
grep -E "ModelPath|ModelId|JobId|NnmSource|GetImageBufMode|InferenceStream|StreamCount|voc_enable|PixFmt|DrawBoxEnable" $INI
echo "=== Model (runtime): MODEL_PATH=$MODEL_PATH MODEL_ID=$MODEL_ID JOB_ID=$JOB_ID ==="
echo "=== Start Firmware (RTSP demo) ==="
LD_LIBRARY_PATH=/mnt/flash/vienna/lib $FW -m "$MODEL_PATH" -i "$MODEL_ID" -j "$JOB_ID" &
FW_PID=$!
sleep 4
# Start RTSP server that reads venc_srb_* output.
LD_LIBRARY_PATH=/mnt/flash/vienna/lib ./rtsps -c stream_server_config.ini &
RTSP_PID=$!
echo "Firmware PID: $FW_PID"
echo "RTSP PID: $RTSP_PID"
echo "RTSP URL: rtsp://192.168.3.10/live1.sdp"
wait $FW_PID

View File

@ -1,58 +0,0 @@
#!/bin/sh
# by mars
set -e
BIN_DIR=/mnt/flash/plus/kp_firmware/kp_firmware_0/kp_firmware/bin
FW=/mnt/flash/vienna/kp_firmware_host_stream
INI=$BIN_DIR/ini/host_stream.ini
cd $BIN_DIR
# Load hardware drivers if not already loaded (required for EDMC/NPU)
[ -e /dev/vpl_edmc ] || (cd /mnt/flash/vienna/drivers && sh driver.sh 2>/dev/null && sleep 1)
killall -9 kp_firmware_host_stream 2>/dev/null || true
killall -9 rtsps 2>/dev/null || true
sleep 1
rm -f /dev/shm/*
# Optional override: PIXFMT=NV21 MODEL_PATH=nef/other.nef MODEL_ID=xxxxx JOB_ID=yyy ./demo_rtsp_hdmi.sh
PIXFMT=${PIXFMT:-NV12}
# Model settings — read from INI as default, env var overrides at runtime
_ini_val() { grep "^$1" "$INI" | sed 's/.*= *//' | tr -d '"' | awk '{print $1}'; }
MODEL_PATH=${MODEL_PATH:-$(_ini_val ModelPath)}
MODEL_ID=${MODEL_ID:-$(_ini_val ModelId)}
JOB_ID=${JOB_ID:-$(_ini_val JobId)}
# Combined RTSP + HDMI profile.
# InferenceStream=1 uses stream1 (724x362) for inference.
# DrawOnResize=1 so segmentation overlay is drawn on resize streams (RTSP streams).
sed -i 's/^NnmSource.*/NnmSource = 0/' $INI
sed -i 's/^GetImageBufMode.*/GetImageBufMode = 0/' $INI
sed -i 's/^InferenceStream.*/InferenceStream = 1/' $INI
sed -i 's/^StreamCount.*/StreamCount = 2/' $INI
sed -i 's/^voc_enable.*/voc_enable = 1/' $INI
sed -i "s/^PixFmt.*/PixFmt = ${PIXFMT}/" $INI
# DrawBoxEnable: respect INI value set by web UI (do not override)
# DrawOnResize: not needed — firmware auto-disables it when InferenceStream != 0
echo "=== RTSP+HDMI Demo INI ==="
grep -E "ModelPath|ModelId|JobId|NnmSource|GetImageBufMode|InferenceStream|StreamCount|voc_enable|PixFmt|DrawBoxEnable|DrawOnResize" $INI
echo "=== Model (runtime): MODEL_PATH=$MODEL_PATH MODEL_ID=$MODEL_ID JOB_ID=$JOB_ID ==="
echo "=== Start Firmware (RTSP+HDMI demo) ==="
LD_LIBRARY_PATH=/mnt/flash/vienna/lib $FW -m "$MODEL_PATH" -i "$MODEL_ID" -j "$JOB_ID" &
FW_PID=$!
sleep 4
# Start RTSP server that reads venc_srb_* output.
LD_LIBRARY_PATH=/mnt/flash/vienna/lib ./rtsps -c stream_server_config.ini &
RTSP_PID=$!
echo "Firmware PID: $FW_PID"
echo "RTSP PID: $RTSP_PID"
echo "RTSP URL: rtsp://192.168.3.10/live1.sdp"
wait $FW_PID

View File

@ -1,68 +0,0 @@
#!/bin/sh
# deploy.sh — 部署新編譯的 firmware 到裝置並重啟 RTSP demo
#
# 使用方式(在裝置上執行):
# sh deploy.sh
#
# 前提host 192.168.3.1:8080 在提供以下檔案:
# /kp_firmware_host_stream (compile.sh 的輸出)
# /host_stream.ini (kl630_build/ini/host_stream.ini)
#
# 一次性設定(只需在新機器上執行一次,之後重開機不需要再跑):
# sh deploy.sh --setup
set -e
HOST_URL="http://192.168.0.114:8080"
BIN_DIR=/mnt/flash/plus/kp_firmware/kp_firmware_0/kp_firmware/bin
FW=/mnt/flash/vienna/kp_firmware_host_stream
INI=$BIN_DIR/ini/host_stream.ini
# ── 一次性 ISP 資源修正 ─────────────────────────────────────────────────────
# IMX662 DOL-HDR 需要 dwStatisticsSrcType=2 和 bGTREnable=1。
# 這些寫入 flash重開機後自動保留只需要執行一次。
one_time_setup() {
echo "=== 一次性 ISP resource 設定 ==="
sed -i 's/dwStatisticsSrcType = 0/dwStatisticsSrcType = 2/' \
$BIN_DIR/Resource/AWB/AutoWhiteBalance.ini
sed -i 's/bGTREnable = 0/bGTREnable = 1/' \
$BIN_DIR/Resource/ISP/0/pqtable_ispe_Config.cfg
sed -i 's/bGTREnable = 0/bGTREnable = 1/' \
$BIN_DIR/Resource/ISP/1/pqtable_ispe_Config.cfg
echo " dwStatisticsSrcType=$(grep dwStatisticsSrcType $BIN_DIR/Resource/AWB/AutoWhiteBalance.ini | head -1)"
echo " bGTREnable=$(grep bGTREnable $BIN_DIR/Resource/ISP/0/pqtable_ispe_Config.cfg)"
echo "=== 完成,之後重開機不需要再執行 ==="
}
if [ "$1" = "--setup" ]; then
one_time_setup
exit 0
fi
# ── 停止舊的 firmware ─────────────────────────────────────────────────────────
echo "=== 停止舊 firmware ==="
killall -9 kp_firmware_host_stream 2>/dev/null || true
killall -9 rtsps 2>/dev/null || true
sleep 1
rm -f /dev/shm/*
# ── 下載新 binary ─────────────────────────────────────────────────────────────
echo "=== 下載 firmware binary ==="
wget -q "$HOST_URL/kp_firmware_host_stream" -O $FW
chmod +x $FW
echo " $FW: $(ls -lh $FW | awk '{print $5, $6, $7, $8}')"
# ── 下載新 INI保留裝置端的 fusion_cfg / ISP 設定)─────────────────────────
echo "=== 下載 INI ==="
wget -q "$HOST_URL/host_stream.ini" -O $INI
echo " fusion_cfg: $(grep '^fusion_cfg' $INI || echo '(not set!)')"
# ── 下載 demo_rtsp.sh確保裝置上版本與 host 一致)────────────────────────────
echo "=== 下載 demo_rtsp.sh ==="
wget -q "$HOST_URL/demo_rtsp.sh" -O $BIN_DIR/ini/demo_rtsp.sh
chmod +x $BIN_DIR/ini/demo_rtsp.sh
# ── 啟動 RTSP demo ────────────────────────────────────────────────────────────
echo "=== 啟動 RTSP demo ==="
cd $BIN_DIR
sh ./ini/demo_rtsp.sh

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,99 +0,0 @@
[sensor]
sensor_cfg = "./Resource/VIC/0/imx662_1920x1080_ch0.cfg"
fusion_cfg = "./Resource/VIC/1/imx662_1920x1080_ch1.cfg"
autoscene_config = "./Resource/AutoScene/autoscene_conf.cfg"
fec_calibrate_path = "./ini/fec_calibrate.ini"
fec_conf_path = "./ini/fec_conf.ini"
fec_mode = 4 # 0: Original, 1: 1 Region, 2: 180 all direction, 3: 180 one Direction, 4: 180 two direction, 5: PT Mode
initial_fec_app_type = 0 # 0: ceiling, 1: table, 2: wall
eis_enable = 1
[nnm]
ModelPath = "nef/STDC04012026_models_630.nef"
ModelId = 32769 # KNERON_YOLOV5S_COCO80_640_640_3 (YOLO v5s)
JobId = 200 # KDP2_INF_ID_APP_YOLO
InferenceStream = 1 # Inference stream index (use stream1: 640x640)
Threshold = 0.5 # for yolo only(JobId = 11)
Fps = 25 # Image input fps for NPU inference
GetImageBufMode = 0 # 0: block mode 1: non-block mode
RoiEnable = 0 # Enable ROI for nnm detect
RoiX = 0 # ROI start x
RoiY = 0 # ROI start y
DrawBoxEnable = 1 # draw object bounding box on stream0 (also enables STDC seg overlay)
OnlyPerson = 1 # only draw person bounding box when DrawBoxEnable
#(so far for yolo only, JobId = 11)
DrawOnResize = 0; # If InferenceStream is 0. This setting needs to be enabled. The box will be drawn on all resize streams.
verbose_log = 0 # 0: quiet (warnings only, ~30B/s), 1: per-frame class ratios every 20 frames (~1KB/s). Toggle from web UI.
NnmSource = 0 # 0: run host_stream independently, 1: run with streamer
ssm_name = "vsrc_ssm_ifp_0" # If NnmSource is 1. This setting needs to be set. The name is automaticlly create by streamer.
[voc]
voc_enable = 1 #enable Video Output Component
VocWidth = 1920 #video output width
VocHeight = 1080 #video output height
PixFmt = NV12 # HDMI input format for VOC: NV12 / NV21 / YM12
[streamer]
StreamCount = 2 #Stream amount
MemType = 0 #Encode buffer type, 0(SRB mode)/1(SCM mode)
#stream0 is the main stream which has the same resolution as the sensor.
[stream0]
Codec = 0 #VMF_VENC_CODEC_TYPE_H264
Width = 1920 #The image width of stream0
Height = 1080 #The image height of stream0
FPS = 25 #The frame rate of stream0
QP = 25 #The base value of the quantization parameter. Its range is from 0 to 51.
Bitrate = 2000000 #The average bitrate of the encoded stream. Its range is from 30,000 to 700,000,000 bps.
PIQ = 0 #PIQ setting. Reduce the difference of QP between intra and inter frame. Default: 0 (disable).
GOP = 50 #Group of pictures. It specifies the number of frames between two intra frames. The maximum GOP value is 600.
Virt_I_Interval = 0 #Virtual intra frame interval. 0:disable, range: 1 ~ (gop-1)
KeepFrameRatio = 0 # This option is valid only on resized stream.
EncodeBufferSize = 6291456 # 6M: 6*1024*1024 = 6291456
EncodeBufferAmount = 3 # (SRB only)
[stream1]
Codec = 0 #VMF_VENC_CODEC_TYPE_H264
Width = 724 #The image width of stream1 (STDC model training resolution)
Height = 362 #The image height of stream1 (STDC model training resolution)
FPS = 25 #The frame rate of stream0
QP = 25 #The base value of the quantization parameter. Its range is from 0 to 51.
Bitrate = 2000000 #The average bitrate of the encoded stream. Its range is from 30,000 to 700,000,000 bps.
PIQ = 0 #PIQ setting. Reduce the difference of QP between intra and inter frame. Default: 0 (disable).
GOP = 50 #Group of pictures. It specifies the number of frames between two intra frames. The maximum GOP value is 600.
Virt_I_Interval = 0 #Virtual intra frame interval. 0:disable, range: 1 ~ (gop-1)
KeepFrameRatio = 0 # This option is valid only on resized stream.
EncodeBufferSize = 2097152 # 2M: 2*1024*1024 = 2097152
EncodeBufferAmount = 3 # (SRB only)
[stream2]
Codec = 0 #VMF_VENC_CODEC_TYPE_H264
Width = 640 #The image width of stream0
Height = 480 #The image height of stream0
FPS = 25 #The frame rate of stream0
QP = 25 #The base value of the quantization parameter. Its range is from 0 to 51.
Bitrate = 2000000 #The average bitrate of the encoded stream. Its range is from 30,000 to 700,000,000 bps.
PIQ = 0 #PIQ setting. Reduce the difference of QP between intra and inter frame. Default: 0 (disable).
GOP = 50 #Group of pictures. It specifies the number of frames between two intra frames. The maximum GOP value is 600.
Virt_I_Interval = 0 #Virtual intra frame interval. 0:disable, range: 1 ~ (gop-1)
KeepFrameRatio = 0 # This option is valid only on resized stream.
EncodeBufferSize = 2097152 # 2M: 2*1024*1024 = 2097152
EncodeBufferAmount = 3 # (SRB only)
[capture]
# Legacy single-JPEG capture (kept for reference, not used by event_recorder)
enable = 0
http_url = http://192.168.0.114:8081/api/upload
cooldown_ms = 1000
[event]
# Violation event recorder — two-channel: JSON (BT/iPad) + tar.gz (Allxon OOB)
enable = 1
bt_uart_dev = /dev/ttyS1 # Channel A: UART device for DX-BT24 BLE module → iPad
bt_at_probe = 0 # 0: skip AT commands (normal); 1: one-time baud upgrade (factory/reset only)
upload_url = http://192.168.0.114:8081/api/golf.cgi # Channel B: tar.gz upload (OOB/cloud path)
# Production: http://192.168.0.99/api/golf.cgi
sd_path = /tmp/sdcard/events # SD card event archive path
sd_max_mb = 7168 # 7 GB — delete oldest when exceeded
upload_delay_ms = 0 # 0: upload immediately after tar.gz built (tar is built after event ends, no extra delay needed)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -18,6 +18,7 @@ mkdir -p $BUILD_DIR
CFLAGS="-DVATICS_PLATFORM -DKL630 -D_GNU_SOURCE -U_FORTIFY_SOURCE" CFLAGS="-DVATICS_PLATFORM -DKL630 -D_GNU_SOURCE -U_FORTIFY_SOURCE"
CFLAGS="$CFLAGS -march=armv7-a -mfpu=neon -mfloat-abi=hard -Os" CFLAGS="$CFLAGS -march=armv7-a -mfpu=neon -mfloat-abi=hard -Os"
CFLAGS="$CFLAGS -Wall -Wno-unused-variable -Wno-unused-function" CFLAGS="$CFLAGS -Wall -Wno-unused-variable -Wno-unused-function"
#CFLAGS="$CFLAGS -DENABLE_DBG_LOG"
INCLUDES="-I$WORKSPACE/include/host_stream" INCLUDES="-I$WORKSPACE/include/host_stream"
INCLUDES="$INCLUDES -I$WORKSPACE/include/app_flow" INCLUDES="$INCLUDES -I$WORKSPACE/include/app_flow"