@@ -11,7 +11,112 @@ Unified simulation framework for Oasis firmware with MCU emulation and MCP inter
1111- ** MCP Server** : AI-accessible API for simulation control
1212- ** Fault Injection** : Test edge cases with disconnect, stuck, offset, and noise faults
1313
14- ## Quick Start
14+ ## Getting Started: Build Your First Device
15+
16+ ### 1. Install the Simulation Framework
17+
18+ ``` bash
19+ cd oasis-firmware/oasis-rpi/simulation
20+ pip install -e .[all]
21+ ```
22+
23+ ### 2. Create a Device Configuration
24+
25+ Create ` my_device.yaml ` in your project directory:
26+
27+ ``` yaml
28+ device :
29+ id : my-first-device
30+ name : Simple Temperature Monitor
31+ board :
32+ platform : mcu
33+ model : esp32_devkit
34+
35+ sensors :
36+ - name : temp_sensor
37+ type : dht22
38+ pins :
39+ data : 4
40+ sampling :
41+ interval_ms : 5000
42+
43+ actuators :
44+ - name : warning_led
45+ type : relay
46+ pins :
47+ output : 16
48+ default :
49+ state : off
50+
51+ control_loops :
52+ - name : temp_warning
53+ type : threshold
54+ input :
55+ sensor : temp_sensor
56+ measurement : temperature
57+ output :
58+ actuator : warning_led
59+ threshold :
60+ setpoint : 30.0
61+ hysteresis : 2.0
62+ direction : heat
63+ ` ` `
64+
65+ ### 3. Run a Simulation
66+
67+ ` ` ` python
68+ from behavioral import BehavioralRuntime
69+ from pathlib import Path
70+
71+ # Initialize runtime
72+ runtime = BehavioralRuntime()
73+ runtime.load_component_library(Path('components'))
74+
75+ # Add components
76+ runtime.add_component('temp1', 'dht22')
77+ runtime.add_component('led1', 'relay')
78+
79+ # Set physical input (simulated environment)
80+ runtime.set_physical_input('temp1', 'temp_actual', 25.0)
81+ runtime.set_physical_input('temp1', 'humidity_actual', 60.0)
82+
83+ # Run simulation loop
84+ for _ in range(100) :
85+ runtime.step(0.1) # 100ms steps
86+ state = runtime.get_state()
87+ print(f"Time : {state['sim_time_ms']}ms")
88+ ` ` `
89+
90+ ### 4. Using the MCP Server (AI-Assisted Development)
91+
92+ Start the MCP server for AI assistant integration:
93+
94+ ` ` ` bash
95+ oasis-sim # Runs stdio MCP server
96+ ```
97+
98+ Then use your AI assistant to:
99+ - Add components: "Add a DHT22 sensor called sensor1"
100+ - Run simulation: "Step the simulation forward 1 second"
101+ - Inject faults: "Disconnect sensor1 to test fault handling"
102+ - Generate components: "Parse this datasheet and create a component YAML"
103+
104+ ## Desktop UI (Rust + egui)
105+
106+ The desktop application provides a visual interface for simulation:
107+
108+ ``` bash
109+ cd oasis-firmware/oasis-rpi/desktop
110+ cargo run --release
111+ ```
112+
113+ ### UI Features
114+ - ** Device Editor** : Visual drag-and-drop component placement
115+ - ** Wiring View** : See signal connections between components
116+ - ** Simulation Panel** : Real-time waveform visualization
117+ - ** Fault Injection** : Click to inject faults and test resilience
118+
119+ ## Quick Start (CLI)
15120
16121``` bash
17122# Install (basic)
@@ -34,47 +139,60 @@ oasis-datasheet generate sensor.pdf -o components/sensors/new.yaml
34139
35140## Emulator Prerequisites
36141
37- ### ESP32 (Easiest - Wokwi)
142+ ### ESP32 (Wokwi CLI) - Recommended
38143``` bash
39- # Wokwi CLI (cloud-based, no local install needed)
40- source ~ /.nvm/nvm.sh && nvm use 20
41- npm install -g wokwi-cli
42- ```
144+ # macOS ARM64
145+ curl -L -o /usr/local/bin/wokwi-cli \
146+ https://github.com/wokwi/wokwi-cli/releases/download/v0.26.1/ wokwi-cli-macos-arm64
147+ chmod +x /usr/local/bin/wokwi-cli
43148
44- ### ESP32 (Local - QEMU)
45- ``` bash
46- # Build Espressif QEMU
47- git clone https://github.com/espressif/qemu.git
48- cd qemu
49- ./configure --target-list=xtensa-softmmu
50- make -j$( nproc)
51- sudo make install
149+ # macOS x64
150+ curl -L -o /usr/local/bin/wokwi-cli \
151+ https://github.com/wokwi/wokwi-cli/releases/download/v0.26.1/wokwi-cli-macos-x64
152+ chmod +x /usr/local/bin/wokwi-cli
153+
154+ # Linux
155+ curl -L -o /usr/local/bin/wokwi-cli \
156+ https://github.com/wokwi/wokwi-cli/releases/download/v0.26.1/wokwi-cli-linux-x64
157+ chmod +x /usr/local/bin/wokwi-cli
158+
159+ # Verify
160+ wokwi-cli --version
52161```
53162
54163### Arduino (simavr)
55164``` bash
56165# macOS - build from source
166+ brew tap osx-cross/avr
57167brew install avr-gcc libelf
58168git clone https://github.com/buserror/simavr.git
59- cd simavr && make && sudo make install
169+ cd simavr && make && sudo make install PREFIX=/usr/local
60170
61171# Ubuntu/Debian
62- sudo apt install simavr
172+ sudo apt install simavr avr-libc
173+
174+ # Verify
175+ simavr --help
63176```
64177
65178### STM32 (Renode)
66179``` bash
67- # macOS - download from releases
68- curl -LO https://github.com/renode/renode/releases/download/v1.15.0/renode-1.15.0.macos-x64.dmg
180+ # macOS ARM64
181+ curl -LO https://github.com/renode/renode/releases/download/v1.16.1/renode-1.16.1-dotnet.osx-arm64-portable.dmg
182+ hdiutil attach renode-1.16.1-dotnet.osx-arm64-portable.dmg
183+ cp -R " /Volumes/Renode_1.16.1/Renode.app" /Applications/
184+ ln -sf /Applications/Renode.app/Contents/MacOS/Renode /usr/local/bin/renode
185+ hdiutil detach " /Volumes/Renode_1.16.1"
186+
187+ # macOS x64
188+ curl -LO https://github.com/renode/renode/releases/download/v1.16.1/renode_1.16.1.dmg
69189# Mount and copy to /Applications
70190
71191# Ubuntu/Debian
72192sudo apt install renode
73193
74- # Or portable version
75- wget https://github.com/renode/renode/releases/download/v1.15.0/renode-1.15.0.linux-portable.tar.gz
76- tar xzf renode-1.15.0.linux-portable.tar.gz
77- export PATH=$PATH :$( pwd) /renode_1.15.0_portable
194+ # Verify
195+ renode --version
78196```
79197
80198## MCP Tools
0 commit comments