Skip to content

Commit 97b9c5e

Browse files
committed
fix: stuff
1 parent 4c5c0a3 commit 97b9c5e

File tree

8 files changed

+584
-180
lines changed

8 files changed

+584
-180
lines changed

.markdownlint.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"default": true,
3+
"MD013": { "line_length": 100, "code_blocks": false, "tables": false },
4+
"MD033": false,
5+
"MD041": false,
6+
"MD014": false,
7+
"MD030": { "ul_single": 1, "ul_multi": 1, "ol_single": 1, "ol_multi": 1 },
8+
"MD004": { "style": "dash" },
9+
"MD024": { "allow_different_nesting": true },
10+
"MD029": { "style": "ordered" },
11+
"MD036": false,
12+
"MD002": false
13+
}

SConstruct

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,21 @@ distenv.PhonyTarget(
394394
IMG_LINT_SOURCES=firmware_env["IMG_LINT_SOURCES"],
395395
)
396396

397-
distenv.Alias("lint_all", ["lint", "lint_py", "lint_img"])
397+
# Markdown Linting
398+
distenv.AddTarget(
399+
name="lint_md",
400+
dependencies=[],
401+
actions=[
402+
Action(
403+
"${PYTHON3} ${FBT_SCRIPT_DIR}/lint.py markdown ${ARGS}",
404+
"${LINT_MD_COMSTR}",
405+
)
406+
],
407+
LINT_MD_COMSTR="${BF}Running Markdown linter${NC}",
408+
)
409+
410+
distenv.Alias("lint_all", ["lint", "lint_py", "lint_img", "lint_md"])
411+
398412
distenv.Alias("format_all", ["format", "format_py", "format_img"])
399413

400414

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
Flipper Pod Manifest: 1
2-
Name: minimal-services
3-
Namespace: system
4-
ContainerCount: 2
5-
6-
# Optimized for absolute minimal resource usage
7-
Container0: minimal-app
8-
Image0: /ext/apps/Tools/minimal_app.fap
9-
Memory0: 4096
10-
CPU0: 5
11-
Threads0: 1
12-
RestartOnCrash0: 1
13-
SystemPrivileges0: 0
14-
15-
Container1: background-task
16-
Image1: /ext/apps/Tools/background_task.fap
17-
Memory1: 4096
18-
CPU1: 5
19-
Threads1: 1
20-
RestartOnCrash1: 1
21-
SystemPrivileges1: 0
1+
{
2+
"apiVersion": "v1",
3+
"kind": "Pod",
4+
"metadata": {
5+
"name": "minimal-pod",
6+
"namespace": "default"
7+
},
8+
"spec": {
9+
"containers": [
10+
{
11+
"name": "main",
12+
"image": "flipper/minimal:latest",
13+
"resources": {
14+
"limits": {
15+
"memory": "4K",
16+
"cpu": 10
17+
}
18+
},
19+
"securityContext": {
20+
"privileged": false
21+
}
22+
}
23+
],
24+
"restartPolicy": "OnFailure"
25+
}
26+
}

documentation/Containerization.md

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,71 @@
1-
# Lightweight Application Containers for Flipper Zero
1+
# Flipper Zero Containerization System
22

3-
## Overview
3+
The containerization system for Flipper Zero provides a minimal-overhead way to run and manage applications
4+
in a resource-efficient manner. This system draws inspiration from container orchestration systems like
5+
Kubernetes but is specifically designed for the highly constrained microcontroller environment.
46

5-
The containerization system for Flipper Zero provides a minimal-overhead way to run and manage applications in a resource-efficient manner. This system draws inspiration from container orchestration systems like Kubernetes but is specifically designed for the highly constrained microcontroller environment.
7+
## Architecture
68

7-
## Technical Specifications
9+
The system consists of the following key components:
810

9-
This system is designed with the Flipper Zero's limited resources in mind:
10-
- STM32WB55 MCU with ARM Cortex-M4 core (64 MHz)
11-
- 1MB Flash memory
12-
- 256KB RAM
11+
- **Container Runtime**: Manages container lifecycle (create, start, stop, destroy)
12+
- **Pod Manifest**: Defines container groups and their configurations
13+
- **Service Registry**: Provides lightweight service discovery for inter-container communication
14+
- **Resource Manager**: Enforces memory and CPU limits for containers
1315

14-
## Core Components
16+
## Performance Optimizations
1517

16-
### Container Runtime
18+
The containerization system implements several critical optimizations for resource-constrained environments:
1719

18-
The container runtime manages application lifecycles:
19-
- Starting/stopping applications
20-
- Basic resource monitoring
21-
- Auto-restart capabilities
20+
- **Memory Pooling**: Containers reuse memory from a pre-allocated pool instead of frequent malloc/free
21+
- **Hash-Based Service Lookups**: O(1) service discovery with hash-based optimization
22+
- **Lazy Loading**: Resources are loaded only when needed to minimize memory footprint
23+
- **Zero-Copy IPC**: Communication between containers uses shared memory references when possible
2224

23-
### Service Registry
25+
## Usage Examples
2426

25-
A lightweight service discovery mechanism:
26-
- Registration of internal and external services
27-
- Service lookup by name and namespace
28-
- Connection facilitation
27+
### Creating a Simple Container
2928

30-
### Pod Manifests
29+
```c
30+
// Create a pod manifest
31+
PodManifest* manifest = pod_manifest_create();
32+
manifest->name = "my-app";
33+
manifest->container_count = 1;
34+
manifest->containers[0].name = "main";
35+
manifest->containers[0].entry_point = my_app_main;
3136

32-
Declarative application definitions:
33-
- Compact manifest format (not JSON, more efficient)
34-
- Multi-container pod support
35-
- Resource specifications
36-
- Health check definitions (optional)
37+
// Start the container
38+
ContainerRuntime* runtime = container_runtime_get_instance();
39+
container_runtime_start(runtime, manifest);
40+
```
3741
38-
## CLI Commands
42+
### Service Registration and Discovery
3943
40-
Access container functionality through the command line:
44+
```c
45+
// Register a service
46+
ServiceRegistry* registry = service_registry_get_instance();
47+
MyService* my_service = my_service_create();
48+
service_registry_register(registry, "my-service", my_service);
49+
50+
// Discover a service
51+
MyService* service = service_registry_get_service(registry, "my-service");
52+
if(service) {
53+
my_service_call_method(service);
54+
}
55+
```
56+
57+
## Best Practices
58+
59+
1. Always specify resource limits in pod manifests
60+
2. Keep container count low - optimal performance with 3-5 containers
61+
3. Use service registry for interface discovery rather than direct references
62+
4. Implement graceful shutdown in containers to prevent resource leaks
63+
5. Prefer static allocation over dynamic when possible
64+
65+
## Future Improvements
66+
67+
- Container networking with virtual interfaces
68+
- Volume mounts for shared persistent storage
69+
- Container health checks and self-healing
70+
- Configuration maps for environment variables
4171

0 commit comments

Comments
 (0)