mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 05:06:30 +04:00
Merge branch 'ofw_dev' into dev
This commit is contained in:
@@ -344,7 +344,7 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
|
||||
case SubGhzReadRAWStatusLoadKeyTX:
|
||||
case SubGhzReadRAWStatusLoadKeyTXRepeat:
|
||||
graphics_mode = 0;
|
||||
elements_button_center(canvas, "Send");
|
||||
elements_button_center(canvas, "Hold to repeat");
|
||||
break;
|
||||
|
||||
case SubGhzReadRAWStatusStart:
|
||||
|
||||
@@ -179,7 +179,8 @@ static void rpc_system_system_factory_reset_process(const PB_Main* request, void
|
||||
RpcSession* session = (RpcSession*)context;
|
||||
furi_assert(session);
|
||||
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagFactoryReset);
|
||||
furi_hal_rtc_reset_registers();
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagStorageFormatInternal);
|
||||
power_reboot(PowerBootModeNormal);
|
||||
|
||||
(void)session;
|
||||
|
||||
@@ -603,7 +603,8 @@ static void storage_cli_factory_reset(Cli* cli, FuriString* args, void* context)
|
||||
char c = cli_getc(cli);
|
||||
if(c == 'y' || c == 'Y') {
|
||||
printf("Data will be wiped after reboot.\r\n");
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagFactoryReset);
|
||||
furi_hal_rtc_reset_registers();
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagStorageFormatInternal);
|
||||
power_reboot(PowerBootModeNormal);
|
||||
} else {
|
||||
printf("Safe choice.\r\n");
|
||||
|
||||
@@ -189,7 +189,7 @@ static void storage_int_lfs_mount(LFSData* lfs_data, StorageData* storage) {
|
||||
lfs_t* lfs = &lfs_data->lfs;
|
||||
|
||||
bool was_fingerprint_outdated = storage_int_check_and_set_fingerprint(lfs_data);
|
||||
bool need_format = furi_hal_rtc_is_flag_set(FuriHalRtcFlagFactoryReset) ||
|
||||
bool need_format = furi_hal_rtc_is_flag_set(FuriHalRtcFlagStorageFormatInternal) ||
|
||||
was_fingerprint_outdated;
|
||||
|
||||
if(need_format) {
|
||||
@@ -197,7 +197,7 @@ static void storage_int_lfs_mount(LFSData* lfs_data, StorageData* storage) {
|
||||
err = lfs_format(lfs, &lfs_data->config);
|
||||
if(err == 0) {
|
||||
FURI_LOG_I(TAG, "Factory reset: Format successful, trying to mount");
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagFactoryReset);
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagStorageFormatInternal);
|
||||
err = lfs_mount(lfs, &lfs_data->config);
|
||||
if(err == 0) {
|
||||
FURI_LOG_I(TAG, "Factory reset: Mounted");
|
||||
|
||||
@@ -63,7 +63,8 @@ bool storage_settings_scene_factory_reset_on_event(void* context, SceneManagerEv
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, StorageSettingsFactoryReset, counter);
|
||||
} else {
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagFactoryReset);
|
||||
furi_hal_rtc_reset_registers();
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagStorageFormatInternal);
|
||||
power_reboot(PowerBootModeNormal);
|
||||
}
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ int32_t update_task_worker_flash_writer(void* context) {
|
||||
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePostUpdate);
|
||||
// Format LFS before restoring backup on next boot
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagFactoryReset);
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagStorageFormatInternal);
|
||||
#ifdef FURI_NDEBUG
|
||||
// Production
|
||||
furi_hal_rtc_set_log_level(FuriLogLevelDefault);
|
||||
|
||||
@@ -117,12 +117,13 @@ Iso14443_3bError iso14443_3b_poller_activate(Iso14443_3bPoller* instance, Iso144
|
||||
bit_buffer_reset(instance->rx_buffer);
|
||||
|
||||
// Send ATTRIB
|
||||
uint8_t cid = 0;
|
||||
bit_buffer_append_byte(instance->tx_buffer, 0x1d);
|
||||
bit_buffer_append_bytes(instance->tx_buffer, data->uid, ISO14443_3B_UID_SIZE);
|
||||
bit_buffer_append_byte(instance->tx_buffer, 0x00);
|
||||
bit_buffer_append_byte(instance->tx_buffer, ISO14443_3B_ATTRIB_FRAME_SIZE_256);
|
||||
bit_buffer_append_byte(instance->tx_buffer, 0x01);
|
||||
bit_buffer_append_byte(instance->tx_buffer, 0x00);
|
||||
bit_buffer_append_byte(instance->tx_buffer, cid);
|
||||
|
||||
ret = iso14443_3b_poller_frame_exchange(
|
||||
instance, instance->tx_buffer, instance->rx_buffer, iso14443_3b_get_fwt_fc_max(data));
|
||||
@@ -138,11 +139,10 @@ Iso14443_3bError iso14443_3b_poller_activate(Iso14443_3bPoller* instance, Iso144
|
||||
bit_buffer_get_size_bytes(instance->rx_buffer));
|
||||
}
|
||||
|
||||
if(bit_buffer_get_byte(instance->rx_buffer, 0) != 0) {
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"Incorrect CID in ATTRIB response: %02X",
|
||||
bit_buffer_get_byte(instance->rx_buffer, 0));
|
||||
uint8_t cid_received = bit_buffer_get_byte(instance->rx_buffer, 0);
|
||||
// 15 bit is RFU
|
||||
if((cid_received & 0x7f) != cid) {
|
||||
FURI_LOG_D(TAG, "Incorrect CID in ATTRIB response: %02X", cid_received);
|
||||
instance->state = Iso14443_3bPollerStateActivationFailed;
|
||||
ret = Iso14443_3bErrorCommunication;
|
||||
break;
|
||||
|
||||
@@ -371,11 +371,14 @@ static NfcCommand mf_ultralight_poller_handler_read_counters(MfUltralightPoller*
|
||||
}
|
||||
|
||||
static NfcCommand mf_ultralight_poller_handler_read_tearing_flags(MfUltralightPoller* instance) {
|
||||
NfcCommand command = NfcCommandContinue;
|
||||
|
||||
if(mf_ultralight_support_feature(
|
||||
instance->feature_set,
|
||||
MfUltralightFeatureSupportCheckTearingFlag | MfUltralightFeatureSupportSingleCounter)) {
|
||||
if(instance->tearing_flag_read == instance->tearing_flag_total) {
|
||||
instance->state = MfUltralightPollerStateTryDefaultPass;
|
||||
command = NfcCommandReset;
|
||||
} else {
|
||||
bool single_counter = mf_ultralight_support_feature(
|
||||
instance->feature_set, MfUltralightFeatureSupportSingleCounter);
|
||||
@@ -391,6 +394,7 @@ static NfcCommand mf_ultralight_poller_handler_read_tearing_flags(MfUltralightPo
|
||||
} else if(instance->error != MfUltralightErrorNone) {
|
||||
FURI_LOG_D(TAG, "Reading tearing flag %d failed", instance->tearing_flag_read);
|
||||
instance->state = MfUltralightPollerStateTryDefaultPass;
|
||||
command = NfcCommandReset;
|
||||
} else {
|
||||
instance->tearing_flag_read++;
|
||||
}
|
||||
@@ -398,9 +402,10 @@ static NfcCommand mf_ultralight_poller_handler_read_tearing_flags(MfUltralightPo
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "Skip reading tearing flags");
|
||||
instance->state = MfUltralightPollerStateTryDefaultPass;
|
||||
command = NfcCommandReset;
|
||||
}
|
||||
|
||||
return NfcCommandContinue;
|
||||
return command;
|
||||
}
|
||||
|
||||
static NfcCommand mf_ultralight_poller_handler_auth(MfUltralightPoller* instance) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,49.1,,
|
||||
Version,+,49.2,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@@ -1247,6 +1247,7 @@ Function,-,furi_hal_rtc_init_early,void,
|
||||
Function,+,furi_hal_rtc_is_flag_set,_Bool,FuriHalRtcFlag
|
||||
Function,+,furi_hal_rtc_is_leap_year,_Bool,uint16_t
|
||||
Function,+,furi_hal_rtc_reset_flag,void,FuriHalRtcFlag
|
||||
Function,+,furi_hal_rtc_reset_registers,void,
|
||||
Function,+,furi_hal_rtc_set_boot_mode,void,FuriHalRtcBootMode
|
||||
Function,+,furi_hal_rtc_set_datetime,void,FuriHalRtcDateTime*
|
||||
Function,+,furi_hal_rtc_set_fault_data,void,uint32_t
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,49.1,,
|
||||
Version,+,49.2,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
@@ -1443,6 +1443,7 @@ Function,-,furi_hal_rtc_init_early,void,
|
||||
Function,+,furi_hal_rtc_is_flag_set,_Bool,FuriHalRtcFlag
|
||||
Function,+,furi_hal_rtc_is_leap_year,_Bool,uint16_t
|
||||
Function,+,furi_hal_rtc_reset_flag,void,FuriHalRtcFlag
|
||||
Function,+,furi_hal_rtc_reset_registers,void,
|
||||
Function,+,furi_hal_rtc_set_boot_mode,void,FuriHalRtcBootMode
|
||||
Function,+,furi_hal_rtc_set_datetime,void,FuriHalRtcDateTime*
|
||||
Function,+,furi_hal_rtc_set_fault_data,void,uint32_t
|
||||
@@ -2328,8 +2329,8 @@ Function,+,mf_classic_is_value_block,_Bool,"MfClassicSectorTrailer*, uint8_t"
|
||||
Function,+,mf_classic_load,_Bool,"MfClassicData*, FlipperFormat*, uint32_t"
|
||||
Function,+,mf_classic_poller_auth,MfClassicError,"MfClassicPoller*, uint8_t, MfClassicKey*, MfClassicKeyType, MfClassicAuthContext*"
|
||||
Function,+,mf_classic_poller_auth_nested,MfClassicError,"MfClassicPoller*, uint8_t, MfClassicKey*, MfClassicKeyType, MfClassicAuthContext*"
|
||||
Function,+,mf_classic_poller_get_nt_nested,MfClassicError,"MfClassicPoller*, uint8_t, MfClassicKeyType, MfClassicNt*"
|
||||
Function,+,mf_classic_poller_get_nt,MfClassicError,"MfClassicPoller*, uint8_t, MfClassicKeyType, MfClassicNt*"
|
||||
Function,+,mf_classic_poller_get_nt_nested,MfClassicError,"MfClassicPoller*, uint8_t, MfClassicKeyType, MfClassicNt*"
|
||||
Function,+,mf_classic_poller_halt,MfClassicError,MfClassicPoller*
|
||||
Function,+,mf_classic_poller_read_block,MfClassicError,"MfClassicPoller*, uint8_t, MfClassicBlock*"
|
||||
Function,+,mf_classic_poller_sync_auth,MfClassicError,"Nfc*, uint8_t, MfClassicKey*, MfClassicKeyType, MfClassicAuthContext*"
|
||||
|
||||
|
@@ -3,14 +3,21 @@
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi_hal_resources.h>
|
||||
#include <stm32wbxx_ll_comp.h>
|
||||
#include <stm32wbxx_ll_pwr.h>
|
||||
|
||||
#define GET_SYSCFG_EXTI_PORT(gpio) \
|
||||
(((gpio) == (GPIOA)) ? LL_SYSCFG_EXTI_PORTA : \
|
||||
((gpio) == (GPIOB)) ? LL_SYSCFG_EXTI_PORTB : \
|
||||
((gpio) == (GPIOC)) ? LL_SYSCFG_EXTI_PORTC : \
|
||||
((gpio) == (GPIOD)) ? LL_SYSCFG_EXTI_PORTD : \
|
||||
((gpio) == (GPIOE)) ? LL_SYSCFG_EXTI_PORTE : \
|
||||
LL_SYSCFG_EXTI_PORTH)
|
||||
static uint32_t furi_hal_gpio_invalid_argument_crash() {
|
||||
furi_crash("Invalid argument");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define GPIO_PORT_MAP(port, prefix) \
|
||||
(((port) == (GPIOA)) ? prefix##A : \
|
||||
((port) == (GPIOB)) ? prefix##B : \
|
||||
((port) == (GPIOC)) ? prefix##C : \
|
||||
((port) == (GPIOD)) ? prefix##D : \
|
||||
((port) == (GPIOE)) ? prefix##E : \
|
||||
((port) == (GPIOH)) ? prefix##H : \
|
||||
furi_hal_gpio_invalid_argument_crash())
|
||||
|
||||
#define GPIO_PIN_MAP(pin, prefix) \
|
||||
(((pin) == (LL_GPIO_PIN_0)) ? prefix##0 : \
|
||||
@@ -28,11 +35,16 @@
|
||||
((pin) == (LL_GPIO_PIN_12)) ? prefix##12 : \
|
||||
((pin) == (LL_GPIO_PIN_13)) ? prefix##13 : \
|
||||
((pin) == (LL_GPIO_PIN_14)) ? prefix##14 : \
|
||||
prefix##15)
|
||||
((pin) == (LL_GPIO_PIN_15)) ? prefix##15 : \
|
||||
furi_hal_gpio_invalid_argument_crash())
|
||||
|
||||
#define GET_SYSCFG_EXTI_PORT(port) GPIO_PORT_MAP(port, LL_SYSCFG_EXTI_PORT)
|
||||
#define GET_SYSCFG_EXTI_LINE(pin) GPIO_PIN_MAP(pin, LL_SYSCFG_EXTI_LINE)
|
||||
#define GET_EXTI_LINE(pin) GPIO_PIN_MAP(pin, LL_EXTI_LINE_)
|
||||
|
||||
#define GET_PWR_PORT(port) GPIO_PORT_MAP(port, LL_PWR_GPIO_)
|
||||
#define GET_PWR_PIN(pin) GPIO_PIN_MAP(pin, LL_PWR_GPIO_BIT_)
|
||||
|
||||
static volatile GpioInterrupt gpio_interrupt[GPIO_NUMBER];
|
||||
|
||||
static uint8_t furi_hal_gpio_get_pin_num(const GpioPin* gpio) {
|
||||
@@ -65,9 +77,11 @@ void furi_hal_gpio_init_ex(
|
||||
const GpioPull pull,
|
||||
const GpioSpeed speed,
|
||||
const GpioAltFn alt_fn) {
|
||||
uint32_t sys_exti_port = GET_SYSCFG_EXTI_PORT(gpio->port);
|
||||
uint32_t sys_exti_line = GET_SYSCFG_EXTI_LINE(gpio->pin);
|
||||
uint32_t exti_line = GET_EXTI_LINE(gpio->pin);
|
||||
const uint32_t sys_exti_port = GET_SYSCFG_EXTI_PORT(gpio->port);
|
||||
const uint32_t sys_exti_line = GET_SYSCFG_EXTI_LINE(gpio->pin);
|
||||
const uint32_t exti_line = GET_EXTI_LINE(gpio->pin);
|
||||
const uint32_t pwr_port = GET_PWR_PORT(gpio->port);
|
||||
const uint32_t pwr_pin = GET_PWR_PIN(gpio->pin);
|
||||
|
||||
// Configure gpio with interrupts disabled
|
||||
FURI_CRITICAL_ENTER();
|
||||
@@ -92,13 +106,21 @@ void furi_hal_gpio_init_ex(
|
||||
switch(pull) {
|
||||
case GpioPullNo:
|
||||
LL_GPIO_SetPinPull(gpio->port, gpio->pin, LL_GPIO_PULL_NO);
|
||||
LL_PWR_DisableGPIOPullUp(pwr_port, pwr_pin);
|
||||
LL_PWR_DisableGPIOPullDown(pwr_port, pwr_pin);
|
||||
break;
|
||||
case GpioPullUp:
|
||||
LL_GPIO_SetPinPull(gpio->port, gpio->pin, LL_GPIO_PULL_UP);
|
||||
LL_PWR_DisableGPIOPullDown(pwr_port, pwr_pin);
|
||||
LL_PWR_EnableGPIOPullUp(pwr_port, pwr_pin);
|
||||
break;
|
||||
case GpioPullDown:
|
||||
LL_GPIO_SetPinPull(gpio->port, gpio->pin, LL_GPIO_PULL_DOWN);
|
||||
LL_PWR_DisableGPIOPullUp(pwr_port, pwr_pin);
|
||||
LL_PWR_EnableGPIOPullDown(pwr_port, pwr_pin);
|
||||
break;
|
||||
default:
|
||||
furi_crash("Incorrect GpioPull");
|
||||
}
|
||||
|
||||
// Set gpio mode
|
||||
@@ -166,7 +188,7 @@ void furi_hal_gpio_init_ex(
|
||||
LL_GPIO_SetPinMode(gpio->port, gpio->pin, LL_GPIO_MODE_ANALOG);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
furi_crash("Incorrect GpioMode");
|
||||
}
|
||||
}
|
||||
FURI_CRITICAL_EXIT();
|
||||
|
||||
@@ -132,13 +132,7 @@ void furi_hal_rtc_init_early() {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterHeader);
|
||||
FuriHalRtcHeader* data = (FuriHalRtcHeader*)&data_reg;
|
||||
if(data->magic != FURI_HAL_RTC_HEADER_MAGIC || data->version != FURI_HAL_RTC_HEADER_VERSION) {
|
||||
// Reset all our registers to ensure consistency
|
||||
for(size_t i = 0; i < FuriHalRtcRegisterMAX; i++) {
|
||||
furi_hal_rtc_set_register(i, 0);
|
||||
}
|
||||
data->magic = FURI_HAL_RTC_HEADER_MAGIC;
|
||||
data->version = FURI_HAL_RTC_HEADER_VERSION;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterHeader, data_reg);
|
||||
furi_hal_rtc_reset_registers();
|
||||
}
|
||||
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
@@ -171,6 +165,18 @@ void furi_hal_rtc_sync_shadow() {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_rtc_reset_registers() {
|
||||
for(size_t i = 0; i < RTC_BKP_NUMBER; i++) {
|
||||
furi_hal_rtc_set_register(i, 0);
|
||||
}
|
||||
|
||||
uint32_t data_reg = 0;
|
||||
FuriHalRtcHeader* data = (FuriHalRtcHeader*)&data_reg;
|
||||
data->magic = FURI_HAL_RTC_HEADER_MAGIC;
|
||||
data->version = FURI_HAL_RTC_HEADER_VERSION;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterHeader, data_reg);
|
||||
}
|
||||
|
||||
uint32_t furi_hal_rtc_get_register(FuriHalRtcRegister reg) {
|
||||
return LL_RTC_BAK_GetRegister(RTC, reg);
|
||||
}
|
||||
|
||||
@@ -56,8 +56,7 @@ void flipper_boot_recovery_exec() {
|
||||
}
|
||||
|
||||
if(!counter) {
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagFactoryReset);
|
||||
furi_hal_rtc_set_pin_fails(0);
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
|
||||
furi_hal_rtc_reset_registers();
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagStorageFormatInternal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef struct {
|
||||
|
||||
typedef enum {
|
||||
FuriHalRtcFlagDebug = (1 << 0),
|
||||
FuriHalRtcFlagFactoryReset = (1 << 1),
|
||||
FuriHalRtcFlagStorageFormatInternal = (1 << 1),
|
||||
FuriHalRtcFlagLock = (1 << 2),
|
||||
FuriHalRtcFlagC2Update = (1 << 3),
|
||||
FuriHalRtcFlagHandOrient = (1 << 4),
|
||||
@@ -91,6 +91,9 @@ void furi_hal_rtc_init();
|
||||
/** Force sync shadow registers */
|
||||
void furi_hal_rtc_sync_shadow();
|
||||
|
||||
/** Reset ALL RTC registers content */
|
||||
void furi_hal_rtc_reset_registers();
|
||||
|
||||
/** Get RTC register content
|
||||
*
|
||||
* @param[in] reg The register identifier
|
||||
|
||||
Reference in New Issue
Block a user