diff --git a/applications/main/nfc/nfc.c b/applications/main/nfc/nfc.c index 432630204..f47a5bac2 100644 --- a/applications/main/nfc/nfc.c +++ b/applications/main/nfc/nfc.c @@ -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; diff --git a/applications/main/nfc/nfc_i.h b/applications/main/nfc/nfc_i.h index b5d284d5b..60e1c1997 100644 --- a/applications/main/nfc/nfc_i.h +++ b/applications/main/nfc/nfc_i.h @@ -33,6 +33,8 @@ #include #include +#include + #include "rpc/rpc_app.h" #define NFC_TEXT_STORE_SIZE 128 diff --git a/applications/plugins/picopass/application.fam b/applications/plugins/picopass/application.fam index 887d0324c..7a81e0804 100644 --- a/applications/plugins/picopass/application.fam +++ b/applications/plugins/picopass/application.fam @@ -1,7 +1,7 @@ App( appid="picopass", name="PicoPass Reader", - apptype=FlipperAppType.PLUGIN, + apptype=FlipperAppType.EXTERNAL, entry_point="picopass_app", requires=[ "storage", diff --git a/documentation/AppManifests.md b/documentation/AppManifests.md index 5e7ceb939..7bc8d0a47 100644 --- a/documentation/AppManifests.md +++ b/documentation/AppManifests.md @@ -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. \ No newline at end of file +For more examples, see .fam files from various firmware parts. diff --git a/fbt_options.py b/fbt_options.py index f7a2cc3b1..eb9c8cff7 100644 --- a/fbt_options.py +++ b/fbt_options.py @@ -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", diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 2592e2b56..f016188ea 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -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, diff --git a/firmware/targets/f7/furi_hal/furi_hal_nfc.c b/firmware/targets/f7/furi_hal/furi_hal_nfc.c index 1a5afa1ec..de67bbc35 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_nfc.c +++ b/firmware/targets/f7/furi_hal/furi_hal_nfc.c @@ -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(); diff --git a/firmware/targets/furi_hal_include/furi_hal_nfc.h b/firmware/targets/furi_hal_include/furi_hal_nfc.h index aa1c61d9c..537e0abf0 100644 --- a/firmware/targets/furi_hal_include/furi_hal_nfc.h +++ b/firmware/targets/furi_hal_include/furi_hal_nfc.h @@ -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(); diff --git a/site_scons/extapps.scons b/site_scons/extapps.scons index cfffda04f..4cb5e35cf 100644 --- a/site_scons/extapps.scons +++ b/site_scons/extapps.scons @@ -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) diff --git a/site_scons/fbt/appmanifest.py b/site_scons/fbt/appmanifest.py index a41717d6a..a0ab5e7c6 100644 --- a/site_scons/fbt/appmanifest.py +++ b/site_scons/fbt/appmanifest.py @@ -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 diff --git a/site_scons/fbt/elfmanifest.py b/site_scons/fbt/elfmanifest.py index 2f54810d9..313a64c09 100644 --- a/site_scons/fbt/elfmanifest.py +++ b/site_scons/fbt/elfmanifest.py @@ -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(