app-module events & callstack config, crash diagnostics (#630)

- Apps can specify task stack depth and preferred memory placement in their manifests.
- App identifiers are validated against length and character requirements.
- Crash diagnostics now show the crash cause, reason, fault address, call stack, and program-counter details, with logs saved for review.
- App closing is more consistent across built-in screens. There's now a dedicated function, and the old _emit() function is made private.
- Crash diagnostics no longer display a QR code without a call stack.
- Improved memory allocation for unrestricted requests.
This commit is contained in:
Ken Van Hoeylandt
2026-08-27 21:50:12 +02:00
committed by GitHub
parent c656ee9ffd
commit 92ca046681
74 changed files with 654 additions and 381 deletions
+7 -10
View File
@@ -114,16 +114,6 @@ error_t app_event_subscribe_with_app_id(struct AppEventSubscription* sub, struct
*/
error_t app_event_unsubscribe(struct AppEventSubscription* sub);
/**
* Deliver @a event to every subscription registered for @a app_instance_id (normally exactly one).
* @warning Does not work in ISR context.
* @retval ERROR_NONE delivered to at least one subscription
* @retval ERROR_NOT_FOUND no subscription is registered for @a app_instance_id
* @retval ERROR_RESOURCE at least one matching subscription's queue was full; the event was
* dropped for that subscription (still delivered to any other matching subscription)
*/
error_t app_event_emit(AppInstanceId app_instance_id, const struct AppEvent* event);
/**
* Non-blocking: pop the next event for @a sub if one is already queued.
* @warning Never blocks. To wait for an event, block in task_event_group_wait()/
@@ -134,6 +124,13 @@ error_t app_event_emit(AppInstanceId app_instance_id, const struct AppEvent* eve
*/
error_t app_event_poll(struct AppEventSubscription* sub, struct AppEvent* out_event);
/**
* Emits a close event to the specified app.
* @param[in] instance_id
* @return ERROR_NONE when event was successfully emitted
*/
error_t app_event_emit_close(AppInstanceId instance_id);
#ifdef __cplusplus
}
#endif
+23
View File
@@ -3,12 +3,16 @@
#include "location.h"
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// Character count, excluding null terminator
#define APP_ID_LENGTH 32
/** Broad classification of an app, used for grouping/launcher presentation. */
enum AppCategory {
APP_CATEGORY_SYSTEM,
@@ -24,6 +28,21 @@ enum AppManifestFlags {
APP_MANIFEST_FLAG_HIDDEN = 1 >> 0,
};
/** Largest stack depth (in words) an app may request. Keeps `depth * sizeof(StackType_t)` safely
* bounded and stops one app from claiming an unreasonable share of available RAM. A depth beyond
* this must be rejected outright, not silently truncated or clamped. */
#define APP_STACK_SIZE_MAX 16384
struct AppStackConfig {
/** Stack depth (in words, matching FreeRTOS's configSTACK_DEPTH_TYPE) for this app's task.
* 0 uses the scheduler's default. Must not exceed APP_STACK_SIZE_MAX. */
uint16_t depth;
/** Desired memory capability.
* 0 means default.
* Combine one or more of \a MemoryCapability from <tactility/memory.h> with a bitwise OR.*/
uint16_t desired_memory_capability;
};
/** Describes a registrable app. One manifest exists per app id. */
struct AppManifest {
/** Unique app identifier. Should never be NULL. */
@@ -34,8 +53,12 @@ struct AppManifest {
struct AppLocation location;
/** Bitmask of AppManifestFlags. Most apps should leave this 0. */
uint8_t flags;
/** Stack allocation config for this app's task. */
struct AppStackConfig stack;
};
bool app_id_is_valid(const char* id);
#ifdef __cplusplus
}
#endif
@@ -50,6 +50,12 @@ struct AppMetadata {
* Must be NULL-terminated.
*/
char requires_device_id[APP_METADATA_REQUIRES_DEVICE_ID_LENGTH + 1];
/**
* Stack depth (in words) for the app's task. Optional; 0 means scheduler default.
* @warning Avoid default values: the default is conservative, which wastes memory.
*/
uint32_t stack_depth;
};
/**