然后修改如下文件:
src/main.rs
#![no_std]
#![no_main]
extern crate panic_halt;
// use hifive1::hal::prelude::*;
// use hifive1::hal::DeviceResources;
use riscv_rt::entry;
#[entry]
fn main() -> ! {
loop {}
}
cargo/config
[target.riscv64gc-unknown-none-elf]
runner = "riscv64-unknown-elf-gdb -q -x gdb_init"
rustflags = [
"-C", "link-arg=-Tmemory.x",
"-C", "link-arg=-Tlink.x",
]
[build]
target = "riscv64gc-unknown-none-elf"
memory.x
MEMORY
{
/* NOTE 1 K = 1 KiBi = 1024 bytes */
/* TODO Adjust these memory regions to match your device memory layout */
/* These values correspond to the LM3S6965, one of the few devices QEMU can emulate */
FLASH : ORIGIN = 0x00020000, LENGTH = 32K
RAM : ORIGIN = 0x00028000, LENGTH = 64K
}
REGION_ALIAS("REGION_TEXT", FLASH);
REGION_ALIAS("REGION_RODATA", FLASH);
REGION_ALIAS("REGION_DATA", RAM);
REGION_ALIAS("REGION_BSS", RAM);
REGION_ALIAS("REGION_HEAP", RAM);
REGION_ALIAS("REGION_STACK", RAM);
gdb_init
set history save on
set confirm off
set remotetimeout 240
# 修改为T-Head DebugServer的gdb端口号:
target extended-remote :1025
set print asm-demangle on
monitor reset halt
load
continue
# quit
- 下载附件
保存到相册
2022-4-20 16:23 上传
下面三个图分别是在windows、msys2、WSL2-Ubuntu-20.04三个系统上的手动调试的过程截图:
不过貌似学习路径应该是先在电脑上学习Rust语法和程序结构,熟悉之后再慢慢渗透到嵌入式编程领域,我这样贸然直接在RISCV芯片上动手写Rust裸机代码,步子跨得有点大,连LED-Blinky点灯程序或者UART输出“HelloWorld”都有点困难;
全志的这颗RISCV64芯片,是这段时间最便宜实惠的RISCV64架构能运行Linux系统的SoC,然后网上有很多利用D1芯片做教学,如“挪威科技大学使用全志D1哪吒开发板开设操作系统课程”,公开课件——Porting the xv6 OS to the Nezha D1 RISC-V Board.pdf;
奋勇而上,得慢慢来,一步一个脚印学习,实现最终目的——将清华大学计算机系本科操作系统课程的rCore移植到D1上;
使用新兴编程语言Rust开发RISCV裸机编程.zip
(1.54 MB, 下载次数: 1)