diff --git a/build.sh b/build.sh index 570abf5..a6c443a 100755 --- a/build.sh +++ b/build.sh @@ -15,6 +15,9 @@ cache_option="no" test_option="no" case_id=0 board_option="EVB" +arm_version=`git log -1 --format="%H"` +arm_tag=`git tag | sed -n '$p'` +arm_build_date=`date +"%Y-%m-%d-%H:%M:%S"` while [[ "$#" > 0 ]]; do case $1 in @@ -39,7 +42,11 @@ while [[ "$#" > 0 ]]; do *) variants+=" $1"; shift;; esac; done - +export arm_version=${arm_version} +export arm_tag=${arm_tag} +export arm_build_date=${arm_build_date} +printf "#arm_version[%s], arm_tag[%s], arm_build_date:[%s]\n" $arm_version $arm_tag $arm_build_date + export DIR_ROOT=$(cd `dirname "$0"`;pwd) #echo "# script_dir:${DIR_ROOT}" export BUILD_DIR=${DIR_ROOT}/build diff --git a/interface/ospVersion.h b/interface/ospVersion.h new file mode 100644 index 0000000..1c56a88 --- /dev/null +++ b/interface/ospVersion.h @@ -0,0 +1,39 @@ +#ifndef __OSPVERSION__ +#define __OSPVERSION__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_BUF_VERSION_LEN (128) + +typedef struct OspVersionInfo { + char platform_commit[MAX_BUF_VERSION_LEN]; + char platform_tag[MAX_BUF_VERSION_LEN]; + char platform_build_date[MAX_BUF_VERSION_LEN/2]; +} OspVersionInfo_t; + +/* + * @brief: 将ARM、SPU侧版本信息print至终端 + * @Date: 2024.05.17 + * @param: void + * @ret: void + */ +void osp_soft_version_show(); + +/* + * @brief: 获取ARM侧的版本信息 + * @Date: 2024.05.17 + * @param: pVersion [out]: 版本信息结构体指针 + * @ret: 0-success, 1-error + */ +int32_t osp_arm_version_get(OspVersionInfo_t *pVersion); + + +#ifdef __cplusplus +} +#endif + +#endif /* __OSPVERSION__ */ + + diff --git a/makefile b/makefile index 05e3ea7..822e766 100644 --- a/makefile +++ b/makefile @@ -23,6 +23,10 @@ CC = $(CROSS_CC)gcc DEFINES ?= #DEFINES ?= UBLOX_ENABLE +DEFINES += ARM_VERSION=\"${arm_version}\" +DEFINES += ARM_TAG=\"${arm_tag}\" +DEFINES += ARM_BUILD_DATE=\"${arm_build_date}\" + ifeq ($(fronthaul_option),jesd) DEFINES += ENABLE_JESD_TEST endif diff --git a/osp/inc/ospVersion.h b/osp/inc/ospVersion.h new file mode 100644 index 0000000..1c56a88 --- /dev/null +++ b/osp/inc/ospVersion.h @@ -0,0 +1,39 @@ +#ifndef __OSPVERSION__ +#define __OSPVERSION__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_BUF_VERSION_LEN (128) + +typedef struct OspVersionInfo { + char platform_commit[MAX_BUF_VERSION_LEN]; + char platform_tag[MAX_BUF_VERSION_LEN]; + char platform_build_date[MAX_BUF_VERSION_LEN/2]; +} OspVersionInfo_t; + +/* + * @brief: 将ARM、SPU侧版本信息print至终端 + * @Date: 2024.05.17 + * @param: void + * @ret: void + */ +void osp_soft_version_show(); + +/* + * @brief: 获取ARM侧的版本信息 + * @Date: 2024.05.17 + * @param: pVersion [out]: 版本信息结构体指针 + * @ret: 0-success, 1-error + */ +int32_t osp_arm_version_get(OspVersionInfo_t *pVersion); + + +#ifdef __cplusplus +} +#endif + +#endif /* __OSPVERSION__ */ + + diff --git a/osp/src/ospShell.c b/osp/src/ospShell.c index 54cf8db..924a21e 100644 --- a/osp/src/ospShell.c +++ b/osp/src/ospShell.c @@ -23,6 +23,7 @@ #include "pet_sm_mgt.h" #include "msg_transfer_layer.h" #include "ospHeartbeat.h" +#include "ospVersion.h" #define MAX_CMD_LEN (150) /*the max length of a shell command */ @@ -97,6 +98,7 @@ OSP_CMD_RTN ospCmdRtnTbl[MAX_CMD_NUM] = {"hb", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)get_heartbeat_status, "test heartbeat", 0}, {"apecmd", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_ape_cmd_show, "show ape register cmd", 0}, {"armcmd", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_arm_cmd_show, "show arm register cmd", 0}, + {"version", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_soft_version_show, "show soft version info", 0}, //{"level_ape", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_ape_set_log_level, "set ape log level", 1}, //{"csu_stop_ape", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_ape_csu_stop_cfg, "set csu start or stop", 2}, //{"i_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_ape_taskinfo, "show ape task info", 0}, @@ -207,8 +209,9 @@ void help(void) { if (ospApeCmdRtnTbl[i].cmd[0] != 0) { - len += sprintf(buf + len, "%-16s%s\n", ospApeCmdRtnTbl[i].cmd, ospApeCmdRtnTbl[i].descption); - + if (strcmp(ospApeCmdRtnTbl[i].cmd, "ver_spu") != 0) { + len += sprintf(buf + len, "%-16s%s\n", ospApeCmdRtnTbl[i].cmd, ospApeCmdRtnTbl[i].descption); + } } } @@ -1429,7 +1432,6 @@ void osp_arm_cmd_show() return; } - #if 0 void osp_cmd_insert_proc(Osp_Ape_Msg_Head *pMsg) diff --git a/osp/src/ospVersion.c b/osp/src/ospVersion.c new file mode 100644 index 0000000..ee86a24 --- /dev/null +++ b/osp/src/ospVersion.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "osp.h" +#include "ospShell.h" +#include "ospDbg.h" +#include "ospSoftQue.h" +#include "ospBuf.h" +#include "ospTimer.h" +#include "ospHeap.h" +#include "ospTypes.h" +#include "ucp_printf.h" +#include "ospHeap.h" +#include "ospDump.h" +#include "ospSwQueue.h" +#include "pet_sm_mgt.h" +#include "msg_transfer_layer.h" +#include "ospHeartbeat.h" +#include "ospVersion.h" + + +/* print软件版本信息 */ +void osp_soft_version_show() +{ + char buf[4096]; + int32_t len = 0; + + /* show arm version */ + len = sprintf(buf, "\n\r[ARM]\n\rVersion:\t%s\n\rTag:\t\t%s\n\rBuild Date:\t%s\n\r", ARM_VERSION, ARM_TAG, ARM_BUILD_DATE); + osp_net_shell_out(buf, len); + + /* show spuversion */ + osp_ape_msg_send("ver_spu"); + + return; +} + +/* + * @brief: 获取ARM版本信息 + * @author: haochen.zhang + * @Date: 2024.5.14 + * @param: pVersion [out] : 版本信息结构体 + */ +int32_t osp_arm_version_get(OspVersionInfo_t *pVersion) +{ + if (NULL == pVersion) { + return OSP_PAR_ILL; + } + + if ((sizeof(ARM_VERSION) > MAX_BUF_VERSION_LEN) || (sizeof(ARM_TAG) > MAX_BUF_VERSION_LEN) || (sizeof(ARM_BUILD_DATE) > MAX_BUF_VERSION_LEN/2)) { + return OSP_ERROR; + } + + memcpy((void *)&pVersion->platform_commit, (void *)ARM_VERSION, sizeof(ARM_VERSION)); + memcpy((void *)&pVersion->platform_tag, (void *)ARM_TAG, sizeof(ARM_TAG)); + memcpy((void *)&pVersion->platform_build_date, (void *)ARM_BUILD_DATE, sizeof(ARM_BUILD_DATE)); + + return OSP_OK; +} +