一、原生的读取版本接口是/proc/version,我这里需要提供获取固件版本号的api给app,因为版本号会经常需要修改,如果每次都到kernel下修改比较麻烦,我这里是想在编译脚本里面对版本号进行修改,这样方便一点。
二、主要修改kernel/fs/proc/version.c kernel/scripts/mkcompile_h ,我的编译脚本里面会去调用我的mk文件去设置环境变量。
BOARD_CONFIG=$TOP_DIR/device/xxx/px30/BoardConfig-px30-evb-ddr4-v11-xxx-board.mk
source $BOARD_CONFIG
diff --git a/device/rockchip/px30/BoardConfig-px30-evb-ddr4-v11-uic-board.mk b/device/rockchip/px30/BoardConfig-px30-evb-ddr4-v11-uic-board.mk
index 21bc39866..b8841fb9f 100755
--- a/device/rockchip/px30/BoardConfig-px30-evb-ddr4-v11-uic-board.mk
+++ b/device/rockchip/px30/BoardConfig-px30-evb-ddr4-v11-uic-board.mk
@@ -51,3 +51,4 @@ export RK_USERDATA_DIR=userdata_normal
export RK_MISC=wipe_all-misc.img
#choose enable distro module
export RK_DISTRO_MODULE=
+export DEVICE_FIRMWARE_VERSION=v2.00
\ No newline at end of file
diff --git a/kernel/fs/proc/version.c b/kernel/fs/proc/version.c
old mode 100644
new mode 100755
index b5d4a052a..27f8a15cf
--- a/kernel/fs/proc/version.c
+++ b/kernel/fs/proc/version.c
@@ -17,7 +17,7 @@ static int version_proc_show(struct seq_file *m, void *v)
static int firmware_version_proc_show(struct seq_file *m, void *v)
{
- seq_printf(m, "V1.0 Date:%s",FIRMWARE_VERSION);
+ seq_printf(m, "%s",DEVICE_FIRMWARE_VERSION);
return 0;
}
diff --git a/kernel/scripts/mkcompile_h b/kernel/scripts/mkcompile_h
index 897165138..bac38c411 100755
--- a/kernel/scripts/mkcompile_h
+++ b/kernel/scripts/mkcompile_h
@@ -66,7 +66,7 @@ UTS_LEN=64
UTS_TRUNCATE="cut -b -$UTS_LEN"
# Generate a temporary compile.h
-
+echo DEVICE_FIRMWARE_VERSION:$DEVICE_FIRMWARE_VERSION
( echo /\* This file is auto generated, version $VERSION \*/
if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi
@@ -74,6 +74,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
echo \#define FIRMWARE_VERSION \"`echo $FIRMWARE_VERSION`\"
+ echo \#define DEVICE_FIRMWARE_VERSION \"`echo $DEVICE_FIRMWARE_VERSION`\"
echo \#define FIRMWARE_VERSION_NUMBER \ `echo $FIRMWARE_VERSION_NUMBER`\
echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
三、编译和执行的结果