Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…irmware into mntm-dev
  • Loading branch information
Willy-JL committed May 13, 2024
2 parents 02a1c16 + 98c51d1 commit 6fc9586
Show file tree
Hide file tree
Showing 46 changed files with 84 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .vscode/example/clangd/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"amiralizadeh9480.cpp-helper",
"marus25.cortex-debug",
"zxh404.vscode-proto3",
"augustocdias.tasks-shell-input"
"augustocdias.tasks-shell-input",
"rioj7.command-variable"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
"twxs.cmake",
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
]
}
}
6 changes: 3 additions & 3 deletions .vscode/example/cpptools/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"configurations": [
{
"name": "Win32",
"compilerPath": "${workspaceFolder}/toolchain/x86_64-windows/bin/arm-none-eabi-gcc.exe",
"compilerPath": "${workspaceFolder}/toolchain/current/bin/arm-none-eabi-gcc.exe",
"intelliSenseMode": "gcc-arm",
"compileCommands": "${workspaceFolder}/build/latest/compile_commands.json",
"cStandard": "gnu23",
"cppStandard": "c++20"
},
{
"name": "Linux",
"compilerPath": "${workspaceFolder}/toolchain/x86_64-linux/bin/arm-none-eabi-gcc",
"compilerPath": "${workspaceFolder}/toolchain/current/bin/arm-none-eabi-gcc",
"intelliSenseMode": "gcc-arm",
"compileCommands": "${workspaceFolder}/build/latest/compile_commands.json",
"cStandard": "gnu23",
"cppStandard": "c++20"
},
{
"name": "Mac",
"compilerPath": "${workspaceFolder}/toolchain/x86_64-darwin/bin/arm-none-eabi-gcc",
"compilerPath": "${workspaceFolder}/toolchain/current/bin/arm-none-eabi-gcc",
"intelliSenseMode": "gcc-arm",
"compileCommands": "${workspaceFolder}/build/latest/compile_commands.json",
"cStandard": "gnu23",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions assets/dolphin/external/L1_Akira_128x64/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1

Width: 128
Height: 64
Passive frames: 15
Active frames: 21
Frames order: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Active cycles: 1
Frame rate: 2
Duration: 360
Active cooldown: 7

Bubble slots: 0
7 changes: 7 additions & 0 deletions assets/dolphin/external/manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,10 @@ Max butthurt: 14
Min level: 11
Max level: 30
Weight: 6

Name: L1_Akira_128x64
Min butthurt: 0
Max butthurt: 14
Min level: 4
Max level: 30
Weight: 5
2 changes: 1 addition & 1 deletion lib/ble_profile/extra_profiles/hid_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static GapConfig template_config = {
.conn_param =
{
.conn_int_min = 0x18, // AN5289: 4.7, we need at least 25ms + advertisement, which is 30 ms
.conn_int_max = 0x18, // 30 ms
.conn_int_max = 0x24, // 45 ms
.slave_latency = 0,
.supervisor_timeout = 0,
},
Expand Down
5 changes: 5 additions & 0 deletions lib/flipper_application/elf/elf_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ __attribute__((unused)) static const char* elf_reloc_type_to_str(int symt) {
STRCASE(R_ARM_NONE)
STRCASE(R_ARM_TARGET1)
STRCASE(R_ARM_ABS32)
STRCASE(R_ARM_REL32)
STRCASE(R_ARM_THM_PC22)
STRCASE(R_ARM_THM_JUMP24)
default:
Expand Down Expand Up @@ -329,6 +330,10 @@ static bool elf_relocate_symbol(ELFFile* elf, Elf32_Addr relAddr, int type, Elf3
*((uint32_t*)relAddr) += symAddr;
FURI_LOG_D(TAG, " R_ARM_ABS32 relocated is 0x%08X", (unsigned int)*((uint32_t*)relAddr));
break;
case R_ARM_REL32:
*((uint32_t*)relAddr) += symAddr - relAddr;
FURI_LOG_D(TAG, " R_ARM_REL32 relocated is 0x%08X", (unsigned int)*((uint32_t*)relAddr));
break;
case R_ARM_THM_PC22:
case R_ARM_CALL:
case R_ARM_THM_JUMP24:
Expand Down
2 changes: 1 addition & 1 deletion targets/f18/furi_hal/furi_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void furi_hal_init_early(void) {
furi_hal_i2c_init_early();
furi_hal_light_init();
furi_hal_rtc_init_early();
furi_hal_version_init();
}

void furi_hal_deinit_early(void) {
Expand All @@ -39,7 +40,6 @@ void furi_hal_init(void) {
furi_hal_interrupt_init();
furi_hal_flash_init();
furi_hal_resources_init();
furi_hal_version_init();
furi_hal_spi_config_init();
furi_hal_spi_dma_init();
furi_hal_speaker_init();
Expand Down
58 changes: 48 additions & 10 deletions targets/f7/ble_glue/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ typedef struct {
FuriThread* thread;
FuriMessageQueue* command_queue;
bool enable_adv;
bool is_secure;
uint8_t negotiation_round;
} Gap;

typedef enum {
Expand Down Expand Up @@ -87,17 +89,46 @@ static void gap_verify_connection_parameters(Gap* gap) {

// Send connection parameters request update if necessary
GapConnectionParamsRequest* params = &gap->config->conn_param;
if(params->conn_int_min > gap->connection_params.conn_interval ||
params->conn_int_max < gap->connection_params.conn_interval) {
FURI_LOG_W(TAG, "Unsupported connection interval. Request connection parameters update");

// Desired max connection interval depends on how many negotiation rounds we had in the past
// In the first negotiation round we want connection interval to be minimum
// If platform disagree then we request wider range
uint16_t connection_interval_max = gap->negotiation_round ? params->conn_int_max :
params->conn_int_min;

// We do care about lower connection interval bound a lot: if it's lower than 30ms 2nd core will not allow us to use flash controller
bool negotiation_failed = params->conn_int_min > gap->connection_params.conn_interval;

// We don't care about upper bound till connection become secure
if(gap->is_secure) {
negotiation_failed |= connection_interval_max < gap->connection_params.conn_interval;
}

if(negotiation_failed) {
FURI_LOG_W(
TAG,
"Connection interval doesn't suite us. Trying to negotiate, round %u",
gap->negotiation_round + 1);
if(aci_l2cap_connection_parameter_update_req(
gap->service.connection_handle,
params->conn_int_min,
params->conn_int_max,
connection_interval_max,
gap->connection_params.slave_latency,
gap->connection_params.supervisor_timeout)) {
FURI_LOG_E(TAG, "Failed to request connection parameters update");
// The other side is not in the mood
// But we are open to try it again
gap->negotiation_round = 0;
} else {
gap->negotiation_round++;
}
} else {
FURI_LOG_I(
TAG,
"Connection interval suits us. Spent %u rounds to negotiate",
gap->negotiation_round);
// Looks like the other side is open to negotiation
gap->negotiation_round = 0;
}
}

Expand All @@ -112,9 +143,9 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) {

event_pckt = (hci_event_pckt*)((hci_uart_pckt*)pckt)->data;

if(gap) {
furi_mutex_acquire(gap->state_mutex, FuriWaitForever);
}
furi_check(gap);
furi_mutex_acquire(gap->state_mutex, FuriWaitForever);

switch(event_pckt->evt) {
case HCI_DISCONNECTION_COMPLETE_EVT_CODE: {
hci_disconnection_complete_event_rp0* disconnection_complete_event =
Expand All @@ -125,6 +156,8 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) {
FURI_LOG_I(
TAG, "Disconnect from client. Reason: %02X", disconnection_complete_event->Reason);
}
gap->is_secure = false;
gap->negotiation_round = 0;
// Enterprise sleep
furi_delay_us(666 + 666);
if(gap->enable_adv) {
Expand Down Expand Up @@ -232,6 +265,7 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) {

case ACI_GAP_SLAVE_SECURITY_INITIATED_VSEVT_CODE:
FURI_LOG_D(TAG, "Slave security initiated");
gap->is_secure = true;
break;

case ACI_GAP_BOND_LOST_VSEVT_CODE:
Expand Down Expand Up @@ -293,9 +327,9 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) {
default:
break;
}
if(gap) {
furi_mutex_release(gap->state_mutex);
}

furi_mutex_release(gap->state_mutex);

return BleEventFlowEnable;
}

Expand Down Expand Up @@ -539,6 +573,10 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
gap->thread = furi_thread_alloc_ex("BleGapDriver", 1024, gap_app, gap);
furi_thread_start(gap->thread);

// Set initial state
gap->is_secure = false;
gap->negotiation_round = 0;

uint8_t adv_service_uid[2];
gap->service.adv_svc_uuid_len = 1;
adv_service_uid[0] = gap->config->adv_service_uuid & 0xff;
Expand Down
2 changes: 1 addition & 1 deletion targets/f7/ble_glue/profiles/serial_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static GapConfig serial_template_config = {
.pairing_method = GapPairingPinCodeShow,
.conn_param = {
.conn_int_min = 0x18, // AN5289: 4.7, we need at least 25ms + advertisement, which is 30 ms
.conn_int_max = 0x18, // 30 ms
.conn_int_max = 0x24, // 45 ms
.slave_latency = 0,
.supervisor_timeout = 0,
}};
Expand Down
2 changes: 1 addition & 1 deletion targets/f7/furi_hal/furi_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void furi_hal_init_early(void) {
furi_hal_i2c_init_early();
furi_hal_light_init();
furi_hal_rtc_init_early();
furi_hal_version_init();
}

void furi_hal_deinit_early(void) {
Expand All @@ -49,7 +50,6 @@ void furi_hal_init(void) {
furi_hal_interrupt_init();
furi_hal_flash_init();
furi_hal_resources_init();
furi_hal_version_init();
furi_hal_region_init();
furi_hal_spi_config_init();
furi_hal_spi_dma_init();
Expand Down

0 comments on commit 6fc9586

Please sign in to comment.