Skip to content

Commit 53e1920

Browse files
feat(zephyr): add Zephyr RTOS RISC-V datum with unified orchestration
Add complete Zephyr RTOS development environment for RISC-V with Rust support. Part of b00t unified orchestration architecture for resource management across Blender (3D robotics/physics), embedded systems, and AI/ML workloads. Components: - Dockerfile with Zephyr SDK 0.16.8, QEMU RISC-V, Rust toolchains - Install script for Ubuntu/Fedora/RHEL - Just recipes for build/run/test workflows - Docker Compose orchestration - MCP integration (CLI + Docker) - Architecture doc explaining unified resource management Integration: - Targets elasticdotventures/zephyr-rust-b00t fork - Integrates with Blender fork (PR #108) for 3D robotics - Shares GPU, API keys, quotas via DAG-based job orchestration - Prevents inter-process agent contention - Event-triggered + scheduled execution Justfile module: zephyr::* Commands: build, run, sample, qemu, install, verify, test Ref: #108
1 parent 74576b4 commit 53e1920

File tree

13 files changed

+1277
-0
lines changed

13 files changed

+1277
-0
lines changed

_b00t_/zephyr.⚡/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build artifacts
2+
build/
3+
*.o
4+
*.elf
5+
*.bin
6+
*.hex
7+
8+
# Zephyr artifacts
9+
.west/
10+
zephyr-project/
11+
*.dts
12+
*.dtb
13+
14+
# Rust artifacts
15+
target/
16+
Cargo.lock
17+
18+
# Editor
19+
.vscode/
20+
.idea/
21+
*.swp
22+
*.swo
23+
*~
24+
25+
# OS
26+
.DS_Store
27+
Thumbs.db

_b00t_/zephyr.⚡/ARCHITECTURE.md

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# ⚡ Zephyr RISC-V in B00t Unified Architecture
2+
3+
## Context
4+
5+
🤓 **Critical architectural context:** This Zephyr RISC-V datum is ONE capability in a unified b00t ecosystem, NOT a standalone project.
6+
7+
## B00t Unified Orchestration
8+
9+
### Integration Points
10+
11+
**Blender Fork Integration:**
12+
- PR: https://github.com/elasticdotventures/_b00t_/pull/108
13+
- Capabilities: 3D robotics, physics simulators, dozen+ MCP servers
14+
- Massive ecosystem expansion (significant size increase)
15+
16+
**Zephyr RISC-V Role:**
17+
- Embedded systems capability
18+
- RISC-V microcontroller development
19+
- Hardware interface layer
20+
- Real-time OS for robotics control
21+
22+
### Unified Topological Skill System
23+
24+
**Architecture Goals:**
25+
- Event-triggered execution
26+
- Scheduled jobs
27+
- DAG (Directed Acyclic Graph) of ordered parallelized jobs
28+
- Application-aware prioritization
29+
- Shared resource orchestration
30+
31+
### Resource Management
32+
33+
**Shared Resources:**
34+
- GPU allocation/release
35+
- API keys (Anthropic, OpenAI, etc.)
36+
- Usage/rate limiting quotas
37+
- Compute resources
38+
39+
**Anti-Patterns Prevented:**
40+
- Inter-process agent contention
41+
- Wasted energy on resource conflicts
42+
- Self-disabling agents due to quota exhaustion
43+
- Race conditions in resource allocation
44+
45+
## Ecosystem Integration
46+
47+
```
48+
b00t Unified Orchestration
49+
├── Blender.🎨 (3D robotics, physics)
50+
│ ├── MCP servers (dozen+)
51+
│ ├── Physics simulators
52+
│ └── Robotics control
53+
├── Zephyr.⚡ (embedded RISC-V)
54+
│ ├── RTOS capabilities
55+
│ ├── Hardware interfaces
56+
│ └── Real-time control
57+
├── Python.🐍 (AI/ML workloads)
58+
├── Rust.🦀 (systems programming)
59+
├── Node-TS.🦄 (services)
60+
└── Docker.🐳 (containerization)
61+
```
62+
63+
## Job Orchestration
64+
65+
### DAG-Based Execution
66+
67+
```
68+
Job Dependency Graph:
69+
┌─────────────┐
70+
│ Blender │ (reserve GPU)
71+
│ Physics │
72+
└──────┬──────┘
73+
74+
┌────┴────┐
75+
│ │
76+
┌───▼───┐ ┌──▼────┐
77+
│Zephyr │ │Python │ (parallel, shared API keys)
78+
│RISC-V │ │AI/ML │
79+
└───┬───┘ └───┬───┘
80+
│ │
81+
└────┬────┘
82+
83+
┌────▼─────┐
84+
│ Release │
85+
│Resources │
86+
└──────────┘
87+
```
88+
89+
### Event Triggers
90+
91+
- Hardware events (RISC-V sensors)
92+
- Timer/scheduler
93+
- API callbacks
94+
- User actions in Blender
95+
- CI/CD pipeline events
96+
97+
## Preventing Schisms
98+
99+
🤓 **Design principle:** Aggressive culling of capabilities can cause ecosystem fragmentation. Each datum (Blender, Zephyr, Python, etc.) is a composable building block in the unified system.
100+
101+
**Integration Strategy:**
102+
- Modular justfile recipes
103+
- MCP server protocol
104+
- Shared configuration (TOML)
105+
- Docker compose orchestration
106+
- Resource reservation protocol
107+
108+
## Resource Reservation Protocol
109+
110+
```rust
111+
// Conceptual resource manager
112+
struct ResourceManager {
113+
gpu: Mutex<GPUPool>,
114+
api_keys: RateLimiter,
115+
quotas: QuotaTracker,
116+
}
117+
118+
impl ResourceManager {
119+
fn reserve_for_job(&self, job: &Job) -> Result<Reservation> {
120+
// Atomic reservation preventing contention
121+
let resources = self.gpu.lock()
122+
.reserve(job.gpu_requirements)?;
123+
let api_handle = self.api_keys
124+
.acquire(job.api_needs)?;
125+
126+
Ok(Reservation { resources, api_handle })
127+
}
128+
129+
fn release(&self, reservation: Reservation) {
130+
// Return to pool for next job
131+
}
132+
}
133+
```
134+
135+
## Architectural Benefits
136+
137+
1. **No Wasted Energy:** Jobs wait for resources instead of failing
138+
2. **No Self-Disabling:** Quota-aware scheduling prevents lockout
139+
3. **Optimal GPU Utilization:** Time-sliced across Blender, ML, and simulation
140+
4. **API Key Management:** Rate limiting prevents 429 errors
141+
5. **Unified Skill DAG:** Dependencies resolved before execution
142+
143+
## Zephyr-Specific Integration
144+
145+
### Hardware Interface Layer
146+
147+
Zephyr provides RTOS capabilities for:
148+
- Sensor data collection (robotics)
149+
- Real-time motor control
150+
- Hardware interrupt handling
151+
- Low-latency event processing
152+
153+
### MCP Integration
154+
155+
```toml
156+
# zephyr-hardware.mcp.toml
157+
[server]
158+
name = "zephyr-hardware"
159+
description = "Hardware interface via Zephyr RTOS"
160+
161+
[capabilities]
162+
sensors = true
163+
actuators = true
164+
real_time = true
165+
```
166+
167+
### Blender ↔ Zephyr Pipeline
168+
169+
```
170+
Blender Physics Simulation
171+
↓ (simulation state)
172+
Zephyr RISC-V Controller
173+
↓ (motor commands)
174+
Physical Robot Hardware
175+
↓ (sensor feedback)
176+
Blender Visualization
177+
```
178+
179+
## Future Expansion
180+
181+
As b00t balloons in size with more MCP servers:
182+
- Each datum maintains modular isolation
183+
- Just recipes compose across domains
184+
- Resource manager scales to N capabilities
185+
- DAG execution prevents blocking
186+
187+
## References
188+
189+
- Blender Integration: https://github.com/elasticdotventures/_b00t_/pull/108
190+
- B00t Gospel: `_b00t_/AGENT.md`
191+
- Resource Management: TBD (future datum)
192+
- DAG Execution: Taskmaster-AI MCP
193+
194+
---
195+
196+
🤓 This architecture prevents the wasted compute and agent chaos that occurs when multiple systems compete for shared resources without coordination.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# syntax=docker/dockerfile:1
2+
3+
##* * * * * \\
4+
# 🐳 Docker
5+
# ⚡ Zephyr RTOS RISC-V
6+
# 层 (Céng) Layer
7+
#
8+
#* Zephyr RTOS development environment with RISC-V support and QEMU emulation
9+
#* Based on elasticdotventures/zephyr-rust-b00t fork
10+
##* * * * * //
11+
12+
FROM ubuntu:24.04
13+
14+
# Prevent interactive prompts during build
15+
ENV DEBIAN_FRONTEND=noninteractive
16+
ENV ZEPHYR_BASE=/opt/zephyrproject/zephyr
17+
ENV PATH="${PATH}:/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin"
18+
19+
# Core dependencies for Zephyr
20+
RUN apt-get update && apt-get install -y \
21+
git \
22+
cmake \
23+
ninja-build \
24+
gperf \
25+
ccache \
26+
dfu-util \
27+
device-tree-compiler \
28+
wget \
29+
python3-dev \
30+
python3-pip \
31+
python3-venv \
32+
python3-tk \
33+
xz-utils \
34+
file \
35+
make \
36+
gcc \
37+
gcc-multilib \
38+
g++-multilib \
39+
libsdl2-dev \
40+
libmagic1 \
41+
curl \
42+
&& rm -rf /var/lib/apt/lists/*
43+
44+
# QEMU for RISC-V emulation
45+
RUN apt-get update && apt-get install -y \
46+
qemu-system-misc \
47+
qemu-system-riscv64 \
48+
&& rm -rf /var/lib/apt/lists/*
49+
50+
# Rust toolchain for zephyr-rust-b00t
51+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
52+
ENV PATH="/root/.cargo/bin:${PATH}"
53+
54+
# RISC-V targets for Rust
55+
RUN rustup target add riscv32i-unknown-none-elf \
56+
&& rustup target add riscv32imac-unknown-none-elf \
57+
&& rustup target add riscv32imc-unknown-none-elf \
58+
&& rustup target add riscv64gc-unknown-none-elf \
59+
&& rustup target add riscv64imac-unknown-none-elf
60+
61+
# Create workspace
62+
WORKDIR /workspace
63+
64+
# Install West (Zephyr meta-tool)
65+
RUN python3 -m pip install --user -U west
66+
67+
# Initialize Zephyr project
68+
RUN west init /opt/zephyrproject && \
69+
cd /opt/zephyrproject && \
70+
west update && \
71+
west zephyr-export
72+
73+
# Install Python dependencies
74+
RUN python3 -m pip install --user -r /opt/zephyrproject/zephyr/scripts/requirements.txt
75+
76+
# Download and install Zephyr SDK (minimal with RISC-V support)
77+
ENV ZEPHYR_SDK_VERSION=0.16.8
78+
RUN wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz && \
79+
tar -xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz -C /opt && \
80+
rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz && \
81+
cd /opt/zephyr-sdk-${ZEPHYR_SDK_VERSION} && \
82+
./setup.sh -t riscv64-zephyr-elf -c
83+
84+
# Setup environment for subsequent runs
85+
RUN echo 'export ZEPHYR_BASE=/opt/zephyrproject/zephyr' >> /root/.bashrc && \
86+
echo 'export PATH="${PATH}:/opt/zephyr-sdk-${ZEPHYR_SDK_VERSION}"' >> /root/.bashrc && \
87+
echo 'source /opt/zephyrproject/zephyr/zephyr-env.sh' >> /root/.bashrc
88+
89+
# Clone zephyr-rust-b00t
90+
WORKDIR /workspace
91+
RUN git clone https://github.com/elasticdotventures/zephyr-rust-b00t.git
92+
93+
WORKDIR /workspace/zephyr-rust-b00t
94+
95+
# 🤓: container ready for Zephyr RISC-V development
96+
# Example usage:
97+
# west build -b qemu_riscv64 samples/synchronization
98+
# west build -t run
99+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)