mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 22:40:25 +00:00
allow setting custom flipper name
serial & ble mac generated from custom name (if set), CI support added too
This commit is contained in:
parent
4dab3a83a3
commit
a896aa4113
7 changed files with 81 additions and 12 deletions
|
@ -106,6 +106,10 @@ static void furi_hal_version_set_name(const char* name) {
|
|||
|
||||
// BLE Mac address
|
||||
uint32_t udn = LL_FLASH_GetUDN();
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
udn = (uint32_t)*version_get_custom_name(NULL);
|
||||
}
|
||||
|
||||
uint32_t company_id = LL_FLASH_GetSTCompanyID();
|
||||
uint32_t device_id = LL_FLASH_GetDeviceID();
|
||||
furi_hal_version.ble_mac[0] = (uint8_t)(udn & 0x000000FF);
|
||||
|
@ -129,7 +133,11 @@ static void furi_hal_version_load_otp_v0() {
|
|||
furi_hal_version.board_body = otp->board_body;
|
||||
furi_hal_version.board_connect = otp->board_connect;
|
||||
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
||||
} else {
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
}
|
||||
|
||||
static void furi_hal_version_load_otp_v1() {
|
||||
|
@ -143,7 +151,11 @@ static void furi_hal_version_load_otp_v1() {
|
|||
furi_hal_version.board_color = otp->board_color;
|
||||
furi_hal_version.board_region = otp->board_region;
|
||||
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
||||
} else {
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
}
|
||||
|
||||
static void furi_hal_version_load_otp_v2() {
|
||||
|
@ -163,7 +175,11 @@ static void furi_hal_version_load_otp_v2() {
|
|||
if(otp->board_color != 0xFF) {
|
||||
furi_hal_version.board_color = otp->board_color;
|
||||
furi_hal_version.board_region = otp->board_region;
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
furi_hal_version_set_name(version_get_custom_name(NULL));
|
||||
} else {
|
||||
furi_hal_version_set_name(otp->name);
|
||||
}
|
||||
} else {
|
||||
furi_hal_version.board_color = 0;
|
||||
furi_hal_version.board_region = 0;
|
||||
|
@ -301,5 +317,8 @@ size_t furi_hal_version_uid_size() {
|
|||
}
|
||||
|
||||
const uint8_t* furi_hal_version_uid() {
|
||||
if(version_get_custom_name(NULL) != NULL) {
|
||||
return (const uint8_t*)((uint32_t)*version_get_custom_name(NULL));
|
||||
}
|
||||
return (const uint8_t*)UID64_BASE;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ struct Version {
|
|||
const char* git_branch;
|
||||
const char* git_branch_num;
|
||||
const char* build_date;
|
||||
const char* custom_flipper_name;
|
||||
const char* version;
|
||||
const uint8_t target;
|
||||
const bool build_is_dirty;
|
||||
|
@ -19,6 +20,11 @@ static const Version version = {
|
|||
.git_branch = GIT_BRANCH,
|
||||
.git_branch_num = GIT_BRANCH_NUM,
|
||||
.build_date = BUILD_DATE,
|
||||
#ifdef FURI_CUSTOM_FLIPPER_NAME
|
||||
.custom_flipper_name = FURI_CUSTOM_FLIPPER_NAME,
|
||||
#else
|
||||
.custom_flipper_name = NULL,
|
||||
#endif
|
||||
.version = VERSION
|
||||
#ifdef FURI_RAM_EXEC
|
||||
" (RAM)"
|
||||
|
@ -52,6 +58,10 @@ const char* version_get_version(const Version* v) {
|
|||
return v ? v->version : version.version;
|
||||
}
|
||||
|
||||
const char* version_get_custom_name(const Version* v) {
|
||||
return v ? v->custom_flipper_name : version.custom_flipper_name;
|
||||
}
|
||||
|
||||
uint8_t version_get_target(const Version* v) {
|
||||
return v ? v->target : version.target;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -64,6 +65,15 @@ const char* version_get_builddate(const Version* v);
|
|||
*/
|
||||
const char* version_get_version(const Version* v);
|
||||
|
||||
/** Get custom flipper name if set in ENV
|
||||
*
|
||||
* @param v pointer to Version data. NULL for currently running
|
||||
* software.
|
||||
*
|
||||
* @return custom name or NULL
|
||||
*/
|
||||
const char* version_get_custom_name(const Version* v);
|
||||
|
||||
/** Get hardware target this firmware was built for
|
||||
*
|
||||
* @param v pointer to Version data. NULL for currently running
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from flipper.app import App
|
||||
from os.path import join, exists
|
||||
from os import makedirs
|
||||
from os import makedirs, environ
|
||||
from update import Main as UpdateMain
|
||||
import shutil
|
||||
|
||||
|
@ -134,6 +134,15 @@ class Main(App):
|
|||
self.logger.info(
|
||||
f"Use this directory to self-update your Flipper:\n\t{bundle_dir}"
|
||||
)
|
||||
log_custom_fz_name = (
|
||||
environ.get("CUSTOM_FLIPPER_NAME", None)
|
||||
or ""
|
||||
)
|
||||
if (log_custom_fz_name != ""):
|
||||
self.logger.info(
|
||||
f"Flipper Custom Name is set:\n\tName: {log_custom_fz_name} : length - {len(log_custom_fz_name)} chars"
|
||||
)
|
||||
|
||||
return UpdateMain(no_exit=True)(bundle_args)
|
||||
|
||||
return 0
|
||||
|
|
|
@ -37,6 +37,21 @@ class GitVersion:
|
|||
or "unknown"
|
||||
)
|
||||
|
||||
custom_fz_name = (
|
||||
os.environ.get("CUSTOM_FLIPPER_NAME", None)
|
||||
or ""
|
||||
)
|
||||
|
||||
if (custom_fz_name != "") and (len(custom_fz_name) <= 8):
|
||||
return {
|
||||
"GIT_COMMIT": commit,
|
||||
"GIT_BRANCH": branch,
|
||||
"GIT_BRANCH_NUM": branch_num,
|
||||
"FURI_CUSTOM_FLIPPER_NAME": custom_fz_name,
|
||||
"VERSION": version,
|
||||
"BUILD_DIRTY": dirty and 1 or 0,
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"GIT_COMMIT": commit,
|
||||
"GIT_BRANCH": branch,
|
||||
|
|
|
@ -76,6 +76,12 @@ vars.Add(
|
|||
default="local",
|
||||
)
|
||||
|
||||
vars.Add(
|
||||
"CUSTOM_FLIPPER_NAME",
|
||||
help="Replaces OTP flipper name with custom string of 8 chars",
|
||||
default="",
|
||||
)
|
||||
|
||||
vars.Add(
|
||||
"UPDATE_VERSION_STRING",
|
||||
help="Version string for updater package",
|
||||
|
|
|
@ -12,7 +12,7 @@ forward_os_env = {
|
|||
"PATH": os.environ["PATH"],
|
||||
}
|
||||
# Proxying CI environment to child processes & scripts
|
||||
for env_value_name in ("WORKFLOW_BRANCH_OR_TAG", "DIST_SUFFIX", "HOME", "APPDATA"):
|
||||
for env_value_name in ("WORKFLOW_BRANCH_OR_TAG", "DIST_SUFFIX", "CUSTOM_FLIPPER_NAME", "HOME", "APPDATA"):
|
||||
if environ_value := os.environ.get(env_value_name, None):
|
||||
forward_os_env[env_value_name] = environ_value
|
||||
|
||||
|
|
Loading…
Reference in a new issue