Skip to content

zgyxyd666/grub_head

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal Bare-Metal Debug Project for Phytium D3000M

这是一个最小化的 Rust 裸机项目,用于验证 Phytium D3000M 笔记本的启动流程和串口输出。它绕过了复杂的 ArceOS 初始化代码,直接测试最基础的硬件访问。

1. 项目目标

  • 验证 GRUB chainloader 加载机制是否正常。
  • 验证 EFI Stub (wrapper.bin) 是否能正确跳转到 Payload。
  • 验证串口地址 0x18002000 是否正确,能否输出字符。

2. 构建流程

前置条件

确保已安装 Rust nightly 和相关工具:

rustup target add aarch64-unknown-none
rustup component add llvm-tools-preview
cargo install cargo-binutils

步骤 1: 准备 Wrapper (如果尚未生成)

head/ 目录下:

# 需要 aarch64-linux-musl-gcc
aarch64-linux-musl-gcc -c wrapper.S -o wrapper.o
aarch64-linux-musl-objcopy -O binary wrapper.o wrapper.bin

(注:如果当前环境中 wrapper.bin 已存在,可跳过此步)

步骤 2: 编译 Rust Payload

head/start/ 目录下:

# 1. 编译 Release 版本
cargo build --release --target aarch64-unknown-none

# 2. 提取纯二进制文件 (start_zero.bin)
rust-objcopy --binary-architecture=aarch64 target/aarch64-unknown-none/release/start --strip-all -O binary start_zero.bin

步骤 3: 合并生成启动镜像

回到 head/ 目录运行脚本:

cd ..
./mk_start_img.sh

这将生成 head/start/arceos_linux.bin

4. 上机测试

  1. arceos_linux.bin 复制到 N80笔记本的 EFI 分区。

    sudo mkdir /boot/efi/EFI/arceos/
    scp /head/start/arceos_linux.bin kylin@10.88.31.105:/boot/efi/EFI/arceos/arceos_linux.bin
    
  2. 修改GRUB配置

    sudo vim /etc/grub.d/40_custom
    
    #!/bin/sh
    exec tail -n +3 $0
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    menuentry 'ArceOS (AArch64 Serial)' {
        search --no-floppy --set=root --file /EFI/arceos/arceos_linux.bin
        linux /EFI/arceos/arceos_linux.bin
        boot
    }
    
  3. 更新GRUB配置:

    sudo update-grub
    
  4. 开机 GRUB界面选择ArceOS (AArch64 Serial),并观察串口输出。预期结果:

    Hello, Bare Metal World!
    ...
    

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors