diff --git a/CHANGELOG.md b/CHANGELOG.md index 15f11eae6..8c88a1791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,7 @@ - Sub-GHz: - Refactor Weather protocols in Sub-GHz app, shows only correct data (by @Willy-JL) - Streamline generic serialize +1.5k free flash (by @Willy-JL) + - UL: Refactor frequency analyzer code for better readability (by @derskythe) - JS: Refactored `widget` and `keyboard` modules with `ViewHolder`, fix crash (by @Willy-JL) - Desktop: - Slim down internal anims, +3.4kb free flash (by @Willy-JL) @@ -100,6 +101,7 @@ -FBT: - OFW: Toolchain v38, clangd as default language server (by @hedger) - OFW: Code formatting update (by @hedger) +- UL: Documentation: Cleanup and format markdown better (by @derskythe) - OFW: Code Cleanup: Unused includes, useless checks, unused variables, etc... (by @skotopes) ### Fixed: diff --git a/applications/main/subghz/views/subghz_frequency_analyzer.c b/applications/main/subghz/views/subghz_frequency_analyzer.c index 1bb2f044f..fde3a1f61 100644 --- a/applications/main/subghz/views/subghz_frequency_analyzer.c +++ b/applications/main/subghz/views/subghz_frequency_analyzer.c @@ -1,7 +1,6 @@ #include "subghz_frequency_analyzer.h" #include -#include #include #include #include @@ -12,20 +11,79 @@ #define TAG "frequency_analyzer" -#define RSSI_MIN -97 -#define RSSI_MAX -60 -#define RSSI_SCALE 2.3 +#define RSSI_MIN (-97.0f) +#define RSSI_MAX (-60.0f) +#define RSSI_SCALE 2.3f #define TRIGGER_STEP 1 #define MAX_HISTORY 4 +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif static const uint32_t subghz_frequency_list[] = { - 300000000, 302757000, 303875000, 303900000, 304250000, 307000000, 307500000, 307800000, - 309000000, 310000000, 312000000, 312100000, 313000000, 313850000, 314000000, 314350000, - 314980000, 315000000, 318000000, 330000000, 345000000, 348000000, 350000000, 387000000, - 390000000, 418000000, 430000000, 431000000, 431500000, 433075000, 433220000, 433420000, - 433657070, 433889000, 433920000, 434075000, 434176948, 434390000, 434420000, 434775000, - 438900000, 440175000, 464000000, 779000000, 868350000, 868400000, 868800000, 868950000, - 906400000, 915000000, 925000000, 928000000}; + /* 300 - 348 */ + 300000000, + 302757000, + 303875000, + 303900000, + 304250000, + 307000000, + 307500000, + 307800000, + 309000000, + 310000000, + 312000000, + 312100000, + 312200000, + 313000000, + 313850000, + 314000000, + 314350000, + 314980000, + 315000000, + 318000000, + 330000000, + 345000000, + 348000000, + 350000000, + + /* 387 - 464 */ + 387000000, + 390000000, + 418000000, + 430000000, + 430500000, + 431000000, + 431500000, + 433075000, /* LPD433 first */ + 433220000, + 433420000, + 433657070, + 433889000, + 433920000, /* LPD433 mid */ + 434075000, + 434176948, + 434190000, + 434390000, + 434420000, + 434620000, + 434775000, /* LPD433 last channels */ + 438900000, + 440175000, + 464000000, + 467750000, + + /* 779 - 928 */ + 779000000, + 868350000, + 868400000, + 868800000, + 868950000, + 906400000, + 915000000, + 925000000, + 928000000, +}; typedef enum { SubGhzFrequencyAnalyzerStatusIDLE, @@ -80,7 +138,7 @@ void subghz_frequency_analyzer_draw_rssi( uint8_t x, uint8_t y) { // Current RSSI - if(rssi) { + if(!float_is_equal(rssi, 0.f)) { if(rssi > RSSI_MAX) { rssi = RSSI_MAX; } @@ -95,7 +153,7 @@ void subghz_frequency_analyzer_draw_rssi( } // Last RSSI - if(rssi_last) { + if(!float_is_equal(rssi_last, 0.f)) { if(rssi_last > RSSI_MAX) { rssi_last = RSSI_MAX; } @@ -108,7 +166,7 @@ void subghz_frequency_analyzer_draw_rssi( // Trigger cursor trigger = (trigger - RSSI_MIN) / RSSI_SCALE; - uint8_t tr_x = x + 2 * trigger; + uint8_t tr_x = (uint8_t)((float)x + (2 * trigger)); canvas_draw_dot(canvas, tr_x, y + 4); canvas_draw_line(canvas, tr_x - 1, y + 5, tr_x + 1, y + 5); @@ -118,7 +176,7 @@ void subghz_frequency_analyzer_draw_rssi( static void subghz_frequency_analyzer_history_frequency_draw( Canvas* canvas, SubGhzFrequencyAnalyzerModel* model) { - char buffer[64]; + char buffer[64] = {0}; const uint8_t x1 = 2; const uint8_t x2 = 66; const uint8_t y = 37; @@ -161,7 +219,7 @@ static void subghz_frequency_analyzer_history_frequency_draw( } void subghz_frequency_analyzer_draw(Canvas* canvas, SubGhzFrequencyAnalyzerModel* model) { - char buffer[64]; + char buffer[64] = {0}; // Title canvas_set_color(canvas, ColorBlack); @@ -190,9 +248,7 @@ void subghz_frequency_analyzer_draw(Canvas* canvas, SubGhzFrequencyAnalyzerModel canvas_draw_box(canvas, 4, 10, 121, 19); canvas_set_color(canvas, ColorWhite); } else { - // TODO: Disable this - //canvas_draw_box(canvas, 4, 11, 121, 19); - //canvas_set_color(canvas, ColorWhite); + canvas_set_color(canvas, ColorBlack); } canvas_draw_str(canvas, 8, 26, buffer); @@ -224,11 +280,14 @@ void subghz_frequency_analyzer_draw(Canvas* canvas, SubGhzFrequencyAnalyzerModel uint32_t subghz_frequency_find_correct(uint32_t input) { uint32_t prev_freq = 0; - uint32_t current = 0; uint32_t result = 0; + uint32_t current; - for(size_t i = 0; i < sizeof(subghz_frequency_list); i++) { + for(size_t i = 0; i < ARRAY_SIZE(subghz_frequency_list) - 1; i++) { current = subghz_frequency_list[i]; + if(current == 0) { + continue; + } if(current == input) { result = current; break; @@ -249,47 +308,40 @@ uint32_t subghz_frequency_find_correct(uint32_t input) { bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { furi_assert(context); - SubGhzFrequencyAnalyzer* instance = context; + SubGhzFrequencyAnalyzer* instance = (SubGhzFrequencyAnalyzer*)context; bool need_redraw = false; - if(event->key == InputKeyBack) { - return false; + return need_redraw; } - if(((event->type == InputTypePress) || (event->type == InputTypeRepeat)) && - ((event->key == InputKeyLeft) || (event->key == InputKeyRight))) { + bool is_press_or_repeat = (event->type == InputTypePress) || (event->type == InputTypeRepeat); + if(is_press_or_repeat && (event->key == InputKeyLeft || event->key == InputKeyRight)) { // Trigger setup float trigger_level = subghz_frequency_analyzer_worker_get_trigger_level(instance->worker); - switch(event->key) { - case InputKeyLeft: + if(event->key == InputKeyLeft) { trigger_level -= TRIGGER_STEP; if(trigger_level < RSSI_MIN) { trigger_level = RSSI_MIN; } - break; - default: - case InputKeyRight: + } else { trigger_level += TRIGGER_STEP; if(trigger_level > RSSI_MAX) { trigger_level = RSSI_MAX; } - break; } subghz_frequency_analyzer_worker_set_trigger_level(instance->worker, trigger_level); FURI_LOG_D(TAG, "trigger = %.1f", (double)trigger_level); need_redraw = true; } else if(event->type == InputTypePress && event->key == InputKeyUp) { - if(instance->feedback_level == 0) { - instance->feedback_level = 2; + if(instance->feedback_level == SubGHzFrequencyAnalyzerFeedbackLevelAll) { + instance->feedback_level = SubGHzFrequencyAnalyzerFeedbackLevelMute; } else { instance->feedback_level--; } need_redraw = true; - } else if( - ((event->type == InputTypePress) || (event->type == InputTypeRepeat)) && - event->key == InputKeyDown) { + } else if(is_press_or_repeat && event->key == InputKeyDown) { instance->show_frame = instance->max_index > 0; if(instance->show_frame) { instance->selected_index = (instance->selected_index + 1) % instance->max_index; @@ -298,63 +350,32 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { } else if(event->key == InputKeyOk) { need_redraw = true; bool updated = false; - uint32_t frequency_to_save = 0; + uint32_t frequency_to_save; with_view_model( instance->view, SubGhzFrequencyAnalyzerModel * model, { frequency_to_save = model->frequency_to_save; + uint32_t prev_freq_to_save = model->frequency_to_save; + uint32_t frequency_candidate = 0; + if(model->show_frame && !model->signal) { - uint32_t prev_freq_to_save = model->frequency_to_save; - uint32_t frequency_candidate = model->history_frequency[model->selected_index]; - if(frequency_candidate == 0 || - // !furi_hal_subghz_is_frequency_valid(frequency_candidate) || - !subghz_txrx_radio_device_is_frequency_valid( - instance->txrx, frequency_candidate) || - prev_freq_to_save == frequency_candidate) { - frequency_candidate = 0; - } else { - frequency_candidate = subghz_frequency_find_correct(frequency_candidate); - } - if(frequency_candidate > 0 && - frequency_candidate != model->frequency_to_save) { - model->frequency_to_save = frequency_candidate; - updated = true; - } - } else if(model->show_frame && model->signal) { - uint32_t prev_freq_to_save = model->frequency_to_save; - uint32_t frequency_candidate = subghz_frequency_find_correct(model->frequency); - if(frequency_candidate == 0 || - // !furi_hal_subghz_is_frequency_valid(frequency_candidate) || - !subghz_txrx_radio_device_is_frequency_valid( - instance->txrx, frequency_candidate) || - prev_freq_to_save == frequency_candidate) { - frequency_candidate = 0; - } else { - frequency_candidate = subghz_frequency_find_correct(frequency_candidate); - } - if(frequency_candidate > 0 && - frequency_candidate != model->frequency_to_save) { - model->frequency_to_save = frequency_candidate; - updated = true; - } - } else if(!model->show_frame && model->signal) { - uint32_t prev_freq_to_save = model->frequency_to_save; - uint32_t frequency_candidate = subghz_frequency_find_correct(model->frequency); - if(frequency_candidate == 0 || - // !furi_hal_subghz_is_frequency_valid(frequency_candidate) || - !subghz_txrx_radio_device_is_frequency_valid( - instance->txrx, frequency_candidate) || - prev_freq_to_save == frequency_candidate) { - frequency_candidate = 0; - } else { - frequency_candidate = subghz_frequency_find_correct(frequency_candidate); - } - if(frequency_candidate > 0 && - frequency_candidate != model->frequency_to_save) { - model->frequency_to_save = frequency_candidate; - updated = true; - } + frequency_candidate = model->history_frequency[model->selected_index]; + } else if( + (model->show_frame && model->signal) || + (!model->show_frame && model->signal)) { + frequency_candidate = subghz_frequency_find_correct(model->frequency); + } + + frequency_candidate = frequency_candidate == 0 || + !subghz_txrx_radio_device_is_frequency_valid( + instance->txrx, frequency_candidate) || + prev_freq_to_save == frequency_candidate ? + 0 : + subghz_frequency_find_correct(frequency_candidate); + if(frequency_candidate > 0 && frequency_candidate != model->frequency_to_save) { + model->frequency_to_save = frequency_candidate; + updated = true; } }, true); @@ -363,7 +384,7 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { instance->callback(SubGhzCustomEventViewFreqAnalOkShort, instance->context); } - // First device receive short, then when user release button we get long + // First the device receives short, then when user release button we get long if(event->type == InputTypeLong && frequency_to_save > 0) { // Stop worker if(subghz_frequency_analyzer_worker_is_running(instance->worker)) { @@ -375,7 +396,6 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { } if(need_redraw) { - SubGhzFrequencyAnalyzer* instance = context; with_view_model( instance->view, SubGhzFrequencyAnalyzerModel * model, @@ -412,7 +432,7 @@ void subghz_frequency_analyzer_pair_callback( uint32_t frequency, float rssi, bool signal) { - SubGhzFrequencyAnalyzer* instance = context; + SubGhzFrequencyAnalyzer* instance = (SubGhzFrequencyAnalyzer*)context; if(float_is_equal(rssi, 0.f) && instance->locked) { if(instance->callback) { instance->callback(SubGhzCustomEventSceneAnalyzerUnlock, instance->context); @@ -477,7 +497,7 @@ void subghz_frequency_analyzer_pair_callback( }, false); instance->max_index = max_index; - } else if((rssi != 0.f) && (!instance->locked)) { + } else if(!float_is_equal(rssi, 0.f) && !instance->locked) { // There is some signal FURI_LOG_I(TAG, "rssi = %.2f, frequency = %ld Hz", (double)rssi, frequency); frequency = round_int(frequency, 3); // Round 299999990Hz to 300000000Hz @@ -490,11 +510,11 @@ void subghz_frequency_analyzer_pair_callback( } // Update values - if(rssi >= instance->rssi_last && (frequency != 0)) { + if(rssi >= instance->rssi_last && frequency != 0) { instance->rssi_last = rssi; } - instance->locked = (rssi != 0.f); + instance->locked = !float_is_equal(rssi, 0.f); with_view_model( instance->view, SubGhzFrequencyAnalyzerModel * model, @@ -514,7 +534,7 @@ void subghz_frequency_analyzer_pair_callback( void subghz_frequency_analyzer_enter(void* context) { furi_assert(context); - SubGhzFrequencyAnalyzer* instance = context; + SubGhzFrequencyAnalyzer* instance = (SubGhzFrequencyAnalyzer*)context; //Start worker instance->worker = subghz_frequency_analyzer_worker_alloc(instance->context); @@ -560,7 +580,7 @@ void subghz_frequency_analyzer_enter(void* context) { void subghz_frequency_analyzer_exit(void* context) { furi_assert(context); - SubGhzFrequencyAnalyzer* instance = context; + SubGhzFrequencyAnalyzer* instance = (SubGhzFrequencyAnalyzer*)context; // Stop worker if(subghz_frequency_analyzer_worker_is_running(instance->worker)) { @@ -574,7 +594,7 @@ void subghz_frequency_analyzer_exit(void* context) { SubGhzFrequencyAnalyzer* subghz_frequency_analyzer_alloc(SubGhzTxRx* txrx) { SubGhzFrequencyAnalyzer* instance = malloc(sizeof(SubGhzFrequencyAnalyzer)); - instance->feedback_level = 2; + instance->feedback_level = SubGHzFrequencyAnalyzerFeedbackLevelMute; // View allocation and configuration instance->view = view_alloc(); diff --git a/documentation/AppManifests.md b/documentation/AppManifests.md index 98a38ffd8..493c9253b 100644 --- a/documentation/AppManifests.md +++ b/documentation/AppManifests.md @@ -16,18 +16,18 @@ Only two parameters are mandatory: **appid** and **apptype**. Others are optiona - **apptype**: member of FlipperAppType.\* enumeration. Valid values are: -| Enum member | Firmware component type | -| ----------- | ------------------------------------------------------------------------------------------- | -| SERVICE | System service, created at early startup | -| SYSTEM | Application is not being shown in any menus. It can be started by other apps or from CLI | -| APP | Regular application for the main menu | -| PLUGIN | Application to be built as a part of the firmware and to be placed in the Plugins menu | -| DEBUG | Application only visible in Debug menu with debug mode enabled | -| ARCHIVE | One and only Archive app | -| SETTINGS | Application to be placed in the system settings menu | -| STARTUP | Callback function to run at system startup. Does not define a separate app | -| EXTERNAL | Application to be built as `.fap` plugin | -| METAPACKAGE | Does not define any code to be run, used for declaring dependencies and application bundles | +| Enum member | Firmware component type | +|:----------------|--------------------------------------------------------------------------------------------------| +| SERVICE | System service, created at early startup | +| SYSTEM | Application is not being shown in any menus. It can be started by other apps or from CLI | +| APP | Regular application for the main menu | +| PLUGIN | Application to be built as a part of the firmware and to be placed in the Plugins menu | +| DEBUG | Application only visible in Debug menu with debug mode enabled | +| ARCHIVE | One and only Archive app | +| SETTINGS | Application to be placed in the system settings menu | +| STARTUP | Callback function to run at system startup. Does not define a separate app | +| EXTERNAL | Application to be built as `.fap` plugin | +| METAPACKAGE | Does not define any code to be run, used for declaring dependencies and application bundles | - **name**: name displayed in menus. - **entry_point**: C function to be used as the application's entry point. Note that C++ function names are mangled, so you need to wrap them in `extern "C"` to use them as entry points. @@ -43,7 +43,7 @@ Only two parameters are mandatory: **appid** and **apptype**. Others are optiona - **targets**: list of strings and target names with which this application is compatible. If not specified, the application is built for all targets. The default value is `["all"]`. - **resources**: name of a folder within the application's source folder to be used for packacking SD card resources for this application. They will only be used if application is included in build configuration. The default value is `""`, meaning no resources are packaged. -#### Parameters for external applications +### Parameters for external applications The following parameters are used only for [FAPs](./AppsOnSDCard.md): @@ -59,7 +59,10 @@ The following parameters are used only for [FAPs](./AppsOnSDCard.md): - **fap_extbuild**: provides support for parts of application sources to be built by external tools. Contains a list of `ExtFile(path="file name", command="shell command")` definitions. `fbt` will run the specified command for each file in the list. - **fal_embedded**: boolean, default `False`. Applies only to PLUGIN type. If `True`, the plugin will be embedded into host application's .fap file as a resource and extracted to `apps_assets/APPID` folder on its start. This allows plugins to be distributed as a part of the host application. -Note that commands are executed at the firmware root folder, and all intermediate files must be placed in an application's temporary build folder. For that, you can use pattern expansion by `fbt`: `${FAP_WORK_DIR}` will be replaced with the path to the application's temporary build folder, and `${FAP_SRC_DIR}` will be replaced with the path to the application's source folder. You can also use other variables defined internally by `fbt`. +> [!NOTE] +> These commands are executed at the firmware root folder, and all intermediate files must be placed in an application's temporary build folder. +> For that, you can use pattern expansion by `fbt`: `${FAP_WORK_DIR}` will be replaced with the path to the application's temporary build folder, +> and `${FAP_SRC_DIR}` will be replaced with the path to the application's source folder. You can also use other variables defined internally by `fbt`. Example for building an app from Rust sources: diff --git a/documentation/FuriHalBus.md b/documentation/FuriHalBus.md index 12c5a70ec..7077e3abf 100644 --- a/documentation/FuriHalBus.md +++ b/documentation/FuriHalBus.md @@ -3,15 +3,21 @@ ## Basic info On system startup, most of the peripheral devices are under reset and not clocked by default. This is done to reduce power consumption and to guarantee that the device will always be in the same state before use. + Some crucial peripherals are enabled right away by the system, others must be explicitly enabled by the user code. -**NOTE:** Here and afterwards the word *"system"* refers to any code belonging to the operating system, hardware drivers or built-in applications. +> [!NOTE] +> +> Here and afterwards the word `system` refers to any code belonging to the operating system, +> hardware drivers or built-in applications. -To **ENABLE** a peripheral, call `furi_hal_bus_enable()`. At the time of the call, the peripheral in question MUST be disabled, otherwise a crash will occur to indicate improper use. This means that any given peripheral cannot be enabled twice or more without disabling it first. +To **ENABLE** a peripheral, call `furi_hal_bus_enable()`. At the time of the call, the peripheral in question **MUST** be disabled; +otherwise a crash will occur to indicate improper use. This means that any given peripheral cannot be enabled twice or more without disabling it first. -To **DISABLE** a peripheral, call `furi_hal_bus_disable()`. Likewise, the peripheral in question MUST be enabled, otherwise a crash will occur. +To **DISABLE** a peripheral, call `furi_hal_bus_disable()`. Likewise, the peripheral in question **MUST** be enabled, otherwise a crash will occur. -To **RESET** a peripheral, call `furi_hal_bus_reset()`. The peripheral in question MUST be enabled, otherwise a crash will occur. This method is used whenever it is necessary to reset all the peripheral's registers to their initial states without disabling it. +To **RESET** a peripheral, call `furi_hal_bus_reset()`. The peripheral in question MUST be enabled, otherwise a crash will occur. +This method is used whenever it is necessary to reset all the peripheral's registers to their initial states without disabling it. ## Peripherals @@ -22,26 +28,28 @@ Built-in peripherals are divided into three categories: ### Always-on peripherals -Below is the list of peripherals that are enabled by the system. The user code must NEVER attempt to disable them. If a corresponding API is provided, the user code must employ it in order to access the peripheral. +Below is the list of peripherals that are enabled by the system. The user code must **NEVER** attempt to disable them. + +If a corresponding API is provided, the user code must employ it in order to access the peripheral. *Table 1* - Peripherals enabled by the system -| Peripheral | Enabled at | -| :-----------: | :-----------------------: | -| DMA1 | `furi_hal_dma.c` | -| DMA2 | -- | -| DMAMUX | -- | -| GPIOA | `furi_hal_resources.c` | -| GPIOB | -- | -| GPIOC | -- | -| GPIOD | -- | -| GPIOE | -- | -| GPIOH | -- | -| PKA | `furi_hal_bt.c` | -| AES2 | -- | -| HSEM | -- | -| IPCC | -- | -| FLASH | enabled by hardware | +| Peripheral | Enabled at | +|:-------------:|:---------------------------:| +| DMA1 | `furi_hal_dma.c` | +| DMA2 | -- | +| DMAMUX | -- | +| GPIOA | `furi_hal_resources.c` | +| GPIOB | -- | +| GPIOC | -- | +| GPIOD | -- | +| GPIOE | -- | +| GPIOH | -- | +| PKA | `furi_hal_bt.c` | +| AES2 | -- | +| HSEM | -- | +| IPCC | -- | +| FLASH | enabled by hardware | ### On-demand system peripherals @@ -51,63 +59,64 @@ When not using the API, these peripherals MUST be enabled by the user code and t *Table 2* - Peripherals enabled and disabled by the system -| Peripheral | API header file | -| :-----------: | :-------------------: | -| RNG | `furi_hal_random.h` | -| SPI1 | `furi_hal_spi.h` | -| SPI2 | -- | -| I2C1 | `furi_hal_i2c.h` | -| I2C3 | -- | -| USART1 | `furi_hal_serial.h` | -| LPUART1 | -- | -| USB | `furi_hal_usb.h` | +| Peripheral | API header file | +|:--------------:|:------------------------:| +| RNG | `furi_hal_random.h` | +| SPI1 | `furi_hal_spi.h` | +| SPI2 | -- | +| I2C1 | `furi_hal_i2c.h` | +| I2C3 | -- | +| USART1 | `furi_hal_serial.h` | +| LPUART1 | -- | +| USB | `furi_hal_usb.h` | ### On-demand shared peripherals -Below is the list of peripherals that are not enabled by default and MUST be enabled by the user code each time it accesses them. +Below is the list of peripherals that are not enabled by default and **MUST** be enabled by the user code each time it accesses them. Note that some of these peripherals may also be used by the system to implement its certain features. + The system will take over any given peripheral only when the respective feature is in use. *Table 3* - Peripherals enabled and disabled by user -| Peripheral | System | Purpose | -| :-----------: | :-------: | ------------------------------------- | -| CRC | | | -| TSC | | | -| ADC | | | -| QUADSPI | | | -| TIM1 | yes | subghz, lfrfid, nfc, infrared, etc... | -| TIM2 | yes | subghz, infrared, etc... | -| TIM16 | yes | speaker | -| TIM17 | yes | cc1101_ext | -| LPTIM1 | yes | tickless idle timer | -| LPTIM2 | yes | pwm | -| SAI1 | | | -| LCD | | | - +| Peripheral | System | Purpose | +|:----------:|:------:|:----------------------------------------| +| CRC | | | +| TSC | | | +| ADC | | | +| QUADSPI | | | +| TIM1 | yes | subghz, lfrfid, nfc, infrared, etc... | +| TIM2 | yes | subghz, infrared, etc... | +| TIM16 | yes | speaker | +| TIM17 | yes | cc1101_ext | +| LPTIM1 | yes | tickless idle timer | +| LPTIM2 | yes | pwm | +| SAI1 | | | +| LCD | | | ## DMA -The DMA1,2 peripherals are a special case in that they have multiple independent channels. Some of the channels may be in use by the system. +The `DMA1`, `DMA2` peripherals are a special case in that they have multiple independent channels. +Some channels may be in use by the system. Below is the list of DMA channels and their usage by the system. *Table 4* - DMA channels -| DMA | Channel | System | Purpose | -| :---: | :-------: | :-------: | ------------------------- | -| DMA1 | 1 | yes | digital signal | -| -- | 2 | yes | -- | -| -- | 3 | | | -| -- | 4 | yes | pulse reader | -| -- | 5 | | | -| -- | 6 | yes | USART_Rx | -| -- | 7 | yes | LPUART_Rx | -| DMA2 | 1 | yes | infrared, lfrfid, subghz, | -| -- | 2 | yes | -- | -| -- | 3 | yes | cc1101_ext | -| -- | 4 | yes | cc1101_ext | -| -- | 5 | yes | cc1101_ext | -| -- | 6 | yes | SPI | -| -- | 7 | yes | SPI | +| DMA | Channel | System | Purpose | +|:------:|:-------:|:------:|:-----------------------------| +| DMA1 | 1 | yes | digital signal | +| -- | 2 | yes | -- | +| -- | 3 | | | +| -- | 4 | yes | pulse reader | +| -- | 5 | | | +| -- | 6 | yes | USART_Rx | +| -- | 7 | yes | LPUART_Rx | +| DMA2 | 1 | yes | infrared, lfrfid, subghz, | +| -- | 2 | yes | -- | +| -- | 3 | yes | cc1101_ext | +| -- | 4 | yes | cc1101_ext | +| -- | 5 | yes | cc1101_ext | +| -- | 6 | yes | SPI | +| -- | 7 | yes | SPI | diff --git a/documentation/devboard/Firmware update on Developer Board.md b/documentation/devboard/Firmware update on Developer Board.md index f6a81d97b..0df5c1f7d 100644 --- a/documentation/devboard/Firmware update on Developer Board.md +++ b/documentation/devboard/Firmware update on Developer Board.md @@ -1,10 +1,13 @@ # Firmware update on Developer Board {#dev_board_fw_update} -It's important to regularly update your Developer Board to ensure that you have access to the latest features and bug fixes. This tutorial will guide you through the necessary steps to update the firmware of your Developer Board. +> [!IMPORTANT] +> +> It's important to regularly update your Developer Board to ensure that you have access to the latest features and bug fixes. +> This tutorial will guide you through the necessary steps to update the firmware of your Developer Board. -This tutorial assumes that you're familiar with the basics of the command line. If you’re not, please refer to the [Windows](https://www.digitalcitizen.life/command-prompt-how-use-basic-commands/) or [MacOS/Linux](https://ubuntu.com/tutorials/command-line-for-beginners#1-overview) command line tutorials. +This tutorial assumes that you're familiar with the basics of the command line. -*** +If you’re not, please refer to the [Windows](https://www.digitalcitizen.life/command-prompt-how-use-basic-commands/) or [MacOS / Linux](https://ubuntu.com/tutorials/command-line-for-beginners#1-overview) command line tutorials. ## Installing the micro Flipper Build Tool @@ -14,20 +17,18 @@ Install uFBT on your computer by running the following command in the Terminal: **For Linux & macOS:** -```text +```bash python3 -m pip install --upgrade ufbt ``` **For Windows:** -```text -py -m pip install --upgrade ufbt +```powershell +python -m pip install --upgrade ufbt ``` If you want to learn more about uFBT, visit [the project's page](https://pypi.org/project/ufbt/). -*** - ## Connecting the Developer Board to your computer 1. List all of the serial devices on your computer. @@ -38,49 +39,38 @@ If you want to learn more about uFBT, visit [the project's page](https://pypi.or **macOS** - On macOS, you can run the following command in the Terminal: - - ```text + On macOS, you can run the following command in the Terminal: + ```bash ls /dev/cu.* ``` **Linux** - On Linux, you can run the following command in the Terminal: - + On Linux, you can run the following command in the Terminal: ```text ls /dev/tty* ``` - View the devices in the list. - 2. Connect the Developer Board to your computer using a USB-C cable. -![The Developer Board in Wired mode](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/Aq7gfMI-m_5H6sGGjwb4I_monosnap-miro-2023-07-19-19-47-39.jpg) - -3. Switch your Developer Board to Bootloader mode: - +![The Developer Board in Wired mode](https://github.com/user-attachments/assets/d13e4e90-d83d-45bf-8787-6eadba590795) +4. Switch your Developer Board to Bootloader mode: 3.1. Press and hold the **BOOT** button. - 3.2. Press the **RESET** button while holding the **BOOT** button. - - 3.3. Release the **BOOT** button.\ -![You can easily switch the Dev Board to Bootloader mode](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/KynP9iT6sJ3mXLaLyI82__image.png) - -4. Repeat Step 1 and view the name of your Developer Board that appeared in the list. + 3.3. Release the **BOOT** button. + ![You can easily switch the Dev Board to Bootloader mode](https://github.com/user-attachments/assets/aecc957f-f37b-4bec-af9f-9efd4837152e) +6. Repeat Step 1 and view the name of your Developer Board that appeared in the list. For example, on macOS: - ```text + ```shell /dev/cu.usbmodem01 ``` -*** - ## Flashing the firmware To flash the firmware onto your Developer Board, run the following command in the terminal: -```text +```shell python3 -m ufbt devboard_flash ``` @@ -90,33 +80,25 @@ You should see the following message: `WiFi board flashed successfully`. If you get an error message during the flashing process, such as this: -```text +```shell A fatal error occurred: Serial data stream stopped: Possible serial noise or corruption. ``` Or this: -```text +```shell FileNotFoundError: [Errno 2] No such file or directory: '/dev/cu.usbmodem01' ``` Try doing the following: - * Disconnect the Developer Board from your computer, then reconnect it. - * Use a different USB port on your computer. - * Use a different USB-C cable. -*** - ## Finishing the installation After flashing the firmware: - -1. Reboot the Developer Board by pressing the **RESET** button. -![Reset the Developer Board](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/rcQeKARgrVwa51tLoo-qY_monosnap-miro-2023-07-20-18-29-33.jpg) - -2. Disconnect and reconnect the USB-C cable. +1. Reboot the Developer Board by pressing the **RESET** button. ![Reset the Developer Board](https://github.com/user-attachments/assets/7527dd7b-eaa5-4fac-8d67-7ba52e552756) +3. Disconnect and reconnect the USB-C cable. The Developer Board should appear as a serial device on your computer. Now, you can use it with the Black Magic Debug client of your choice. diff --git a/documentation/devboard/Get started with the Dev Board.md b/documentation/devboard/Get started with the Dev Board.md index 04fa9d358..a679ccb11 100644 --- a/documentation/devboard/Get started with the Dev Board.md +++ b/documentation/devboard/Get started with the Dev Board.md @@ -2,35 +2,34 @@ The Wi-Fi Developer Board serves as a tool to debug the Flipper Zero firmware. To debug the firmware, the initial step involves compiling the firmware from its source code. This process enables the debugging functionality within the firmware and generates all the necessary files required for debugging purposes. -> **NOTE:** Building and debugging the Flipper Zero firmware is fully supported on MacOS and Linux. Support for Windows is in beta test. - -*** +> [!IMPORTANT] +> +> Building and debugging the Flipper Zero firmware is fully supported on MacOS and Linux. +> Support for Windows is in beta test. ## Updating the firmware of your Developer Board Update the firmware of your Developer Board before using it. For more information, visit [Firmware update on Developer Board](https://docs.flipperzero.one/development/hardware/wifi-debugger-module/update). -*** - ## Installing Git You'll need Git installed on your computer to clone the firmware repository. If you don't have Git, install it by doing the following: -* **MacOS** +### MacOS - On MacOS, install the **Xcode Command Line Tools** package, which includes Git as one of the pre-installed command-line utilities, by running in the Terminal the following command: +On MacOS, install the **Xcode Command Line Tools** package, which includes Git as one of the pre-installed command-line utilities, by running in the Terminal the following command: - ```text - xcode-select --install - ``` +```bash +xcode-select --install +``` -* **Linux** +### Linux - On Linux, you can install Git using your package manager. For example, on Ubuntu, run in the Terminal the following command: +On Linux, you can install Git using your package manager. For example, on Ubuntu, run in the Terminal the following command: - ```text - sudo apt install git - ``` +```bash +sudo apt install git +``` For other distributions, refer to your package manager documentation. @@ -40,14 +39,14 @@ For other distributions, refer to your package manager documentation. First, clone the firmware repository: -```text +```bash git clone --recursive https://github.com/flipperdevices/flipperzero-firmware.git cd flipperzero-firmware ``` Then, run the **Flipper Build Tool** (FBT) to build the firmware: -```text +```bash ./fbt ``` @@ -57,13 +56,15 @@ Then, run the **Flipper Build Tool** (FBT) to build the firmware: The Developer Board can work in the **Wired** mode and two **Wireless** modes: **Wi-Fi access point (AP)** mode and **Wi-Fi client (STA)** mode. The Wired mode is the simplest to set up, but requires a USB Type-C cable. The Wireless modes are more complex to set up, but they allow you to debug your Flipper Zero wirelessly. - > **NOTE:** Use the following credentials when connecting to the Developer Board in **Wi-Fi access point** mode:\n - Name: **blackmagic**\n - Password: **iamwitcher** +> [!TIP] +> +> Use the following credentials when connecting to the Developer Board in **Wi-Fi access point** mode: +> Name: **blackmagic** +> Password: **iamwitcher** ## Wired -![The Developer Board in Wired mode](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/jZdVlRTPVdSQVegzCyXp7_monosnap-miro-2023-06-22-16-28-06.jpg) +![The Developer Board in Wired mode](https://github.com/user-attachments/assets/32938d4a-20b7-4a53-8b36-608cf0112c9a) To connect the Developer Board in **Wired** mode, do the following: @@ -71,83 +72,81 @@ To connect the Developer Board in **Wired** mode, do the following: 2. On your computer, open the **Terminal** and run the following: - * **MacOS** - - ```text - ls /dev/cu.* - ``` - - * **Linux** - - ```text - ls /dev/tty* - ``` - - Note the list of devices. + ### MacOS + + ```shell + ls /dev/cu.* + ``` + + ### Linux + + ```bash + ls /dev/tty* + ``` + + Note the list of devices. 3. Connect the Developer Board to your computer via a USB-C cable. 4. Rerun the command. Two new devices have to appear: this is the Developer Board. - > **NOTE:** If the Developer Board doesn't appear in the list of devices, try using a different cable, USB port, or computer. - > - > **NOTE:** Flipper Zero logs can only be viewed when the Developer Board is connected via USB. The option to view logs over Wi-Fi will be added in future updates. For more information, visit [Reading logs via the Dev Board](https://docs.flipperzero.one/development/hardware/wifi-debugger-module/reading-logs). +> [!NOTE] +> +> If the Developer Board doesn't appear in the list of devices, try using a different cable, USB port, or computer. + +
+ +> [!IMPORTANT] +> +> Flipper Zero logs can only be viewed when the Developer Board is connected via USB. +> The option to view logs over Wi-Fi will be added in future updates. +> For more information, visit [Reading logs via the Dev Board](https://docs.flipperzero.one/development/hardware/wifi-debugger-module/reading-logs). ## Wireless ### Wi-Fi access point (AP) mode -![The Developer Board in Wi-Fi access point mode](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/tKRTMHAuruiLSEce2a8Ve_monosnap-miro-2023-06-22-16-39-17.jpg) +![The Developer Board in Wi-Fi access point mode](https://github.com/user-attachments/assets/1f210e91-3ac8-4f4c-a910-cc7c52b94346) Out of the box, the Developer Board is configured to work as a **Wi-Fi access point**. This means it'll create its own Wi-Fi network to which you can connect. If your Developer Board doesn't create a Wi-Fi network, it is probably configured to work in **Wi-Fi client** mode. To reset your Developer Board back to **Wi-Fi access point** mode, press and hold the **BOOT** button for 10 seconds, then wait for the module to reboot. -![You can reconfigure the Developer Board mode by pressing and holding the BOOT button](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/57eELJsAwMxeZCEA1NMJw_monosnap-miro-2023-06-22-20-33-27.jpg) +![You can reconfigure the Developer Board mode by pressing and holding the BOOT button](https://github.com/user-attachments/assets/8fee05de-fb1e-475a-b23a-d1ddca9cd701) To connect the Developer Board in **Wi-Fi access point** mode, do the following: 1. Cold-plug the Developer Board by turning off your Flipper Zero and connecting the Developer Board, and then turning it back on. - 2. Open Wi-Fi settings on your client device (phone, laptop, or other). - 3. Connect to the network: - - * Name: **blackmagic** - - * Password: **iamwitcher** - + * Name: `blackmagic` + * Password: `iamwitcher` 4. To configure the Developer Board, open a browser and go to `http://192.168.4.1`. ### Wi-Fi client (STA) mode -![The Developer Board in Wi-Fi client mode](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/xLQpFyYPfUS5Cx0uQhrNd_monosnap-miro-2023-06-23-12-34-36.jpg) +![The Developer Board in Wi-Fi client mode](https://github.com/user-attachments/assets/42e7e69e-51b0-4914-b082-431c68bc75d3) To connect the Developer Board in **Wi-Fi client** mode, you need to configure it to connect to your Wi-Fi network by doing the following: 1. Cold-plug the Developer Board by turning off your Flipper Zero and connecting the Developer Board, and then turning it back on. - 2. Connect to the Developer Board in **Wi-Fi access point** mode. - 3. In a browser, go to the configuration page on `http://192.168.4.1`. - 4. Select the **STA** mode and enter your network's **SSID** (name) and **password**. For convenience, you can click the **+** button to see the list of nearby networks. - 5. Save the configuration and reboot the Developer Board. +6. In the Wi-Fi tab, you can set the Developer Board mode -![In the Wi-Fi tab, you can set the Developer Board mode](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/klbLVj8lz2bEvm7j4wRaj_monosnap-miro-2023-06-23-13-06-32.jpg) +![Developer Board mode](https://github.com/user-attachments/assets/fbeea000-1117-4297-8a0d-5d580123e938) -After rebooting, the Developer Board connects to your Wi-Fi network. You can connect to the device using the mDNS name **blackmagic.local** or the IP address it got from your router (you'll have to figure this out yourself, every router is different). +After rebooting, the Developer Board connects to your Wi-Fi network. You can connect to the device using the mDNS name `blackmagic.local` or the IP address it got from your router (you'll have to figure this out yourself, every router is different). -After connecting to your debugger via , you can find its IP address in the **SYS** tab. You can also change the debugger's mode to **AP** or **STA** there. +After connecting to your debugger via [http://blackmagic.local](http://blackmagic.local), you can find its IP address in the **SYS** tab. You can also change the debugger's mode to **AP** or **STA** there. -![In the SYS tab, you can view the IP address of your Developer Board](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/5XbUptlfqzlV0p6hRUqiG_monosnap-miro-2023-06-22-18-11-30.jpg) - -*** +![In the SYS tab, you can view the IP address of your Developer Board](https://github.com/user-attachments/assets/aa3afc64-a2ec-46a6-a827-eea187a97c04) ## Debugging the firmware -Open the **Terminal** in the **flipperzero-firmware** directory that you cloned earlier and run the following command: +Open the **Terminal** in the `flipperzero-firmware` directory that you cloned earlier and run the following command: -```text +```bash ./fbt flash ``` @@ -155,24 +154,22 @@ This will upload the firmware you've just built to your Flipper Zero via the Dev To debug in **VSCode**, do the following: -1. In VSCode, open the **flipperzero-firmware** directory. - +1. In VSCode, open the `flipperzero-firmware` directory. 2. You should see a notification about recommended extensions. Install them. - - If there were no notifications, open the **Extensions** tab, enter `@recommended` in the search bar, and install the workspace recommendations. - +> [!TIP] +> +> If there were no notifications, open the `Extensions` tab, +> enter `@recommended` in the search bar, +> and install the workspace recommendations. +> 3. In the **Terminal**, run the `./fbt vscode_dist` command. This will generate the VSCode configuration files needed for debugging. - 4. In VSCode, open the **Run and Debug** tab and select **Attach FW (blackmagic)** from the dropdown menu. - 5. If needed, flash your Flipper Zero with the `./fbt flash` command, then click the **Play** button in the debug sidebar to start the debugging session. - 6. Note that starting a debug session halts the execution of the firmware, so you'll need to click the **Continue** button on the toolbar at the top of your VSCode window to continue execution. -![Click Continue in the toolbar to continue execution of the firmware](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/lp8ygGaZ3DvWD3OSI9yGO_monosnap-miro-2023-06-23-17-58-09.jpg) +![Click Continue in the toolbar to continue execution of the firmware](https://github.com/user-attachments/assets/74f26bdb-8511-4e5a-8aa8-c44212aa6228) To learn about debugging, visit the following pages: * [Debugging with GDB](https://sourceware.org/gdb/current/onlinedocs/gdb.pdf) - -* [Debugging in VS Code](https://code.visualstudio.com/docs/editor/debugging) +* [Debugging in VSCode](https://code.visualstudio.com/docs/editor/debugging) diff --git a/documentation/devboard/Reading logs via the Dev Board.md b/documentation/devboard/Reading logs via the Dev Board.md index e9fc0e2ca..41461b1cd 100644 --- a/documentation/devboard/Reading logs via the Dev Board.md +++ b/documentation/devboard/Reading logs via the Dev Board.md @@ -2,17 +2,16 @@ The Developer Board allows you to read Flipper Zero logs via UART. Unlike reading logs via the command-line interface (CLI), the Developer Board enables you to collect logs from the device directly to a serial console independently from the operating system of Flipper Zero. It allows you to see the device's logs when it's loading, updating, or crashing. It's useful for debugging and troubleshooting during software development. -> **NOTE:** Flipper Zero logs can only be viewed when the developer board is connected via USB. The option to view logs over Wi-Fi will be added in future updates. - -*** +> [!NOTE] +> +> Flipper Zero logs can only be viewed when the developer board is connected via USB. +> The option to view logs over Wi-Fi will be added in future updates. ## Setting the log level -Depending on your needs, you can set the log level by going to **Main Menu -> Settings -> Log Level**. To learn more about logging levels, visit [Settings](https://docs.flipperzero.one/basics/settings#d5TAt). +Depending on your needs, you can set the log level by going to `Main Menu -> Settings -> Log Level`. To learn more about logging levels, visit [Settings](https://docs.flipperzero.one/basics/settings#d5TAt). -![You can manually set the preferred log level](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/INzQMw8QUsG9PXi30WFS0_monosnap-miro-2023-07-11-13-29-47.jpg) - -*** +![You can manually set the preferred log level](https://github.com/user-attachments/assets/b1317d01-8b9b-4544-8720-303c87b85324) ## Viewing Flipper Zero logs @@ -20,118 +19,94 @@ Depending on your operating system, you need to install an additional applicatio ### MacOS -On MacOS, you need to install the **minicom** communication program by doing the following: +On MacOS, you need to install the `minicom` communication program by doing the following: 1. [Install Homebrew](https://brew.sh/) by running the following command in the Terminal: - - ```text - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - ``` - -2. After installation of Homebrew, run the following command to install minicom: - - ```text + ```bash + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + ``` +2. After installation of Homebrew, run the following command to install `minicom`: + ```bash brew install minicom ``` -After installation of minicom on your macOS computer, you can connect to the Developer Board to read Flipper Zero logs by doing the following: +After installation of `minicom` on your macOS computer, you can connect to the Developer Board to read Flipper Zero logs by doing the following: 1. Cold-plug the Developer Board into your Flipper Zero by turning off the Flipper Zero, connecting the developer board, and then turning it back on. - 2. On your computer, open the Terminal and run the following command: - - ```text + ```bash ls /dev/cu.* ``` - - Note the list of devices. - +> [!NOTE] +> +> The list of devices. 3. Connect the developer board to your computer using a USB Type-C cable. -![Connect the developer board with a USB-C cable](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/iPpsMt2-is4aIjiVeFu5t_hjxs2i1oovrnps74v5jgsimage.png) - -4. Rerun the command. Two new devices have to appear: this is the Developer Board. - - ```text + ![Connect the developer board with a USB-C cable](https://github.com/user-attachments/assets/0f469a31-2dd1-4559-918a-ff3ca3309531) +5. Rerun the command. Two new devices have to appear: this is the Developer Board. + ```bash /dev/cu.usbmodemblackmagic1 ``` - - ```text + ```bash /dev/cu.usbmodemblackmagic3 ``` - - Your Developer Board might have different names. - -5. Run the following command: - - ```text - minicom -D /dev/ -b 230400 - ``` - +> [!NOTE] +> +> Your Developer Board might have different names. +6. Run the following command: + ```bash + minicom -D /dev/ -b 230400 + ``` Where `` is the name of your device with a bigger number. - Example: - - ```text + ```bash minicom -D /dev/cu.usbmodemblackmagic3 -b 230400 ``` - -6. View logs of your Flipper Zero in the Terminal. - -7. To quit, close the minicom window or quit via the minicom menu. +7. View logs of your Flipper Zero in the Terminal. +8. To quit, close the `minicom` window or quit via the `minicom` menu. ### Linux -On Linux, you need to install the **minicom** communication program. For example, on Ubuntu, run in the Terminal the following command: +On Linux, you need to install the `minicom` communication program. For example, on Ubuntu, run in the Terminal the following command: -```text +```bash sudo apt install minicom - ``` +``` -After installation of minicom on your Linux computer, you can connect to the Developer Board to read Flipper Zero logs by doing the following: +After installation of `minicom` on your Linux computer, you can connect to the Developer Board to read Flipper Zero logs by doing the following: 1. Cold-plug the Developer Board into your Flipper Zero by turning off the Flipper Zero, connecting the developer board, and then turning it back on. - 2. On your computer, open the Terminal and run the following command: - - ```text + ```bash ls /dev/tty* ``` - Note the list of devices. - 3. Connect the developer board to your computer using a USB Type-C cable. -![Connect the developer board with a USB-C cable](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/iPpsMt2-is4aIjiVeFu5t_hjxs2i1oovrnps74v5jgsimage.png) - + ![Connect the developer board with a USB-C cable](https://github.com/user-attachments/assets/0f469a31-2dd1-4559-918a-ff3ca3309531) 4. Rerun the command. Two new devices have to appear: this is the Developer Board. - - ```text + ```bash /dev/ttyACM0 ``` - - ```text + ```bash /dev/ttyACM1 ``` - - Your Developer Board might have different names. - +> [!NOTE] +> +> Your Developer Board might have different names. 5. Run the following command: - - ```text + ```bash minicom -D /dev/ -b 230400 ``` - Where `` is the name of your device with a bigger number. - Example: - - ```text + ```bash minicom -D /dev/cu.usbmodemblackmagic3 -b 230400 ``` - 6. View logs of your Flipper Zero in the Terminal. - - **NOTE:** If no logs are shown in the Terminal, try running the command from Step 5 with another device name. - +> [!NOTE] +> +> If no logs are shown in the Terminal, +> try running the command from Step 5 with another device name. +> 7. To quit, close the minicom window or quit via the minicom menu. ### Windows @@ -139,22 +114,14 @@ After installation of minicom on your Linux computer, you can connect to the Dev On Windows, do the following: 1. On your computer, [install the PuTTY application](https://www.chiark.greenend.org.uk/\~sgtatham/putty/latest.html). - 2. Cold-plug the Developer Board into your Flipper Zero by turning off the Flipper Zero, connecting the developer board, and then turning it back on. - 3. Connect the developer board to your computer using a USB Type-C cable. -![Connect the developer board with a USB-C cable](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/iPpsMt2-is4aIjiVeFu5t_hjxs2i1oovrnps74v5jgsimage.png) - -4. Find the serial port that the developer board is connected to by going to **Device Manager -> Ports (COM & LPT)** and looking for a new port that appears when you connect the Wi-Fi developer board. -![Find the serial port in your Device Manager](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/KKLQJK1lvqmI5iab3d__C_image.png) - -5. Run the PuTTY application and select **Serial** as the connection type. - -6. Enter the port number you found in the previous step into the **Serial line** field. - -7. Set the **Speed** parameter to **230400** and click **Open**. -![Set speed to 230400](https://archbee-image-uploads.s3.amazonaws.com/3StCFqarJkJQZV-7N79yY/ROBSJyfQ_CXiy4GUZcPbs_monosnap-miro-2023-07-12-13-56-47.jpg) - -8. View logs of your Flipper Zero in the PuTTY terminal window. - -9. To quit, close the PuTTY window. + ![Connect the developer board with a USB-C cable](https://github.com/user-attachments/assets/0f469a31-2dd1-4559-918a-ff3ca3309531) +4. Find the serial port that the developer board is connected to by going to `Device Manager -> Ports (COM & LPT)` and looking for a new port that appears when you connect the Wi-Fi developer board. + ![Find the serial port in your Device Manager](https://github.com/user-attachments/assets/aa542fe6-4781-45dc-86f6-e98ab34952b0) +6. Run the `PuTTY` application and select `Serial` as the connection type. +7. Enter the port number you found in the previous step into the `Serial line` field. +8. Set the `Speed` parameter to `230400` and click `Open`. + ![Set speed to 230400](https://github.com/user-attachments/assets/93463c78-9776-479b-a6cc-d68ed712d0c4) +10. View logs of your Flipper Zero in the PuTTY terminal window. +11. To quit, close the PuTTY window. diff --git a/documentation/fbt.md b/documentation/fbt.md index 8e083349f..a8759f8eb 100644 --- a/documentation/fbt.md +++ b/documentation/fbt.md @@ -9,24 +9,35 @@ If you don't need all features of `fbt` - like building the whole firmware - and To use `fbt`, you only need `git` installed in your system. -`fbt` by default downloads and unpacks a pre-built toolchain, and then modifies environment variables for itself to use it. It does not contaminate your global system's path with the toolchain. - > However, if you wish to use tools supplied with the toolchain outside `fbt`, you can open an *fbt shell*, with properly configured environment. - > - On Windows, simply run `scripts/toolchain/fbtenv.cmd`. - > - On Linux & MacOS, run `source scripts/toolchain/fbtenv.sh` in a new shell. - > - You can also type ```. `./fbt -s env` ``` in your shell. (Keep the "." at the beginning.) +`fbt` by default downloads and unpacks a pre-built toolchain, and then modifies environment variables for itself to use it. +It does not contaminate your global system's path with the toolchain. + +> [!NOTE] +> +> However, if you wish to use tools supplied with the toolchain outside `fbt`, +> you can open an *fbt shell*, with properly configured environment. +> +> - On Windows, simply run `scripts/toolchain/fbtenv.cmd`. +> - On Linux & MacOS, run `source scripts/toolchain/fbtenv.sh` in a new shell. +> - You can also type ```. `./fbt -s env` ``` in your shell. (Keep the "." at the beginning.) - If your system is not supported by pre-built toolchain variants or you want to use custom versions of dependencies, you can `set FBT_NOENV=1`. `fbt` will skip toolchain & environment configuration and will expect all tools to be available on your system's `PATH`. *(this option is not available on Windows)* +If your system is not supported by pre-built toolchain variants or you want to use custom versions of dependencies, you can `set FBT_NOENV=1`. - If `FBT_TOOLCHAIN_PATH` variable is set, `fbt` will use that directory to unpack toolchain into. By default, it downloads toolchain into `toolchain` subdirectory repo's root. +`fbt` will skip toolchain & environment configuration and will expect all tools to be available on your system's `PATH`. *(this option is not available on Windows)* + +If `FBT_TOOLCHAIN_PATH` variable is set, `fbt` will use that directory to unpack toolchain into. By default, it downloads toolchain into `toolchain` subdirectory repo's root. If you want to enable extra debug output for `fbt` and toolchain management scripts, you can `set FBT_VERBOSE=1`. `fbt` always performs `git submodule update --init` on start, unless you set `FBT_NO_SYNC=1` in the environment: - - On Windows, it's `set "FBT_NO_SYNC=1"` in the shell you're running `fbt` from - - On \*nix, it's `$ FBT_NO_SYNC=1 ./fbt ...` - - > There are more variables controlling basic `fbt` behavior. See `fbt` & `fbtenv` scripts' sources for details. +- On Windows, it's `set "FBT_NO_SYNC=1"` in the shell you're running `fbt` from +- On \*nix, it's `$ FBT_NO_SYNC=1 ./fbt ...` +> [!NOTE] +> +> There are more variables controlling basic `fbt` behavior. +> See `fbt` & `fbtenv` scripts' sources for details. +> ## Invoking FBT @@ -38,22 +49,34 @@ To run cleanup (think of `make clean`) for specified targets, add the `-c` optio ## Build directories -`fbt` builds updater & firmware in separate subdirectories in `build`, and their names depend on optimization settings (`COMPACT` & `DEBUG` options). However, for ease of integration with IDEs, the latest built variant's directory is always linked as `built/latest`. Additionally, `compile_commands.json` is generated in that folder (it is used for code completion support in IDEs). +`fbt` builds updater & firmware in separate subdirectories in `build`, and their names depend on optimization settings (`COMPACT` & `DEBUG` options). + +However, for ease of integration with IDEs, the latest built variant's directory is always linked as `built/latest`. + +Additionally, `compile_commands.json` is generated in that folder (it is used for code completion support in IDEs). -`build/latest` symlink & compilation database are only updated upon *firmware build targets* - that is, when you're re-building the firmware itself. Running other tasks, like firmware flashing or building update bundles *for a different debug/release configuration or hardware target*, does not update `built/latest` dir to point to that configuration. +`build/latest` symlink & compilation database are only updated upon *firmware build targets* - that is, when you're re-building the firmware itself. + +Running other tasks, like firmware flashing or building update bundles *for a different debug/release configuration or hardware target*, does not update `built/latest` dir to point to that configuration. ## VSCode integration -`fbt` includes basic development environment configuration for VS Code. Run `./fbt vscode_dist` to deploy it. That will copy the initial environment configuration to the `.vscode` folder. After that, you can use that configuration by starting VS Code and choosing the firmware root folder in the "File > Open Folder" menu. +`fbt` includes basic development environment configuration for VSCode. Run `./fbt vscode_dist` to deploy it. -To use language servers other than the default VS Code C/C++ language server, use `./fbt vscode_dist LANG_SERVER=` instead. Currently `fbt` supports the default language server (`cpptools`) and `clangd`. +That will copy the initial environment configuration to the `.vscode` folder. + +After that, you can use that configuration by starting VSCode and choosing the firmware root folder in the File > Open Folder menu. + +To use language servers other than the default VS Code C/C++ language server, use `./fbt vscode_dist LANG_SERVER=` instead. + +Currently `fbt` supports the default language server (`cpptools`) and `clangd`. - On the first start, you'll be prompted to install recommended plugins. We highly recommend installing them for the best development experience. _You can find a list of them in `.vscode/extensions.json`._ -- Basic build tasks are invoked in the Ctrl+Shift+B menu. +- Basic build tasks are invoked in the Ctrl + Shift + B menu. - Debugging requires a supported probe. That includes: - Wi-Fi devboard with stock firmware (blackmagic). - ST-Link and compatible devices. - - J-Link for flashing and debugging (in VSCode only). _Note that J-Link tools are not included with our toolchain and you have to [download](https://www.segger.com/downloads/jlink/) them yourself and put them on your system's PATH._ + - J-Link for flashing and debugging (in VSCode only). _Note that J-Link tools are not included with our toolchain and you have to [download](https://www.segger.com/downloads/jlink/) them yourself and put them on your system's `PATH`. - Without a supported probe, you can install firmware on Flipper using the USB installation method. ## FBT targets @@ -68,7 +91,7 @@ To use language servers other than the default VS Code C/C++ language server, us - `copro_dist` - bundle Core2 FUS+stack binaries for qFlipper. - `flash` - flash the attached device over SWD interface with supported probes. Probe is detected automatically; you can override it with `SWD_TRANSPORT=...` variable. If multiple probes are attached, you can specify the serial number of the probe to use with `SWD_TRANSPORT_SERIAL=...`. - `flash_usb`, `flash_usb_full` - build, upload and install the update package to the device over USB. See details on `updater_package` and `updater_minpackage`. -- `debug` - build and flash firmware, then attach with gdb with firmware's .elf loaded. +- `debug` - build and flash firmware, then attach with gdb with firmware's `.elf` loaded. - `debug_other`, `debug_other_blackmagic` - attach GDB without loading any `.elf`. It will allow you to manually add external `.elf` files with `add-symbol-file` in GDB. - `updater_debug` - attach GDB with the updater's `.elf` loaded. - `devboard_flash` - Update WiFi dev board. Supports `ARGS="..."` to pass extra arguments to the update script, e.g. `ARGS="-c dev"`. @@ -76,7 +99,7 @@ To use language servers other than the default VS Code C/C++ language server, us - `openocd` - just start OpenOCD. You can pass extra arguments with `ARGS="..."`. - `get_blackmagic` - output the blackmagic address in the GDB remote format. Useful for IDE integration. - `get_stlink` - output serial numbers for attached STLink probes. Used for specifying an adapter with `SWD_TRANSPORT_SERIAL=...`. -- `lint`, `format` - run clang-format on the C source code to check and reformat it according to the `.clang-format` specs. Supports `ARGS="..."` to pass extra arguments to clang-format. +- `lint`, `format` - run `clang-format` on the C source code to check and reformat it according to the `.clang-format` specs. Supports `ARGS="..."` to pass extra arguments to clang-format. - `lint_py`, `format_py` - run [black](https://black.readthedocs.io/en/stable/index.html) on the Python source code, build system files & application manifests. Supports `ARGS="..."` to pass extra arguments to black. - `firmware_pvs` - generate a PVS Studio report for the firmware. Requires PVS Studio to be available on your system's `PATH`. - `doxygen` - generate Doxygen documentation for the firmware. `doxy` target also opens web browser to view the generated documentation. @@ -115,6 +138,7 @@ To use language servers other than the default VS Code C/C++ language server, us ## Configuration Default configuration variables are set in the configuration file: `fbt_options.py`. + Values set in the command line have higher precedence over the configuration file. You can also create a file called `fbt_options_local.py` that will be evaluated when loading default options file, enabling persisent overriding of default options without modifying default configuration. @@ -123,7 +147,12 @@ You can find out available options with `./fbt -h`. ### Firmware application set -You can create customized firmware builds by modifying the list of applications to be included in the build. Application presets are configured with the `FIRMWARE_APPS` option, which is a `map(configuration_name:str -> application_list:tuple(str))`. To specify an application set to use in the build, set `FIRMWARE_APP_SET` to its name. +You can create customized firmware builds by modifying the list of applications to be included in the build. + +Application presets are configured with the `FIRMWARE_APPS` option, which is a `map(configuration_name:str -> application_list:tuple(str))`. + +To specify an application set to use in the build, set `FIRMWARE_APP_SET` to its name. + For example, to build a firmware image with unit tests, run `./fbt FIRMWARE_APP_SET=unit_tests`. Check out `fbt_options.py` for details. diff --git a/documentation/file_formats/BadUsbScriptFormat.md b/documentation/file_formats/BadUsbScriptFormat.md index 1bac3c4aa..0b8381c1e 100644 --- a/documentation/file_formats/BadUsbScriptFormat.md +++ b/documentation/file_formats/BadUsbScriptFormat.md @@ -2,7 +2,10 @@ ## Command syntax -BadUsb app uses extended Duckyscript syntax. It is compatible with classic USB Rubber Ducky 1.0 scripts but provides some additional commands and features, such as custom USB ID, ALT+Numpad input method, SYSRQ command, and more functional keys. +BadUsb app uses extended DuckyScript syntax. + +It is compatible with classic USB Rubber Ducky 1.0 scripts but provides some additional commands and features, +such as custom USB ID, `ALT` + `Numpad` input method, `SYSRQ` command, and more functional keys. ## Script file format @@ -12,168 +15,181 @@ BadUsb app can execute only text scripts from `.txt` files, no compilation is re ### Comment line -Just a single comment line. The interpreter will ignore all text after the REM command. -| Command | Parameters | Notes | -| ------- | ------------ | ----- | -| REM | Comment text | | +Just a single comment line. The interpreter will ignore all text after the `REM` command. + +| Command | Parameters | Notes | +|:---------|:--------------|:--------| +| REM | Comment text | | ### Delay Pause script execution by a defined time. -| Command | Parameters | Notes | -| ------------- | ----------------- | ----------------------------------- | -| DELAY | Delay value in ms | Single delay | -| DEFAULT_DELAY | Delay value in ms | Add delay before every next command | -| DEFAULTDELAY | Delay value in ms | Same as DEFAULT_DELAY | + +| Command | Parameters | Notes | +|:--------------|:--------------------------|:--------------------------------------| +| DELAY | Delay value in ms | Single delay | +| DEFAULT_DELAY | Delay value in ms | Add delay before every next command | +| DEFAULTDELAY | Delay value in ms | Same as DEFAULT_DELAY | ### Special keys -| Command | Notes | -| ------------------ | ---------------- | -| DOWNARROW / DOWN | | -| LEFTARROW / LEFT | | -| RIGHTARROW / RIGHT | | -| UPARROW / UP | | -| ENTER | | -| DELETE | | -| BACKSPACE | | -| END | | -| HOME | | -| ESCAPE / ESC | | -| INSERT | | -| PAGEUP | | -| PAGEDOWN | | -| CAPSLOCK | | -| NUMLOCK | | -| SCROLLLOCK | | -| PRINTSCREEN | | -| BREAK | Pause/Break key | -| PAUSE | Pause/Break key | -| SPACE | | -| TAB | | -| MENU | Context menu key | -| APP | Same as MENU | -| Fx | F1-F12 keys | +| Command | Notes | +|:--------------------|:------------------| +| DOWNARROW / DOWN | | +| LEFTARROW / LEFT | | +| RIGHTARROW / RIGHT | | +| UPARROW / UP | | +| ENTER | | +| DELETE | | +| BACKSPACE | | +| END | | +| HOME | | +| ESCAPE / ESC | | +| INSERT | | +| PAGEUP | | +| PAGEDOWN | | +| CAPSLOCK | | +| NUMLOCK | | +| SCROLLLOCK | | +| PRINTSCREEN | | +| BREAK | Pause/Break key | +| PAUSE | Pause/Break key | +| SPACE | | +| TAB | | +| MENU | Context menu key | +| APP | Same as MENU | +| Fx | F1-F12 keys | ### Modifier keys Can be combined with a special key command or a single character. -| Command | Notes | -| -------------- | ---------- | -| CONTROL / CTRL | | -| SHIFT | | -| ALT | | -| WINDOWS / GUI | | -| CTRL-ALT | CTRL+ALT | -| CTRL-SHIFT | CTRL+SHIFT | -| ALT-SHIFT | ALT+SHIFT | -| ALT-GUI | ALT+WIN | -| GUI-SHIFT | WIN+SHIFT | -| GUI-CTRL | WIN+CTRL | + +| Command | Notes | +|:----------------|:-------------| +| CONTROL / CTRL | | +| SHIFT | | +| ALT | | +| WINDOWS / GUI | | +| CTRL-ALT | CTRL+ALT | +| CTRL-SHIFT | CTRL+SHIFT | +| ALT-SHIFT | ALT+SHIFT | +| ALT-GUI | ALT+WIN | +| GUI-SHIFT | WIN+SHIFT | +| GUI-CTRL | WIN+CTRL | ## Key hold and release Up to 5 keys can be hold simultaneously. -| Command | Parameters | Notes | -| ------- | ------------------------------- | ---------------------------------------- | -| HOLD | Special key or single character | Press and hold key until RELEASE command | -| RELEASE | Special key or single character | Release key | + +| Command | Parameters | Notes | +|:---------|:---------------------------------|:------------------------------------------| +| HOLD | Special key or single character | Press and hold key until RELEASE command | +| RELEASE | Special key or single character | Release key | ## String -| Command | Parameters | Notes | -| ------- | ----------- | ----------------- | -| STRING | Text string | Print text string | -| STRINGLN | Text string | Print text string and press enter after it | +| Command | Parameters | Notes | +|:----------|:-------------|:--------------------------------------------| +| STRING | Text string | Print text string | +| STRINGLN | Text string | Print text string and press enter after it | ## String delay -Delay between keypresses. -| Command | Parameters | Notes | -| -------------------- | ----------------- | --------------------------------------------- | -| STRING_DELAY | Delay value in ms | Applied once to next appearing STRING command | -| STRINGDELAY | Delay value in ms | Same as STRING_DELAY | -| DEFAULT_STRING_DELAY | Delay value in ms | Apply to every appearing STRING command | -| DEFAULTSTRINGDELAY | Delay value in ms | Same as DEFAULT_STRING_DELAY | +Delay between key presses. + +| Command | Parameters | Notes | +|:----------------------|:-------------------|:-----------------------------------------------| +| STRING_DELAY | Delay value in ms | Applied once to next appearing STRING command | +| STRINGDELAY | Delay value in ms | Same as STRING_DELAY | +| DEFAULT_STRING_DELAY | Delay value in ms | Apply to every appearing STRING command | +| DEFAULTSTRINGDELAY | Delay value in ms | Same as DEFAULT_STRING_DELAY | ### Repeat -| Command | Parameters | Notes | -| ------- | ---------------------------- | ----------------------- | -| REPEAT | Number of additional repeats | Repeat previous command | +| Command | Parameters | Notes | +|:---------|:------------------------------|:-------------------------| +| REPEAT | Number of additional repeats | Repeat previous command | ### ALT+Numpad input On Windows and some Linux systems, you can print characters by holding `ALT` key and entering its code on Numpad. | Command | Parameters | Notes | -| --------- | -------------- | --------------------------------------------------------------- | +| :---------- | :--------------- | :--------------------------------------------------------------- | | ALTCHAR | Character code | Print single character | | ALTSTRING | Text string | Print text string using ALT+Numpad method | -| ALTCODE | Text string | Same as ALTSTRING, presents in some Duckyscript implementations | +| ALTCODE | Text string | Same as ALTSTRING, presents in some DuckyScript implementations | ### SysRq Send [SysRq command](https://en.wikipedia.org/wiki/Magic_SysRq_key) -| Command | Parameters | Notes | -| ------- | ---------------- | ----- | -| SYSRQ | Single character | | + +| Command | Parameters | Notes | +|:---------|:------------------|:-------| +| SYSRQ | Single character | | ## Media keys -Some Media/Consumer Control keys can be pressed with "MEDIA" command +Some Media/Consumer Control keys can be pressed with `MEDIA` command -| Command | Parameters | Notes | -| ------- | ------------------------- | ----- | -| MEDIA | Media key, see list below | | +| Command | Parameters | Notes | +|:---------|:---------------------------|:------| +| MEDIA | Media key, see list below | | -| Key name | Notes | -| ----------------- | ----------------------------- | -| POWER | | -| REBOOT | | -| SLEEP | | -| LOGOFF | | -| EXIT | | -| HOME | | -| BACK | | -| FORWARD | | -| REFRESH | | -| SNAPSHOT | Take photo in a camera app | -| PLAY | | -| PAUSE | | -| PLAY_PAUSE | | -| NEXT_TRACK | | -| PREV_TRACK | | -| STOP | | -| EJECT | | -| MUTE | | -| VOLUME_UP | | -| VOLUME_DOWN | | -| FN | Fn/Globe key on Mac keyboard | -| BRIGHT_UP | Increase display brightness | -| BRIGHT_DOWN | Decrease display brightness | + +| Key name | Notes | +|:-------------------|:-------------------------------| +| POWER | | +| REBOOT | | +| SLEEP | | +| LOGOFF | | +| EXIT | | +| HOME | | +| BACK | | +| FORWARD | | +| REFRESH | | +| SNAPSHOT | Take photo in a camera app | +| PLAY | | +| PAUSE | | +| PLAY_PAUSE | | +| NEXT_TRACK | | +| PREV_TRACK | | +| STOP | | +| EJECT | | +| MUTE | | +| VOLUME_UP | | +| VOLUME_DOWN | | +| FN | Fn/Globe key on Mac keyboard | +| BRIGHT_UP | Increase display brightness | +| BRIGHT_DOWN | Decrease display brightness | ## Fn/Globe key commands (Mac/iPad) -| Command | Parameters | Notes | -| ------- | ------------------------------- | ----- | -| GLOBE | Special key or single character | | +| Command | Parameters | Notes | +|:---------|:---------------------------------|:-------| +| GLOBE | Special key or single character | | ## Wait for button press Will wait indefinitely for a button to be pressed -| Command | Parameters | Notes | -| --------------------- | ------------ | --------------------------------------------------------------------- | -| WAIT_FOR_BUTTON_PRESS | None | Will wait for the user to press a button to continue script execution | + +| Command | Parameters | Notes | +|:----------------------|:-----------|:------------------------------------------------------------------------------| +| WAIT_FOR_BUTTON_PRESS | None | Will wait for the user to press a button to continue script execution | ## USB device ID You can set the custom ID of the Flipper USB HID device. ID command should be in the **first line** of script, it is executed before script run. -| Command | Parameters | Notes | -| ------- | ---------------------------- | ----- | -| ID | VID:PID Manufacturer:Product | | +| Command | Parameters | Notes | +|:---------|:------------------------------|:-------| +| ID | VID:PID Manufacturer:Product | | Example: -`ID 1234:abcd Flipper Devices:Flipper Zero` +```text +ID 1234:abcd Flipper Devices:Flipper Zero +``` -VID and PID are hex codes and are mandatory. Manufacturer and Product are text strings and are optional. +> [!IMPORTANT] +> +> VID and PID are hex codes and are mandatory. +> Manufacturer and Product are text strings and are optional. diff --git a/scripts/debug/FreeRTOS/FreeRTOSgdb/QueueTools.py b/scripts/debug/FreeRTOS/FreeRTOSgdb/QueueTools.py index a35f0894f..4984d2a06 100644 --- a/scripts/debug/FreeRTOS/FreeRTOSgdb/QueueTools.py +++ b/scripts/debug/FreeRTOS/FreeRTOSgdb/QueueTools.py @@ -102,7 +102,7 @@ class QueueInspector: except Exception as exc: # If the TRACE functionality of the RTOS is not enabled, - # then the queue type will not be availabe in the queue + # then the queue type will not be available in the queue # handle - so we return None print("Failed to get Type: %s" % str(exc)) return None