[FL-1464] Cli: merge version and hwinfo into device_info (#553)

* Cli: merge version and hwinfo and form machine/human readable key value set.
* Backport F6 changes to F5. Add readme to cli_command_device_info rountine
* Cli: return proper order to radio stack version in device_info command

Co-authored-by: SG <who.just.the.doctor@gmail.com>
This commit is contained in:
あく
2021-07-02 03:58:31 +03:00
committed by GitHub
parent d088c28659
commit 5d14dce013
11 changed files with 181 additions and 77 deletions

View File

@@ -1,18 +0,0 @@
#pragma once
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Get platform UID size in bytes */
size_t api_hal_uid_size();
/** Get const pointer to UID */
const uint8_t* api_hal_uid();
#ifdef __cplusplus
}
#endif

View File

@@ -15,6 +15,9 @@ void api_hal_version_init();
/** Check target firmware version */
bool api_hal_version_do_i_belong_here();
/** Get model name */
const char* api_hal_version_get_model_name();
/** Get hardware version */
const uint8_t api_hal_version_get_hw_version();
@@ -24,9 +27,15 @@ const uint8_t api_hal_version_get_hw_target();
/** Get hardware body */
const uint8_t api_hal_version_get_hw_body();
/** Get hardware body color */
const uint8_t api_hal_version_get_hw_color();
/** Get hardware connect */
const uint8_t api_hal_version_get_hw_connect();
/** Get hardware region */
const uint8_t api_hal_version_get_hw_region();
/** Get hardware timestamp */
const uint32_t api_hal_version_get_hw_timestamp();
@@ -39,6 +48,8 @@ const char* api_hal_version_get_device_name_ptr();
/** Get pointer to target ble local device name */
const char* api_hal_version_get_ble_local_device_name_ptr();
const uint8_t* api_hal_version_get_ble_mac();
/**
* Get address of version structure of bootloader, stored in chip flash.
*
@@ -51,7 +62,13 @@ const struct Version* api_hal_version_get_boot_version(void);
*
* @return Address of firmware version structure.
*/
const struct Version* api_hal_version_get_fw_version(void);
const struct Version* api_hal_version_get_firmware_version(void);
/** Get platform UID size in bytes */
size_t api_hal_version_uid_size();
/** Get const pointer to UID */
const uint8_t* api_hal_version_uid();
#ifdef __cplusplus
}

View File

@@ -16,7 +16,6 @@ template <unsigned int N> struct STOP_EXTERNING_ME {};
#include "api-hal-power.h"
#include "api-hal-vcp.h"
#include "api-hal-version.h"
#include "api-hal-uid.h"
#include "api-hal-bt.h"
#include "api-hal-spi.h"
#include "api-hal-flash.h"

View File

@@ -1,10 +0,0 @@
#include <api-hal-uid.h>
#include <stm32wbxx.h>
size_t api_hal_uid_size() {
return 64/8;
}
const uint8_t* api_hal_uid() {
return (const uint8_t *)UID64_BASE;
}

View File

@@ -16,12 +16,13 @@ typedef struct {
} ApiHalVersionOTP;
#define FLIPPER_ARRAY_NAME_LENGTH (FLIPPER_NAME_LENGTH + 1)
// BLE symbol + "Flipper Zero " + name
// BLE symbol + "Flipper " + name
#define FLIPPER_DEVICE_NAME_LENGTH (1 + 8 + FLIPPER_ARRAY_NAME_LENGTH)
// Initialiazed from OTP, used to guarantee zero terminated C string
static char flipper_name[FLIPPER_ARRAY_NAME_LENGTH];
static char flipper_device_name[FLIPPER_DEVICE_NAME_LENGTH];
static uint8_t api_hal_version_ble_mac[6];
void api_hal_version_init() {
char* name = ((ApiHalVersionOTP*)OTP_AREA_BASE)->name;
@@ -41,12 +42,27 @@ void api_hal_version_init() {
}
flipper_device_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
// BLE Mac address
uint32_t udn = LL_FLASH_GetUDN();
uint32_t company_id = LL_FLASH_GetSTCompanyID();
uint32_t device_id = LL_FLASH_GetDeviceID();
api_hal_version_ble_mac[0] = (uint8_t)(udn & 0x000000FF);
api_hal_version_ble_mac[1] = (uint8_t)( (udn & 0x0000FF00) >> 8 );
api_hal_version_ble_mac[2] = (uint8_t)( (udn & 0x00FF0000) >> 16 );
api_hal_version_ble_mac[3] = (uint8_t)device_id;
api_hal_version_ble_mac[4] = (uint8_t)(company_id & 0x000000FF);;
api_hal_version_ble_mac[5] = (uint8_t)( (company_id & 0x0000FF00) >> 8 );
}
bool api_hal_version_do_i_belong_here() {
return api_hal_version_get_hw_target() == 5;
}
const char* api_hal_version_get_model_name() {
return "Flipper Zero";
}
const uint8_t api_hal_version_get_hw_version() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->version;
}
@@ -59,10 +75,18 @@ const uint8_t api_hal_version_get_hw_body() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->body;
}
const uint8_t api_hal_version_get_hw_color() {
return 0;
}
const uint8_t api_hal_version_get_hw_connect() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->connect;
}
const uint8_t api_hal_version_get_hw_region() {
return 0;
}
const uint32_t api_hal_version_get_hw_timestamp() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->timestamp;
}
@@ -79,7 +103,11 @@ const char* api_hal_version_get_ble_local_device_name_ptr() {
return flipper_device_name;
}
const struct Version* api_hal_version_get_fw_version(void) {
const uint8_t* api_hal_version_get_ble_mac() {
return api_hal_version_ble_mac;
}
const struct Version* api_hal_version_get_firmware_version(void) {
return version_get();
}
@@ -91,3 +119,11 @@ const struct Version* api_hal_version_get_boot_version(void) {
return (const struct Version*)LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR1);
#endif
}
size_t api_hal_version_uid_size() {
return 64/8;
}
const uint8_t* api_hal_version_uid() {
return (const uint8_t *)UID64_BASE;
}

