Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ ostool board run --package paging-test --bin basic
> Exit shortcut: In the serial terminal (e.g., `ostool run uboot`), press `Ctrl+A` then `x` to quit; the tool captures this sequence and exits gracefully instead of sending it to the target device.
> For more keyboard mappings, see `ostool/src/sterm/mod.rs`.

#### 5. Prepare Boot Artifacts

```bash
# Build the kernel and prepare a boot package under target/boot
ostool boot prepare

# Include a DTB and temporarily override Cargo package / binary target
ostool boot prepare --dtb virt.dtb --package paging-test --bin basic

# Override FIT addresses. Addresses accept decimal or 0x-prefixed hexadecimal.
ostool boot prepare --kernel-load-addr 0x80200000 --kernel-entry-addr 0x80200000

# Prepare the manifest, ELF metadata, boot script, and staging directories without FIT
ostool boot prepare --no-fit
```

`boot prepare` treats the built ELF as the canonical source artifact and derives
ELF entry/load metadata automatically. When FIT generation is enabled, the
required BIN is derived automatically; users do not need to declare a binary
artifact manually. The default output directory is the invocation's `target/boot`,
and the command writes a stable `boot-artifacts.json` v1 manifest.

## ⚙️ Configuration Files

ostool uses multiple independent TOML configuration files, each responsible for different functional modules:
Expand Down Expand Up @@ -201,8 +223,15 @@ pre_build_cmds = ["make prepare"]
# Post-build commands
post_build_cmds = ["make post-process"]

# Output as binary file
to_bin = true
# Optional compatibility field. U-Boot, board, and UEFI QEMU runs prepare the
# required BIN automatically.
to_bin = false

# Optional analysis artifacts. Field names describe artifacts, not tool names.
[system.Cargo.artifacts]
disassembly = false
elf_info = false
symbols = false
```

Command-line `--package`/`--bin` overrides are applied to the final Cargo
Expand All @@ -223,8 +252,14 @@ build_cmd = "make ARCH=aarch64 A=examples/helloworld"
# Generated ELF file path
elf_path = "examples/helloworld/helloworld_aarch64-qemu-virt.elf"

# Output as binary file
to_bin = true
# Optional compatibility field. U-Boot, board, and UEFI QEMU runs prepare the
# required BIN automatically.
to_bin = false

[system.Custom.artifacts]
disassembly = false
elf_info = false
symbols = false
```

### QEMU Configuration (.qemu.toml)
Expand All @@ -238,14 +273,21 @@ args = ["-machine", "virt", "-cpu", "cortex-a57", "-nographic"]
# Enable UEFI boot
uefi = false

# Output as binary file
to_bin = true
# Optional compatibility field. UEFI QEMU prepares the required BIN automatically.
to_bin = false

# Success regex patterns (for auto-detection)
success_regex = ["Hello from my OS", "Kernel booted successfully"]

# Failure regex patterns (for auto-detection)
fail_regex = ["panic", "error", "failed"]

# Boot mode. direct is the default path; uboot is recognized and fails early
# when firmware is missing.
[boot]
mode = "direct"
# mode = "uboot"
# firmware = "target/firmware/u-boot.bin"
```

### U-Boot Configuration (.uboot.toml)
Expand Down
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ ostool board run --package paging-test --bin basic
> 交互退出:在串口终端(如 `ostool run uboot`)中,按下 `Ctrl+A` 后再按 `x`,工具会检测到该序列并优雅退出,不会将按键发送到目标设备。
> 更多键盘快捷键映射可参考源码 `ostool/src/sterm/mod.rs`。

#### 5. 准备启动产物

```bash
# 构建内核并准备 target/boot 下的启动产物包
ostool boot prepare

# 附带 DTB,并临时覆盖 Cargo package / binary target
ostool boot prepare --dtb virt.dtb --package paging-test --bin basic

# 覆盖 FIT 地址,地址支持十进制或 0x 前缀十六进制
ostool boot prepare --kernel-load-addr 0x80200000 --kernel-entry-addr 0x80200000

# 只准备 manifest、ELF metadata、boot script 和 staging 目录,不生成 FIT
ostool boot prepare --no-fit
```

`boot prepare` 以构建出的 ELF 作为唯一源产物,自动推导 ELF entry/load metadata;需要
FIT 时会自动派生 BIN,不需要在配置中手动声明 binary。默认输出目录为当前 invocation 的
`target/boot`,并写出 `boot-artifacts.json` v1 manifest。

## ⚙️ 配置文件

ostool 使用多个独立的 TOML 配置文件,每个文件负责不同的功能模块:
Expand Down Expand Up @@ -202,6 +222,12 @@ post_build_cmds = ["make post-process"]

# 可选兼容字段。U-Boot、board 和 UEFI QEMU 运行会自动准备所需 BIN。
to_bin = false

# 可选分析产物。字段名描述产物,不描述底层命令。
[system.Cargo.artifacts]
disassembly = false
elf_info = false
symbols = false
```

命令行 `--package`/`--bin` 会先覆盖 `.build.toml` 中的 Cargo 包/二进制选择,再用于
Expand All @@ -223,6 +249,11 @@ elf_path = "examples/helloworld/helloworld_aarch64-qemu-virt.elf"

# 可选兼容字段。U-Boot、board 和 UEFI QEMU 运行会自动准备所需 BIN。
to_bin = false

[system.Custom.artifacts]
disassembly = false
elf_info = false
symbols = false
```

### QEMU 配置 (.qemu.toml)
Expand All @@ -244,6 +275,12 @@ success_regex = ["Hello from my OS", "Kernel booted successfully"]

# 失败运行的正则表达式(用于自动检测)
fail_regex = ["panic", "error", "failed"]

# 启动模式。direct 为默认路径;uboot 目前只识别配置并在缺少 firmware 时提前报错。
[boot]
mode = "direct"
# mode = "uboot"
# firmware = "target/firmware/u-boot.bin"
```

### U-Boot 配置 (.uboot.toml)
Expand Down
Loading