diff --git a/build.sh b/build.sh index 42528e3..b90a08f 100755 --- a/build.sh +++ b/build.sh @@ -27,6 +27,9 @@ test_option="no" case_id=21 ape_core_mask=0xf platform_build_data=0x20230926 +spu_version=`git log -1 --format="%H"` +spu_tag=`git tag | sed -n '$p'` +spu_build_date=`date +"%Y-%m-%d-%H:%M:%S"` while [[ "$#" > 0 ]]; do case $1 in @@ -101,8 +104,13 @@ export test_option=${test_option} export test_id=${case_id} export ape_core_mask=$((ape_core_mask)) export platform_build_data=$((platform_build_data)) +export spu_version=${spu_version} +export spu_tag=${spu_tag} +export spu_build_date=${spu_build_date} + #echo "# ape_core_mask:$ape_core_mask,platform_build_data:$platform_build_data" printf "#ape_core_mask[0x%x], #platform_build_data[0x%x]\n" $ape_core_mask $platform_build_data +printf "#spu_version[%s], spu_tag[%s], spu_build_date:[%s]\n" $spu_version $spu_tag $spu_build_date make -f ${MAKE_DIR}/makefile.lib makefile_set="makefile.ape_spu makefile.ecs_rfm_spu0 makefile.ecs_rfm_spu1 makefile.pet_rfm_spu0 makefile.pet_rfm_spu1" diff --git a/inc/osp_ape.h b/inc/osp_ape.h index d1bb92c..60b032d 100644 --- a/inc/osp_ape.h +++ b/inc/osp_ape.h @@ -2,9 +2,35 @@ #define __OSP_APE_INTERFACE_H__ /****************************UCP2.0 Platform start***********************************/ + +#define MAX_BUF_VERSION_LEN (128) + +typedef struct SpuVersionInfo { + char platform_commit[MAX_BUF_VERSION_LEN]; + char platform_tag[MAX_BUF_VERSION_LEN]; + char platform_build_date[MAX_BUF_VERSION_LEN/2]; +} SpuVersionInfo_t; + /************************************************************************************/ /* shell相关接口定义 */ /************************************************************************************/ +/* + * 函数名称: spu_show_version + * 函数入参: void + * 函数功能:输出SPU侧的版本信息 + * ret: void + */ +void spu_show_version(void); + +/* + * 函数名称: 获取SPU侧的版本信息 + * 函数入参: pVersion [out]: 版本信息结构体指针 + * 函数功能:返回SPU侧版本信息 + * ret: 0-success, 1-error + */ +int32_t spu_version_get(SpuVersionInfo_t *pVersion); + + /* shell命令回调函数类型 */ typedef unsigned long (*OSP_FUNCPTR)(); diff --git a/public/common/platform/inc/spu_version.h b/public/common/platform/inc/spu_version.h new file mode 100644 index 0000000..bc0a7ab --- /dev/null +++ b/public/common/platform/inc/spu_version.h @@ -0,0 +1,17 @@ +#ifndef __SPU_VERSION__ +#define __SPU_VERSION__ + +#define MAX_BUF_VERSION_LEN (128) + +typedef struct SpuVersionInfo { + char platform_commit[MAX_BUF_VERSION_LEN]; + char platform_tag[MAX_BUF_VERSION_LEN]; + char platform_build_date[MAX_BUF_VERSION_LEN/2]; +} SpuVersionInfo_t; + + +void spu_show_version(void); +int32_t spu_version_get(SpuVersionInfo_t *pVersion); + + +#endif /* __SPU_VERSION__ */ diff --git a/public/common/platform/src/spu_shell.s.c b/public/common/platform/src/spu_shell.s.c index b0ce132..bdfd564 100644 --- a/public/common/platform/src/spu_shell.s.c +++ b/public/common/platform/src/spu_shell.s.c @@ -7,6 +7,7 @@ #include "ucp_utility.h" #include "typedef.h" #include "phy_para.h" +#include "spu_version.h" OSP_CMD_RTN gastCmdRtnTblExt[MAX_EXT_CMD_NUM]; @@ -147,6 +148,10 @@ int spu_shell_init(void) spu_insert_cmd_ext("csu_ape", (OSP_FUNCPTR)spu_csu_stop_cfg, "cfg csu info", 2); spu_insert_cmd_ext("level_ape", (OSP_FUNCPTR)spu_log_level_set, "cfg ape print level", 1); spu_insert_cmd_ext("slevel_ape", (OSP_FUNCPTR)spu_log_level_get, "get ape print level", 0); + /* 注册版本信息 */ + if (11 == g_core_id) { + spu_insert_cmd_ext("ver_spu", (OSP_FUNCPTR)spu_show_version, "show spu soft version", 0); + } return 0; } diff --git a/public/common/platform/src/spu_version.c b/public/common/platform/src/spu_version.c new file mode 100644 index 0000000..85a1f62 --- /dev/null +++ b/public/common/platform/src/spu_version.c @@ -0,0 +1,51 @@ +#include +#include +#include "spu_shell.h" +#include "ucp_printf.h" +#include "spu_log.h" +#include "ucp_drv_common.h" +#include "ucp_utility.h" +#include "typedef.h" +#include "spu_version.h" + +/* print spu软件版本信息 */ +void spu_show_version() +{ + char pbuf[2048]; + int len = 0; + + len = sprintf(pbuf, "[SPU]\n\rVersion:\t%s\n\rTag:\t\t%s\n\rBuild Date:\t%s\n\r", SPU_VERSION, SPU_TAG, SPU_BUILD_DATE); + + spu_shellinfo_to_arm(pbuf, len, UCP4008_OSP_SHELL); + + return ; +} + +/* + * @brief: 获取SPU版本信息 + * @author: haochen.zhang + * @Date: 2024.5.14 + * @param: pVersion [out] : 版本信息结构体 + */ +int32_t spu_version_get(SpuVersionInfo_t *pVersion) +{ + if (NULL == pVersion) + return -2; + + if ((sizeof(SPU_VERSION) > MAX_BUF_VERSION_LEN) || (sizeof(SPU_TAG) > MAX_BUF_VERSION_LEN) || (sizeof(SPU_TAG) > MAX_BUF_VERSION_LEN/2)) { + return -1; + } + + + memcpy((void *)&pVersion->platform_commit, (void *)SPU_VERSION, sizeof(SPU_VERSION)); + memcpy((void *)&pVersion->platform_tag, (void *)SPU_TAG, sizeof(SPU_TAG)); + memcpy((void *)&pVersion->platform_build_date, (void *)SPU_BUILD_DATE, sizeof(SPU_BUILD_DATE)); + + return 0; +} + + + + + + diff --git a/public/make/makefile.common b/public/make/makefile.common index 790df73..fe5c646 100644 --- a/public/make/makefile.common +++ b/public/make/makefile.common @@ -15,6 +15,11 @@ endif #DEFINES += APE_CORE_MASK=\"$(ape_core_mask)\" DEFINES += APE_CORE_MASK=$(ape_core_mask) DEFINES += PLATFORM_BUILD_DATA=$(platform_build_data) + +DEFINES += SPU_VERSION=\"${spu_version}\" +DEFINES += SPU_TAG=\"${spu_tag}\" +DEFINES += SPU_BUILD_DATE=\"${spu_build_date}\" + ifeq ($(backhaul_option), pcie) DEFINES += PCIE_BACKHAUL endif