View File

@@ -1,10 +0,0 @@
#include <api-hal-uid.h>
#include <stm32wbxx.h>
size_t api_hal_uid_size() {
return 64/8;
}
const uint8_t* api_hal_uid() {
return (const uint8_t *)UID64_BASE;
}

View File

@@ -22,6 +22,7 @@ typedef struct {
// Initialiazed from OTP, used to guarantee zero terminated C string
static char flipper_name[FLIPPER_ARRAY_NAME_LENGTH];
static char flipper_device_name[FLIPPER_DEVICE_NAME_LENGTH];
static uint8_t api_hal_version_ble_mac[6];
void api_hal_version_init() {
char* name = ((ApiHalVersionOTP*)OTP_AREA_BASE)->name;
@@ -41,12 +42,27 @@ void api_hal_version_init() {
}
flipper_device_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
// BLE Mac address
uint32_t udn = LL_FLASH_GetUDN();
uint32_t company_id = LL_FLASH_GetSTCompanyID();
uint32_t device_id = LL_FLASH_GetDeviceID();
api_hal_version_ble_mac[0] = (uint8_t)(udn & 0x000000FF);
api_hal_version_ble_mac[1] = (uint8_t)( (udn & 0x0000FF00) >> 8 );
api_hal_version_ble_mac[2] = (uint8_t)( (udn & 0x00FF0000) >> 16 );
api_hal_version_ble_mac[3] = (uint8_t)device_id;
api_hal_version_ble_mac[4] = (uint8_t)(company_id & 0x000000FF);;
api_hal_version_ble_mac[5] = (uint8_t)( (company_id & 0x0000FF00) >> 8 );
}
bool api_hal_version_do_i_belong_here() {
return api_hal_version_get_hw_target() == 6;
}
const char* api_hal_version_get_model_name() {
return "Flipper Zero";
}
const uint8_t api_hal_version_get_hw_version() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->version;
}
@@ -59,10 +75,18 @@ const uint8_t api_hal_version_get_hw_body() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->body;
}
const uint8_t api_hal_version_get_hw_color() {
return 0;
}
const uint8_t api_hal_version_get_hw_connect() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->connect;
}
const uint8_t api_hal_version_get_hw_region() {
return 0;
}
const uint32_t api_hal_version_get_hw_timestamp() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->timestamp;
}
@@ -79,7 +103,11 @@ const char* api_hal_version_get_ble_local_device_name_ptr() {
return flipper_device_name;
}
const struct Version* api_hal_version_get_fw_version(void) {
const uint8_t* api_hal_version_get_ble_mac() {
return api_hal_version_ble_mac;
}
const struct Version* api_hal_version_get_firmware_version(void) {
return version_get();
}
@@ -91,3 +119,11 @@ const struct Version* api_hal_version_get_boot_version(void) {
return (const struct Version*)LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR1);
#endif
}
size_t api_hal_version_uid_size() {
return 64/8;
}
const uint8_t* api_hal_version_uid() {
return (const uint8_t *)UID64_BASE;
}