1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 12:42:30 +04:00

Merge branch 'fz-dev' into dev

This commit is contained in:
MX
2022-09-19 17:21:31 +03:00
11 changed files with 67 additions and 19 deletions

View File

@@ -231,7 +231,30 @@ void nfc_show_loading_popup(void* context, bool show) {
}
}
static bool nfc_is_hal_ready() {
if(!furi_hal_nfc_is_init()) {
// No connection to the chip, show an error screen
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage* message = dialog_message_alloc();
dialog_message_set_text(
message,
"Error!\nNFC chip failed to start\n\n\nSend a photo of this to:\nsupport@flipperzero.one",
0,
0,
AlignLeft,
AlignTop);
dialog_message_show(dialogs, message);
dialog_message_free(message);
furi_record_close(RECORD_DIALOGS);
return false;
} else {
return true;
}
}
int32_t nfc_app(void* p) {
if(!nfc_is_hal_ready()) return 0;
Nfc* nfc = nfc_alloc();
char* args = p;

View File

@@ -33,6 +33,8 @@
#include <nfc/scenes/nfc_scene.h>
#include <nfc/helpers/nfc_custom_event.h>
#include <dialogs/dialogs.h>
#include "rpc/rpc_app.h"
#define NFC_TEXT_STORE_SIZE 128

View File

@@ -1,7 +1,7 @@
App(
appid="picopass",
name="PicoPass Reader",
apptype=FlipperAppType.PLUGIN,
apptype=FlipperAppType.EXTERNAL,
entry_point="picopass_app",
requires=[
"storage",

View File

@@ -1,16 +1,16 @@
# Flipper Application Manifests (.fam)
All components of Flipper Zero firmware — services, user applications, system settings — are developed independently. Each component has a build system manifest file, named `application.fam`, defining basic properties of a components and its relations to other parts of the system.
All components of Flipper Zero firmware — services, user applications, system settings — are developed independently. Each component has a build system manifest file, named `application.fam`, which defines basic properties of that component and its relations to other parts of the system.
When building firmware, **`fbt`** collects all application manifests, processes their dependencies and builds only those components that are utilized in current build configuration. See [fbt docs](./fbt.md#firmware-application-set) for details on build configurations.
When building firmware, **`fbt`** collects all application manifests and processes their dependencies. Then it builds only those components that are referenced in the current build configuration. See [fbt docs](./fbt.md#firmware-application-set) for details on build configurations.
## Application definition
Properties of a firmware component are declared in a form of a Python code snippet, forming a call to App() function with various parameters.
Only 2 parameters are mandatoty: ***appid*** and ***apptype***, others are optional and may be meaningful only for certain application types.
Only 2 parameters are mandatory: ***appid*** and ***apptype***, others are optional and may only be meaningful for certain application types.
### Keys
### Parameters
* **appid**: string, application id within the build system. Used for specifying which applications to include in build configuration and to resolve dependencies and conflicts.
@@ -21,7 +21,7 @@ Only 2 parameters are mandatoty: ***appid*** and ***apptype***, others are optio
| SERVICE | System service, created at early startup |
| SYSTEM | Application not being shown in any menus. Can be started by other apps or from CLI |
| APP | Regular application for main menu |
| PLUGIN | Application to be built as .fap plugin |
| PLUGIN | Application to be built as a part of firmware an to be placed in 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 System settings menu |
@@ -29,25 +29,28 @@ Only 2 parameters are mandatoty: ***appid*** and ***apptype***, others are optio
| 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 to show in menus.
* **entry_point**: C function to be used as applicaiton's entry point.
* **name**: Name that is displayed in menus.
* **entry_point**: C function to be used as application's entry point.
* **flags**: Internal flags for system apps. Do not use.
* **cdefines**: C preprocessor definitions to declare globally for other apps when current application is included in active build configuration.
* **requires**: List of application IDs to also include in build configuration, when current application is referenced in list of applications to build.
* **conflicts**: List of application IDs that current application conflicts with. If any of them is found in constructed application list, **`fbt`** will abort firmware build process.
* **provides**: Functionally identical to ***requires*** field.
* **stack_size**: Stack size, in bytes, to allocate for application on its startup. Note that allocating a stack too small for app to run will cause system crash due to stack overflow, and allocating too much stack will reduce usable heap memory size for app to process data. *Note: you can use `ps` and `free` CLI commands to profile you app's memory usage.*
* **stack_size**: Stack size, in bytes, to allocate for application on its startup. Note that allocating a stack that is too small for an app to run will cause system crash due to stack overflow, and allocating too much stack space will reduce usable heap memory size for apps to process data. *Note: you can use `ps` and `free` CLI commands to profile your app's memory usage.*
* **icon**: Animated icon name from built-in assets to be used when building app as a part of firmware.
* **order**: Order of an application within its group when sorting entries in it. The lower the order is, the closer to the start of the list the items is located. Used for ordering startup hooks and menu entries.
* **sdk_headers**: List of C header files from this app's code to include in API definitions for external applicaions.
* **order**: Order of an application within its group when sorting entries in it. The lower the order is, the closer to the start of the list the item is placed. *Used for ordering startup hooks and menu entries.*
* **sdk_headers**: List of C header files from this app's code to include in API definitions for external applications.
The following parameters are used only for [FAPs](./AppsOnSDCard.md):
* **sources**: list of file name masks, used for gathering sources within app folder. Default value of ["\*.c\*"] includes C and CPP source files.
* **version**: string, 2 numbers in form of "x.y": application version to be embedded within .fap file.
* **fap_icon**: name of .png file, 1-bit color depth, 10x10px, to be embedded within .fap file.
* **fap_version**: string, 2 numbers in form of "x.y": application version to be embedded within .fap file.
* **fap_icon**: name of a .png file, 1-bit color depth, 10x10px, to be embedded within .fap file.
* **fap_libs**: list of extra libraries to link application against. Provides access to extra functions that are not exported as a part of main firmware at expense of increased .fap file size and RAM consumption.
* **fap_category**: string, may be empty. App subcategory, also works as path of FAP within apps folder in the file system.
* **fap_description**: string, may be empty. Short application descriotion.
* **fap_author**: string, may be empty. Application's author.
* **fap_weburl**: string, may be empty. Application's homepage.
## .fam file contents
@@ -76,4 +79,4 @@ App(
)
```
For more examples, see application.fam files for basic firmware components.
For more examples, see .fam files from various firmware parts.

View File

@@ -73,7 +73,8 @@ FIRMWARE_APPS = {
"system_apps",
# Settings
"settings_apps",
# Plugins
# Stock plugins - no longer built into fw, now they're .faps
# Yet you can still build them as a part of fw
# "basic_plugins",
# Debug
# "debug_apps",

View File

@@ -1116,6 +1116,7 @@ Function,+,furi_hal_nfc_field_off,void,
Function,+,furi_hal_nfc_field_on,void,
Function,-,furi_hal_nfc_init,void,
Function,+,furi_hal_nfc_is_busy,_Bool,
Function,+,furi_hal_nfc_is_init,_Bool,
Function,+,furi_hal_nfc_listen,_Bool,"uint8_t*, uint8_t, uint8_t*, uint8_t, _Bool, uint32_t"
Function,+,furi_hal_nfc_listen_rx,_Bool,"FuriHalNfcTxRxContext*, uint32_t"
Function,+,furi_hal_nfc_listen_sleep,void,
1 entry status name type params
1116 Function + furi_hal_nfc_field_on void
1117 Function - furi_hal_nfc_init void
1118 Function + furi_hal_nfc_is_busy _Bool
1119 Function + furi_hal_nfc_is_init _Bool
1120 Function + furi_hal_nfc_listen _Bool uint8_t*, uint8_t, uint8_t*, uint8_t, _Bool, uint32_t
1121 Function + furi_hal_nfc_listen_rx _Bool FuriHalNfcTxRxContext*, uint32_t
1122 Function + furi_hal_nfc_listen_sleep void

View File

@@ -39,6 +39,10 @@ bool furi_hal_nfc_is_busy() {
return rfalNfcGetState() != RFAL_NFC_STATE_IDLE;
}
bool furi_hal_nfc_is_init() {
return rfalNfcGetState() != RFAL_NFC_STATE_NOTINIT;
}
void furi_hal_nfc_field_on() {
furi_hal_nfc_exit_sleep();
st25r3916TxRxOn();

View File

@@ -107,6 +107,12 @@ void furi_hal_nfc_init();
*/
bool furi_hal_nfc_is_busy();
/** Check if nfc is initialized
*
* @return true if initialized
*/
bool furi_hal_nfc_is_init();
/** NFC field on
*/
void furi_hal_nfc_field_on();

View File

@@ -63,7 +63,10 @@ def build_app_as_external(env, appdef):
extapps["dist"][appdef.appid] = (appdef.fap_category, compact_elf)
apps_to_build_as_faps = [FlipperAppType.PLUGIN, FlipperAppType.EXTERNAL]
apps_to_build_as_faps = [
FlipperAppType.PLUGIN,
FlipperAppType.EXTERNAL,
]
if appenv["DEBUG_TOOLS"]:
apps_to_build_as_faps.append(FlipperAppType.DEBUG)

View File

@@ -36,11 +36,16 @@ class FlipperApplication:
icon: Optional[str] = None
order: int = 0
sdk_headers: List[str] = field(default_factory=list)
version: Tuple[int] = field(default_factory=lambda: (0, 0))
# .fap-specific
sources: List[str] = field(default_factory=lambda: ["*.c*"])
fap_version: Tuple[int] = field(default_factory=lambda: (0, 0))
fap_icon: Optional[str] = None
fap_libs: List[str] = field(default_factory=list)
fap_category: str = ""
fap_description: str = ""
fap_author: str = ""
fap_weburl: str = ""
# Internally used by fbt
_appdir: Optional[object] = None
_apppath: Optional[str] = None

View File

@@ -66,8 +66,8 @@ def assemble_manifest_data(
)
image_data = image.data
app_version_as_int = ((app_manifest.version[0] & 0xFFFF) << 16) | (
app_manifest.version[1] & 0xFFFF
app_version_as_int = ((app_manifest.fap_version[0] & 0xFFFF) << 16) | (
app_manifest.fap_version[1] & 0xFFFF
)
data = ElfManifestBaseHeader(