Просмотр исходного кода

[FL-1961] Cli: device_info format versioning. Detach target from firmware name. #765

あく 4 лет назад
Родитель
Сommit
2255060d52

+ 2 - 2
applications/about/about.c

@@ -110,7 +110,7 @@ static DialogMessageButton fw_version_screen(DialogsApp* dialogs, DialogMessage*
     } else {
     } else {
         string_cat_printf(
         string_cat_printf(
             buffer,
             buffer,
-            "%s [%s]\n%s [%s]\n[%s] %s",
+            "%s [%s]\n%s [%s]\n[%d] %s",
             version_get_version(ver),
             version_get_version(ver),
             version_get_builddate(ver),
             version_get_builddate(ver),
             version_get_githash(ver),
             version_get_githash(ver),
@@ -140,7 +140,7 @@ static DialogMessageButton boot_version_screen(DialogsApp* dialogs, DialogMessag
     } else {
     } else {
         string_cat_printf(
         string_cat_printf(
             buffer,
             buffer,
-            "%s [%s]\n%s [%s]\n[%s] %s",
+            "%s [%s]\n%s [%s]\n[%d] %s",
             version_get_version(ver),
             version_get_version(ver),
             version_get_builddate(ver),
             version_get_builddate(ver),
             version_get_githash(ver),
             version_get_githash(ver),

+ 9 - 4
applications/cli/cli_commands.c

@@ -55,6 +55,9 @@ static const uint8_t enclave_signature_expected[ENCLAVE_SIGNATURE_KEY_SLOTS][ENC
  * Keys and values format MUST NOT BE changed
  * Keys and values format MUST NOT BE changed
  */
  */
 void cli_command_device_info(Cli* cli, string_t args, void* context) {
 void cli_command_device_info(Cli* cli, string_t args, void* context) {
+    // Device Info version
+    printf("device_info_major   : %d\r\n", 1);
+    printf("device_info_minor   : %d\r\n", 0);
     // Model name
     // Model name
     printf("hardware_model      : %s\r\n", furi_hal_version_get_model_name());
     printf("hardware_model      : %s\r\n", furi_hal_version_get_model_name());
 
 
@@ -88,21 +91,23 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) {
     // Bootloader Version
     // Bootloader Version
     const Version* boot_version = furi_hal_version_get_boot_version();
     const Version* boot_version = furi_hal_version_get_boot_version();
     if(boot_version) {
     if(boot_version) {
-        printf("boot_version        : %s\r\n", version_get_version(boot_version));
-        printf("boot_target         : %s\r\n", version_get_target(boot_version));
         printf("boot_commit         : %s\r\n", version_get_githash(boot_version));
         printf("boot_commit         : %s\r\n", version_get_githash(boot_version));
         printf("boot_branch         : %s\r\n", version_get_gitbranch(boot_version));
         printf("boot_branch         : %s\r\n", version_get_gitbranch(boot_version));
+        printf("boot_branch_num     : %s\r\n", version_get_gitbranchnum(boot_version));
+        printf("boot_version        : %s\r\n", version_get_version(boot_version));
         printf("boot_build_date     : %s\r\n", version_get_builddate(boot_version));
         printf("boot_build_date     : %s\r\n", version_get_builddate(boot_version));
+        printf("boot_target         : %d\r\n", version_get_target(boot_version));
     }
     }
 
 
     // Firmware version
     // Firmware version
     const Version* firmware_version = furi_hal_version_get_firmware_version();
     const Version* firmware_version = furi_hal_version_get_firmware_version();
     if(firmware_version) {
     if(firmware_version) {
-        printf("firmware_version    : %s\r\n", version_get_version(firmware_version));
-        printf("firmware_target     : %s\r\n", version_get_target(firmware_version));
         printf("firmware_commit     : %s\r\n", version_get_githash(firmware_version));
         printf("firmware_commit     : %s\r\n", version_get_githash(firmware_version));
         printf("firmware_branch     : %s\r\n", version_get_gitbranch(firmware_version));
         printf("firmware_branch     : %s\r\n", version_get_gitbranch(firmware_version));
+        printf("firmware_branch_num : %s\r\n", version_get_gitbranchnum(firmware_version));
+        printf("firmware_version    : %s\r\n", version_get_version(firmware_version));
         printf("firmware_build_date : %s\r\n", version_get_builddate(firmware_version));
         printf("firmware_build_date : %s\r\n", version_get_builddate(firmware_version));
+        printf("firmware_target     : %d\r\n", version_get_target(firmware_version));
     }
     }
 
 
     WirelessFwInfo_t pWirelessInfo;
     WirelessFwInfo_t pWirelessInfo;

+ 3 - 2
applications/desktop/scenes/desktop_scene_hw_mismatch.c

@@ -15,8 +15,9 @@ void desktop_scene_hw_mismatch_on_enter(void* context) {
     snprintf(
     snprintf(
         buffer,
         buffer,
         sizeof(buffer),
         sizeof(buffer),
-        "HW target: F%d\nFW target: " TARGET,
-        furi_hal_version_get_hw_target());
+        "HW target: %d\nFW target: %d",
+        furi_hal_version_get_hw_target(),
+        version_get_target(NULL));
     popup_set_context(popup, desktop);
     popup_set_context(popup, desktop);
     popup_set_header(popup, "!!!! HW Mismatch !!!!", 60, 14, AlignCenter, AlignCenter);
     popup_set_header(popup, "!!!! HW Mismatch !!!!", 60, 14, AlignCenter, AlignCenter);
     popup_set_text(popup, buffer, 60, 37, AlignCenter, AlignCenter);
     popup_set_text(popup, buffer, 60, 37, AlignCenter, AlignCenter);

+ 1 - 1
applications/desktop/views/desktop_debug.c

@@ -67,7 +67,7 @@ void desktop_debug_render(Canvas* canvas, void* model) {
         canvas_draw_str(canvas, 5, 43, buffer);
         canvas_draw_str(canvas, 5, 43, buffer);
 
 
         snprintf(
         snprintf(
-            buffer, sizeof(buffer), "[%s] %s", version_get_target(ver), version_get_gitbranch(ver));
+            buffer, sizeof(buffer), "[%d] %s", version_get_target(ver), version_get_gitbranch(ver));
         canvas_draw_str(canvas, 5, 54, buffer);
         canvas_draw_str(canvas, 5, 54, buffer);
 
 
     } else {
     } else {

+ 2 - 0
bootloader/targets/f6/target.mk

@@ -12,6 +12,8 @@ MCU_FLAGS		= -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard
 CFLAGS			+= $(MCU_FLAGS) $(BOOT_CFLAGS) -DSTM32WB55xx -Wall -fdata-sections -ffunction-sections
 CFLAGS			+= $(MCU_FLAGS) $(BOOT_CFLAGS) -DSTM32WB55xx -Wall -fdata-sections -ffunction-sections
 LDFLAGS			+= $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs 
 LDFLAGS			+= $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs 
 
 
+HARDWARE_TARGET = 6
+
 CUBE_DIR		= $(PROJECT_ROOT)/lib/STM32CubeWB
 CUBE_DIR		= $(PROJECT_ROOT)/lib/STM32CubeWB
 
 
 # ST HAL
 # ST HAL

+ 2 - 0
bootloader/targets/f7/target.mk

@@ -12,6 +12,8 @@ MCU_FLAGS		= -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard
 CFLAGS			+= $(MCU_FLAGS) $(BOOT_CFLAGS) -DSTM32WB55xx -Wall -fdata-sections -ffunction-sections
 CFLAGS			+= $(MCU_FLAGS) $(BOOT_CFLAGS) -DSTM32WB55xx -Wall -fdata-sections -ffunction-sections
 LDFLAGS			+= $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs 
 LDFLAGS			+= $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs 
 
 
+HARDWARE_TARGET = 7
+
 CUBE_DIR		= $(PROJECT_ROOT)/lib/STM32CubeWB
 CUBE_DIR		= $(PROJECT_ROOT)/lib/STM32CubeWB
 
 
 # ST HAL
 # ST HAL

+ 8 - 0
core/furi/common_defines.h

@@ -57,3 +57,11 @@
 #ifndef ALIGN
 #ifndef ALIGN
 #define ALIGN(n) __attribute__((aligned(n)))
 #define ALIGN(n) __attribute__((aligned(n)))
 #endif
 #endif
+
+#ifndef STRINGIFY
+#define STRINGIFY(x) #x
+#endif
+
+#ifndef TOSTRING
+#define TOSTRING(x) STRINGIFY(x)
+#endif

+ 1 - 1
firmware/targets/f6/ble-glue/dev_info_service.c

@@ -18,7 +18,7 @@ static DevInfoSvc* dev_info_svc = NULL;
 
 
 static const char dev_info_man_name[] = "Flipper Devices Inc.";
 static const char dev_info_man_name[] = "Flipper Devices Inc.";
 static const char dev_info_serial_num[] = "1.0";
 static const char dev_info_serial_num[] = "1.0";
-static const char dev_info_firmware_rev_num[] = TARGET;
+static const char dev_info_firmware_rev_num[] = TOSTRING(TARGET);
 static const char dev_info_software_rev_num[] = GIT_COMMIT " " GIT_BRANCH " " GIT_BRANCH_NUM " " BUILD_DATE;
 static const char dev_info_software_rev_num[] = GIT_COMMIT " " GIT_BRANCH " " GIT_BRANCH_NUM " " BUILD_DATE;
 
 
 void dev_info_svc_start() {
 void dev_info_svc_start() {

+ 2 - 0
firmware/targets/f6/target.mk

@@ -24,6 +24,8 @@ LDFLAGS			+= $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs
 CPPFLAGS		+= -fno-rtti -fno-use-cxa-atexit -fno-exceptions 
 CPPFLAGS		+= -fno-rtti -fno-use-cxa-atexit -fno-exceptions 
 LDFLAGS			+= -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group
 LDFLAGS			+= -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group
 
 
+HARDWARE_TARGET = 6
+
 MXPROJECT_DIR = $(TARGET_DIR)
 MXPROJECT_DIR = $(TARGET_DIR)
 
 
 # Entry Point
 # Entry Point

+ 1 - 1
firmware/targets/f7/ble-glue/dev_info_service.c

@@ -18,7 +18,7 @@ static DevInfoSvc* dev_info_svc = NULL;
 
 
 static const char dev_info_man_name[] = "Flipper Devices Inc.";
 static const char dev_info_man_name[] = "Flipper Devices Inc.";
 static const char dev_info_serial_num[] = "1.0";
 static const char dev_info_serial_num[] = "1.0";
-static const char dev_info_firmware_rev_num[] = TARGET;
+static const char dev_info_firmware_rev_num[] = TOSTRING(TARGET);
 static const char dev_info_software_rev_num[] = GIT_COMMIT " " GIT_BRANCH " " GIT_BRANCH_NUM " " BUILD_DATE;
 static const char dev_info_software_rev_num[] = GIT_COMMIT " " GIT_BRANCH " " GIT_BRANCH_NUM " " BUILD_DATE;
 
 
 void dev_info_svc_start() {
 void dev_info_svc_start() {

+ 2 - 0
firmware/targets/f7/target.mk

@@ -24,6 +24,8 @@ LDFLAGS			+= $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs
 CPPFLAGS		+= -fno-rtti -fno-use-cxa-atexit -fno-exceptions 
 CPPFLAGS		+= -fno-rtti -fno-use-cxa-atexit -fno-exceptions 
 LDFLAGS			+= -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group
 LDFLAGS			+= -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group
 
 
+HARDWARE_TARGET = 7
+
 MXPROJECT_DIR = $(TARGET_DIR)
 MXPROJECT_DIR = $(TARGET_DIR)
 
 
 # Entry Point
 # Entry Point

+ 2 - 2
lib/toolbox/version.c

@@ -6,7 +6,7 @@ struct Version {
     const char*  git_branch_num;
     const char*  git_branch_num;
     const char*  build_date;
     const char*  build_date;
     const char*  version;
     const char*  version;
-    const char*  target;
+    const uint8_t target;
 };
 };
 
 
 /* version of current running firmware (bootloader/flipper) */
 /* version of current running firmware (bootloader/flipper) */
@@ -44,7 +44,7 @@ const char* version_get_version(const Version* v) {
     return v ? v->version : version.version;
     return v ? v->version : version.version;
 }
 }
 
 
-const char* version_get_target(const Version* v) {
+const uint8_t version_get_target(const Version* v) {
     return v ? v->target : version.target;
     return v ? v->target : version.target;
 }
 }
 
 

+ 38 - 33
lib/toolbox/version.h

@@ -1,71 +1,76 @@
 #pragma once
 #pragma once
 
 
+#include <stdint.h>
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 extern "C" {
 extern "C" {
 #endif
 #endif
 
 
 typedef struct Version Version;
 typedef struct Version Version;
 
 
-/**
- * Gets current running firmware version handle.
- * You can store it somewhere. But if you want to retrieve data,
- * you have to use 'version_*_get()' set of functions.
- * Also, 'version_*_get()' imply to use this
+/** Get current running firmware version handle.
+ *
+ * You can store it somewhere. But if you want to retrieve data, you have to use
+ * 'version_*_get()' set of functions. Also, 'version_*_get()' imply to use this
  * handle if no handle (NULL_PTR) provided.
  * handle if no handle (NULL_PTR) provided.
  *
  *
- * @return Handle to version data.
+ * @return     pointer to Version data.
  */
  */
 const Version* version_get(void);
 const Version* version_get(void);
 
 
-/**
- * Gets git hash of build commit.
+/** Get git commit hash.
  *
  *
- * @param   v - ptr to version handle. If zero - gets current running fw info.
- * @return  git hash
+ * @param      v     pointer to Version data. NULL for currently running
+ *                   software.
+ *
+ * @return     git hash
  */
  */
 const char* version_get_githash(const Version* v);
 const char* version_get_githash(const Version* v);
 
 
-/**
- * Gets git branch of build commit.
+/** Get git branch.
+ *
+ * @param      v     pointer to Version data. NULL for currently running
+ *                   software.
  *
  *
- * @param   v - ptr to version handle. If zero - gets current running fw info.
- * @return  git branch
+ * @return     git branch
  */
  */
 const char* version_get_gitbranch(const Version* v);
 const char* version_get_gitbranch(const Version* v);
 
 
-/**
- * Gets git number of build commit.
+/** Get number of commit in git branch.
  *
  *
- * @param   v - ptr to version handle. If zero - gets current running fw info.
- * @return  number of commit
+ * @param      v     pointer to Version data. NULL for currently running
+ *                   software.
+ *
+ * @return     number of commit
  */
  */
 const char* version_get_gitbranchnum(const Version* v);
 const char* version_get_gitbranchnum(const Version* v);
 
 
-/**
- * Gets build date.
+/** Get build date.
+ *
+ * @param      v     pointer to Version data. NULL for currently running
+ *                   software.
  *
  *
- * @param   v - ptr to version handle. If zero - gets current running fw info.
- * @return  build date
+ * @return     build date
  */
  */
 const char* version_get_builddate(const Version* v);
 const char* version_get_builddate(const Version* v);
 
 
-/**
- * Gets build version.
- * Build version is last tag in git history.
+/** Get build version. Build version is last tag in git history.
  *
  *
- * @param   v - ptr to version handle. If zero - gets current running fw info.
- * @return  build date
+ * @param      v     pointer to Version data. NULL for currently running
+ *                   software.
+ *
+ * @return     build date
  */
  */
 const char* version_get_version(const Version* v);
 const char* version_get_version(const Version* v);
 
 
-/**
- * Gets firmware target.
- * Build version is last tag for build commit.
+/** Get hardware target this firmware was built for
+ *
+ * @param      v     pointer to Version data. NULL for currently running
+ *                   software.
  *
  *
- * @param   v - ptr to version handle. If zero - gets current running fw info.
- * @return  build date
+ * @return     build date
  */
  */
-const char* version_get_target(const Version* v);
+const uint8_t version_get_target(const Version* v);
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }

+ 6 - 6
make/git.mk

@@ -5,9 +5,9 @@ BUILD_DATE		:= $(shell date '+%d-%m-%Y' || echo 'unknown')
 VERSION			:= $(shell git describe --tags --abbrev=0 --exact-match || echo 'unknown')
 VERSION			:= $(shell git describe --tags --abbrev=0 --exact-match || echo 'unknown')
 
 
 CFLAGS += \
 CFLAGS += \
-	-DGIT_COMMIT="\"$(GIT_COMMIT)\"" \
-	-DGIT_BRANCH="\"$(GIT_BRANCH)\"" \
-	-DGIT_BRANCH_NUM="\"$(GIT_BRANCH_NUM)\"" \
-	-DBUILD_DATE="\"$(BUILD_DATE)\"" \
-	-DTARGET="\"$(TARGET)\"" \
-	-DVERSION="\"$(VERSION)\""
+	-DGIT_COMMIT=\"$(GIT_COMMIT)\" \
+	-DGIT_BRANCH=\"$(GIT_BRANCH)\" \
+	-DGIT_BRANCH_NUM=\"$(GIT_BRANCH_NUM)\" \
+	-DBUILD_DATE=\"$(BUILD_DATE)\" \
+	-DVERSION=\"$(VERSION)\" \
+	-DTARGET=$(HARDWARE_TARGET)