Skip to content

Commit

Permalink
docs: add README.md
Browse files Browse the repository at this point in the history
Signed-off-by: tfx2001 <tfx2001@outlook.com>
  • Loading branch information
tfx2001 committed Jul 27, 2024
1 parent 1db223c commit a8991f8
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# RustSBI implementation for HPMicro MCUs

[![Build](https://github.com/hpm-rs/rustsbi-hpm/actions/workflows/ci.yml/badge.svg)](https://github.com/hpm-rs/rustsbi-hpm/actions/workflows/ci.yml)

## 介绍

这是一个基于 [RustSBI](https://github.com/rustsbi/rustsbi),用于 HPMicro MCUs 的 SBI 实现。支持以下功能:

### SEE (Supervisor Execution Environment)

目前支持以下 SBI 拓展:

- legacy console
- timer

### SDRAM 初始化

支持初始化 SDRAM 并映射到 AXI 总线。可用于后续内核的启动和执行。

### Linux 内核引导

支持引导 Linux 内核,并传递设备树。内核链接和烧录时请遵循如下布局。

| Name | Base Address | Load Address | Length |
|----------|---------------|--------------|-----------|
| RustSBI | 0x80003000 | 0x80003000 | 64 KB |
| Kernel | 0x40000000 | 0x80010000 | 3 MB |
| DTB | 0x40300000 | 0x80310000 | 16 KB |

## 编译与烧录

通过如下命令生成烧录所需的 `.bin` 文件。

```shell
# 安装 cargo-binutils
cargo install cargo-binutils
# 生成 .bin 文件
cargo objcopy --release --features=flash -- -O binary rustsbi.bin
```

编译完成后,可使用 [hpm_isp](https://github.com/tfx2001/hpm_isp) 进行烧录。修改启动模式选择管脚为 `BOOT_MODE[1:0]=0b10` 后将 USB0 连接至 PC,运行如下命令进行烧录。

```shell
hpm_isp flash 0 write 0x0 rustsbi.bin
```

## 支持的开发版

- [HPM6360EVK](http://hpmicro.com/resources/detail2.html?id=b60936f5-c3fe-4916-bb7d-854cc6bc5456)

## Rust 版本

```
rustc 1.81.0-nightly (6be96e386 2024-07-09)
```

# 相关链接

- [hpm-rs/buildroot](https://github.com/hpm-rs/buildroot) - 为 HPMicro MCUs 生成可启动的 Linux 镜像
8 changes: 4 additions & 4 deletions src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{DTB_LOAD_ADDRESS, SUPERVISOR_ENTRY};
#[derive(PartialEq)]
enum BlobType {
Kernel,
Dts,
Dtb,
}
struct BlobInfo {
type_: BlobType,
Expand All @@ -16,7 +16,7 @@ struct BlobInfo {
/// |---------|------------|--------|
/// | RustSBI | 0x80000000 | 64 KB |
/// | Kernel | 0x80010000 | 3 MB |
/// | DTS | 0x80310000 | 16 KB |
/// | DTB | 0x80310000 | 16 KB |
///
const BLOB_TABLE: &'static [BlobInfo] = &[
BlobInfo {
Expand All @@ -25,7 +25,7 @@ const BLOB_TABLE: &'static [BlobInfo] = &[
length: 3 * 1024 * 1024,
},
BlobInfo {
type_: BlobType::Dts,
type_: BlobType::Dtb,
start: 0x80310000,
length: 16 * 1024,
},
Expand Down Expand Up @@ -57,7 +57,7 @@ pub unsafe fn load_test_kernel() {

pub unsafe fn load_dtb() {
let info: &BlobInfo = &BLOB_TABLE[1];
assert!(info.type_ == BlobType::Dts);
assert!(info.type_ == BlobType::Dtb);

info.load(DTB_LOAD_ADDRESS as *mut _);
}

0 comments on commit a8991f8

Please sign in to comment.