Skip to content

Commit 966f692

Browse files
Merge pull request csg-tokyo#80 from maejima-fumika/develop/add-getstarted-docs
Add "Get started" and "CLI Reference" to the website.
2 parents 1ee4dcf + bd75ca3 commit 966f692

File tree

12 files changed

+1690
-115
lines changed

12 files changed

+1690
-115
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can find the official website at https://csg-tokyo.github.io/bluescript/.
99
WARNING: this project is in beta stage and is subject to changes of the code-base, including project-wide name changes and API changes.
1010

1111
# Documentation
12-
- [Get started](https://csg-tokyo.github.io/bluescript/docs/tutorial/get-started)
12+
- [Quick Start](http://localhost:3000/bluescript/docs/tutorial/get-started/quick-start)
1313
- [Reference Manual](https://csg-tokyo.github.io/bluescript/docs/reference/language/intro)
1414

1515
- Fumika Mochizuki, Tetsuro Yamazaki, Shigeru Chiba, ["Interactive Programming for Microcontrollers by Offloading Dynamic Incremental Compilation"](https://dl.acm.org/doi/10.1145/3679007.3685062), MPLR 2024, pp. 28-40, ACM, 2024.

website/docs/reference/cli.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# CLI
2+
3+
The BlueScript CLI (`blue`) is the primary tool for managing projects, setting up board environments, and running code on your devices.
4+
5+
## Installation
6+
7+
```bash
8+
npm install -g @bluescript/cli
9+
```
10+
11+
## Project Commands
12+
13+
### `blue create-project`
14+
15+
Creates a new BlueScript project with the necessary configuration files.
16+
17+
```bash
18+
blue create-project <project-name> [options]
19+
```
20+
21+
This command generates a new directory containing:
22+
* `index.bs`: The main entry point for your application.
23+
* `bsconfig.json`: The project configuration file.
24+
25+
**Arguments:**
26+
* `<project-name>`: The name of the directory to create.
27+
28+
**Options:**
29+
30+
| Option | Alias | Description |
31+
| :--- | :--- | :--- |
32+
| `--board` | `-b` | Specify the target board (e.g., `esp32`). If omitted, an interactive selection list will appear. |
33+
34+
**Example:**
35+
```bash
36+
# Create a project interactively
37+
blue create-project my-app
38+
39+
# Create a project specifically for ESP32
40+
blue create-project my-app --board esp32
41+
```
42+
43+
---
44+
45+
### `blue run`
46+
47+
Compiles the current project and executes it on a target device via Bluetooth.
48+
49+
```bash
50+
blue run
51+
```
52+
53+
When you run this command:
54+
1. The CLI scans for available BlueScript devices over Bluetooth.
55+
2. The project is compiled into native code on your host machine.
56+
3. The code is transferred and executed immediately.
57+
58+
---
59+
60+
## Board Management
61+
62+
These commands manage the toolchains and runtime environments for specific hardware platforms.
63+
64+
### `blue board setup`
65+
66+
Downloads and installs the necessary environment files and dependencies for a specific board architecture.
67+
68+
```bash
69+
blue board setup <board-name>
70+
```
71+
72+
**Arguments:**
73+
* `<board-name>`: The target board identifier (e.g., `esp32`).
74+
75+
---
76+
77+
### `blue board flash-runtime`
78+
79+
Flashes the BlueScript Runtime firmware onto the microcontroller.
80+
**Note:** This command requires a physical USB connection to the device.
81+
82+
```bash
83+
blue board flash-runtime <board-name> [options]
84+
```
85+
86+
**Arguments:**
87+
* `<board-name>`: The target board identifier.
88+
89+
**Options:**
90+
91+
| Option | Alias | Description |
92+
| :--- | :--- | :--- |
93+
| `--port` | `-p` | Specify the serial port connected to the device (e.g., `COM3`, `/dev/ttyUSB0`). If omitted, the CLI will list available ports for selection. |
94+
95+
**Example:**
96+
```bash
97+
blue board flash-runtime esp32 --port /dev/ttyUSB0
98+
```
99+
100+
---
101+
102+
### `blue board list`
103+
104+
Lists all board architectures currently supported by the installed CLI version.
105+
106+
```bash
107+
blue board list
108+
```
109+
110+
---
111+
112+
### `blue board remove`
113+
114+
Removes the environment files and setup data for a specific board.
115+
116+
```bash
117+
blue board remove <board-name> [options]
118+
```
119+
120+
By default, this command asks for confirmation before deleting files.
121+
122+
**Options:**
123+
124+
| Option | Alias | Description |
125+
| :--- | :--- | :--- |
126+
| `--force` | `-f` | Skips the confirmation prompt and forces removal. |
127+
128+
---
129+
130+
### `blue board fullclean`
131+
132+
Completely removes all configuration and environment files for **all** boards. This returns the CLI board configurations to a fresh state.
133+
134+
```bash
135+
blue board fullclean
136+
```
137+
By default, this command asks for confirmation before deleting files.
138+
139+
**Options:**
140+
141+
| Option | Alias | Description |
142+
| :--- | :--- | :--- |
143+
| `--force` | `-f` | Skips the confirmation prompt and forces removal. |

website/docs/reference/cli/install.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Blink LED
22

3-
In preparation
3+
Coming soon...

website/docs/tutorial/get-started.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Introduction
2+
3+
Welcome to **BlueScript**.
4+
5+
BlueScript is not just another programming language with a new syntax. It is a next-generation language system for microcontrollers, built upon a novel architectural concept called the **Disaggregated Virtual Machine**.
6+
7+
## Why BlueScript?
8+
**The Existing Trade-off:**
9+
Until now, microcontroller development has forced developers to choose between two extremes:
10+
11+
1. **C/C++ (Compiled Languages):**
12+
* **Pros:** High execution speed, high memory efficiency.
13+
* **Cons:** Slow development cycle (compile → flash → run), requires physical cable connection.
14+
2. **MicroPython / Espruino (Interpreted Languages):**
15+
* **Pros:** Easy to write, rapid prototyping.
16+
* **Cons:** Slow execution speed, high memory consumption (RAM) because compilation and interpretation happen on the device.
17+
18+
BlueScript resolves this dilemma. By adopting the **Disaggregated VM** architecture, it delivers the **flexibility of a script language** with **performance comparable to compiled languages**.
19+
20+
## What is a Disaggregated VM?
21+
22+
Traditional Virtual Machines (Monolithic VMs) cram the compiler, interpreter, and runtime all into the microcontroller's limited memory.
23+
24+
BlueScript physically separates (disaggregates) these VM components between the **Host (PC)** and the **Target (Microcontroller)**.
25+
26+
### Architecture Overview
27+
28+
```mermaid
29+
graph LR
30+
subgraph Host["Host Machine (PC)"]
31+
Source[Source Code]
32+
Compiler[Incremental Compiler]
33+
Shadow[Shadow Machine]
34+
end
35+
36+
subgraph Target["Target Device (MCU)"]
37+
Runtime[Lightweight Runtime]
38+
Execution[Native Execution]
39+
end
40+
41+
Source --> Compiler
42+
Compiler -- "Native Code" --> Runtime
43+
Runtime --> Execution
44+
Shadow -. "State Sync" .- Runtime
45+
46+
style Host fill:#f9f,stroke:#333,stroke-width:2px
47+
style Target fill:#bbf,stroke:#333,stroke-width:2px
48+
style Compiler fill:#ff9,stroke:#333
49+
style Runtime fill:#9f9,stroke:#333
50+
```
51+
52+
### Core Technologies
53+
54+
This architecture is powered by three key technologies:
55+
56+
1. **Offloaded Compilation**
57+
Resource-heavy compilation tasks are offloaded to the powerful Host PC. The incremental compiler on the host converts BlueScript code into optimized native code. The microcontroller only receives and executes this code, resulting in **significantly faster execution and lower memory usage** compared to MicroPython.
58+
59+
2. **Shadow Machine**
60+
The Host PC maintains a "Shadow Machine" that mirrors the state of the microcontroller (memory map, symbol tables, etc.). Because the host knows the exact state of the device, it can compile new code fragments that link correctly to the running program. This enables **interactive development**.
61+
62+
3. **Bluetooth OTA Updates**
63+
Since the compiled binary differences are very small, they can be transferred instantly over Bluetooth Low Energy (BLE). Once the runtime is flashed, you can update your program **wirelessly without cables**.
64+
65+
## The BlueScript Experience
66+
67+
Thanks to this unique architecture, BlueScript offers a developer experience unlike any other:
68+
69+
* **TypeScript-like Syntax:** Write in a modern, familiar syntax.
70+
* **Inline C:** Embed C code directly for critical performance sections or hardware access.
71+
* **Interactive Mode:** Execute code line-by-line and inspect variables instantly, just like a REPL, but with compiled performance.
72+
73+
:::info Academic Background
74+
The architecture of BlueScript is based on the research paper *["BlueScript: A Disaggregated Virtual Machine for Microcontrollers"](https://arxiv.org/pdf/2511.15821v1)*.
75+
:::
76+
77+
## Supported Hardware
78+
79+
Currently, BlueScript supports the following platform:
80+
- Espressif ESP32 (Supported)
81+
82+
:::note Future Roadmap
83+
We plan to support other boards in the future.
84+
:::
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Quick Start
2+
3+
Let's get your first BlueScript program running. In this guide, we will set up your environment, flash the runtime to a microcontroller, and execute code wirelessly over Bluetooth.
4+
5+
Currently, only ESP32 development board is supported.
6+
7+
## Prerequisites
8+
9+
Before we begin, ensure you have the following:
10+
11+
* **Hardware:** An ESP32 development board (e.g., ESP32-DevKitC) and a USB cable.
12+
* **Software:** [Node.js](https://nodejs.org/) (v18 or later) installed on your computer.
13+
14+
---
15+
16+
## Step 1: Install the CLI
17+
18+
BlueScript provides a command-line interface (CLI) to manage projects and communicate with your device. Install it globally using npm:
19+
20+
```bash
21+
npm install -g @bluescript/cli
22+
```
23+
24+
Verify the installation:
25+
26+
```bash
27+
blue --version
28+
```
29+
30+
---
31+
32+
## Step 2: Board Setup
33+
34+
Because BlueScript uses a **Disaggregated VM** architecture, you need to install the lightweight **Runtime** onto your microcontroller.
35+
36+
:::info One-Time Setup
37+
The USB cable is only required for this step (`flash-runtime`). For daily development, you can use Bluetooth.
38+
:::
39+
40+
1. **Download the platform tools** for ESP32:
41+
42+
```bash
43+
blue board setup esp32
44+
```
45+
Note: Currently, only esp32 is supported.
46+
47+
2. **Connect your ESP32** to your computer via USB.
48+
3. **Flash the Runtime** to the device:
49+
50+
```bash
51+
blue board flash-runtime esp32
52+
```
53+
54+
---
55+
56+
## Step 3: Create a Project
57+
58+
Create a new directory for your project. The CLI will generate the necessary configuration files.
59+
60+
```bash
61+
blue create-project hello-bluescript
62+
cd hello-bluescript
63+
```
64+
65+
This creates a simple project structure:
66+
* `bsconfig.json`: Project configuration.
67+
* `index.bs`: Your entry point file.
68+
69+
---
70+
71+
## Step 4: Write Code
72+
73+
Open `index.bs` and write a simple program.
74+
75+
```typescript title="index.bs"
76+
print("Hello world!");
77+
```
78+
---
79+
80+
## Step 5: Run Wirelessly
81+
82+
Make sure your ESP32 is powered on. You can disconnect the USB cable and power it via a battery if you wish.
83+
84+
Run the following command:
85+
86+
```bash
87+
blue run
88+
```
89+
90+
**What happens next?**
91+
1. It scans for nearby BlueScript devices.
92+
2. The CLI compiles your project into **Native Code** on your PC.
93+
3. Upon selection, it transfers the binary via **Bluetooth**.
94+
4. The ESP32 executes the code immediately.
95+
96+
---
97+
98+
## Next Steps
99+
100+
Now that you have the basics down, explore what else BlueScript can do:
101+
102+
* **[Language Reference](../../reference/language/intro)**: Learn about supported syntax, Inline C, and hardware APIs.
103+
* **[CLI Reference](../../reference/cli)**: Discover advanced commands.

website/docusaurus.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ const config: Config = {
3030
onBrokenLinks: 'throw',
3131
onBrokenMarkdownLinks: 'warn',
3232

33+
markdown: {
34+
mermaid: true,
35+
},
36+
themes: ["@docusaurus/theme-mermaid"],
37+
3338
// Even if you don't use internationalization, you can use this field to set
3439
// useful metadata like html lang. For example, if your site is Chinese, you
3540
// may want to replace "en" with "zh-Hans".

0 commit comments

Comments
 (0)