-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rCore-Tutorial-Book-v3/chapter1/4first-instruction-in-kernel2 #96
Comments
虽然老师提供了连接脚本,但是该怎么获知写的程序都有哪些段需要被链接呢? |
开篇提供的 vm 镜像似乎并没安装 objcopy,需要使用如下语句来安装 |
回翻了一下开篇,发现原来是自己漏掉工具链安装那一步了 ORZ |
请问 这里的 0x100c: ld t0,24(t0) 。 ld是什么意思? |
代表是 load 指令 |
那请问 load指令 是指 汇编指令吗? |
请问 ld t0,24(t0) 这个是什么意思呢? |
请问一下为什么在终端输入cargo build后会遇到这种问题呢,把main.rs中的use core::arch::global_asm换成use core::global_asm还是不行,下面的github链接有没有找到方案 error[E0432]: unresolved import error: aborting due to 2 previous errors Some errors have detailed explanations: E0432, E0658. To learn more, run the command again with --verbose. |
@lu-yidan 请将Rust升级到最新版本,可以在 |
虚拟磁盘文件未安装riscv64-unknown-elf-gdb,该怎么安装呢? |
关于执行riscv64-unknown-elf-gdb后
```
riscv64-unknown-elf-gdb: command not found
```
gdb工具链下载链接已在开发环境配置中,我将其下载解压在目录:
/home/oslab/.riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/
具体目录根据你的情况而定
对于gdb这样一个可执行二进制文件,如何将其路径添加直环境变量中呢?
终端中输入
``````
gedit .bashrc
``````
添加一行
```
export PATH=$PATH:/home/oslab/.riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/bin
```
大功告成,这样就可以直接使用该命令啦
…------------------ 原始邮件 ------------------
发件人: ***@***.***>;
发送时间: 2022年1月16日(星期天) 晚上8:05
收件人: ***@***.***>;
抄送: ***@***.***>; ***@***.***>;
主题: Re: [rcore-os/rCore-Tutorial-Book-v3] rCore-Tutorial-Book-v3/chapter1/4first-instruction-in-kernel2 (Issue #96)
虚拟磁盘文件未安装riscv64-unknown-elf-gdb,该怎么安装呢?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
关于内核的加载这里有一个疑问,如果说按照这里内核是直接进行从文件中进行拷贝过去,那么是否会出现文件中相应片段大小小于实际在内存中占用大小的情况?(因为传统elf文件是有可能出现片段在文件中占用大小小于实际内存中大小的) |
@ZENOTME 据我所知,这种情况一般只出现在零初始化的 |
根据文档riscv-spec-20191213.pdf中Ch2和Ch25 注意这里寄存器的名字, |
@konpoe 很棒!大体上正确,帮你修改了一下格式。有一个问题是 |
谢谢指正 |
我仔细检查了一下,ld加载双字(8字节),所以$a1 应该是[8bytes@0x1020]后面的t0应该是[8bytes@0x1018]。 |
弱弱问一下,为什么我使用objcopy strip之后的文件为什么会是0size呢……Orz? llvm-objcopy --strip-all target/riscv64gc-unknown-none-elf/release/os -O binary target/riscv64gc-unknown-none-elf/release/os.bin stat /home/senki/Documents/xv6-rust/os/target/riscv64gc-unknown-none-elf/release/os.bin 我使用rust-objcopy无法运行,所以使用了llvm-objcopy(虽然说cargo-binutils也只是对这些工具做了封装)。 |
但是生成的os文件 大小是正常的(1000左右) |
我搞清楚了!原来是: 12行与13行没有缩进(我以为不缩进功能也是一样的) |
演示代码
应该是五次si后才能得到
实机演示:
|
Mac OS 执行 riscv64-unknown-elf-gdb 命令报:
解决办法:
|
@lu-yidan 的方法有用,不过得注意: |
关于riscv64-unknown-elf-gdb,对于我而言除了@lu-yidan 的方法,还要对riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14 chmod -R 777 一下 |
麻烦请问启动 Qemu 并加载 RustSBI 和内核镜像出现以下报错可能是什么原因呢? qemu-system-riscv64 \
|
可能是目录下没有bootloader文件,可以从ch1分支的代码中复制一份 |
ch1 ..为什么我没看到有 ch1 的分支。。 |
原来我down错仓库了。。把 python 文档的那个仓库下载了。。。抱歉,找到了 |
为什么我的是 $ stat target/riscv64gc-unknown-none-elf/release/os
File: target/riscv64gc-unknown-none-elf/release/os
Size: 5240 Blocks: 16 IO Block: 4096 regular file
Device: a5h/165d Inode: 1187295 Links: 2
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2022-03-28 13:02:28.913213000 +0000
Modify: 2022-03-27 15:00:03.103959000 +0000
Change: 2022-03-27 15:00:03.112959000 +0000
Birth: -
|
wsl2环境遇到riscv64-unknown-elf-gdb缺失问题,可以按如下方法解决,具体思路是下载与编译工具链,并添加到环境变量中。 # 下载预编译文件
wget https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz 后面是解压和添加环境变量,最后需要 |
我在gdb-py加载dashboard的时候遇到了这个问题 ➜ bin riscv64-unknown-elf-gdb-py --batch -ex 'python import sys; print(sys.version)'
Traceback (most recent call last):
File "<string>", line 33, in <module>
ImportError: /home/****/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/python/lib/python3.7/lib-dynload/math.cpython-37m-x86_64-linux-gnu.so: undefined symbol: PyFloat_Type
/home/****/.gdbinit:2318: Error in sourced command file:
Error while executing Python code.
3.7.7 (default, Jul 6 2020, 09:36:26)
[GCC 5.4.0 20160609] |
ubuntu 下 riscv64-unknown-elf-gdb 可以用 gdb-multiarch 代替 |
还没有遇到
获取 Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
发件人: LeezHua ***@***.***>
发送时间: Thursday, January 12, 2023 2:14:23 PM
收件人: rcore-os/rCore-Tutorial-Book-v3 ***@***.***>
抄送: yangyue-1993 ***@***.***>; Mention ***@***.***>
主题: Re: [rcore-os/rCore-Tutorial-Book-v3] rCore-Tutorial-Book-v3/chapter1/4first-instruction-in-kernel2 (Issue #96)
ubuntu 下 riscv64-unknown-elf-gdb 可以用 gdb-multiarch 代替
―
Reply to this email directly, view it on GitHub<#96 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AQDJMMNQBZ32NOLENZHFSUDWR6OL7ANCNFSM5LJLZTAQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
哦哦,谢谢!
…---Original---
From: ***@***.***>
Date: Thu, Jan 12, 2023 14:14 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [rcore-os/rCore-Tutorial-Book-v3]rCore-Tutorial-Book-v3/chapter1/4first-instruction-in-kernel2 (Issue #96)
ubuntu 下 riscv64-unknown-elf-gdb 可以用 gdb-multiarch 代替
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
wsl2 ubuntu 22.04 配置了gdb调试环境以后, 当启动qemu `qemu-system-riscv64 \
The target architecture is set to "riscv:rv64". |
@fengyeall111 也许是qemu没有在1234端口?我在直接使用文档中的qemu指令启动qemu时,默认监听的端口不是1234。-s 选项换成
能指定1234端口,其他不变,gdb在1234端口能够连接上 |
给 |
大哥大姐萌,我没有../bootloader/rustsbi-qemu.bin",我该去哪找啊, |
也可以用 vscode 直接连接查看 ,这个配置: {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "rcore-os",
"type": "cppdbg",
"request": "launch",
"program": "/home/hn/code/rCore-Tutorial-v3/os/target/riscv64gc-unknown-none-elf/debug/os",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/riscv64-unknown-elf-gdb", //riscv64-unknown-elf-gdb 位置
"miDebuggerServerAddress": "localhost:1234" // gdb server 地址
}
]
} |
能夠使用以下指令進行連接,使用起來挺方便的 |
Instead of copying the boot loader directory, how can I create my very own boot loader from the rustSBI repository? |
关于调整内核的内存布局,补充一下:
可以看到这并不符合QEMU的内存布局,因此需要我们手动调整内存布局,使用链接脚本后再查看: target/riscv64gc-unknown-none-elf/release/os: file format elf64-littleriscv
Sections:
Idx Name Size VMA Type
0 00000000 0000000000000000
1 .text 00000004 0000000080200000 TEXT
2 .bss 00000000 0000000080201000 BSS
3 .riscv.attributes 00000035 0000000000000000
4 .comment 00000013 0000000000000000
5 .symtab 00000168 0000000000000000
6 .shstrtab 00000041 0000000000000000
7 .strtab 0000007b 0000000000000000
Disassembly of section .text:
0000000080200000 <stext>:
80200000: 93 00 40 06 li ra, 100 |
config文件中的首行 // os/.cargo/config 是不是应该改为 # os/.cargo/config ,使用WSL我改为#才能编译通过 |
ld to 24(t0),这是一条M指令, 从内存中取数存如寄存器, 这里表达将 t0 储存的地址偏移24后的地址储存的数据储存至t0寄存器 |
之前不太理解为什么会有短跳转,长跳转这类的概念,看了绝对地址和相对地址的分析,终于明白了 |
ArchLinux 执行 riscv64-unknown-elf-gdb: command not found 解决办法:安装 RISC-V 工具集 $ git clone https://github.com/riscv/riscv-gnu-toolchain
$ cd riscv-gnu-toolchain
# /home/kay/tools/riscv-gnu-toolchain 为安装目录
$ ./configure --prefix=/home/kay/tools/riscv-gnu-toolchain
# riscv-gnu-toolchain 目录下
$ make
$ make install clean
# 添加环境变量
# 编辑 .bashrc 文件,添加:
export PATH=/home/kay/tools/riscv-gnu-toolchain/bin:$PATH
# 刷新
$ source ./.bashrc |
已解决,感谢。<br/><br/><br/><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="ntes-mailmaster-quote" style="padding-top: 1px; padding-bottom: 1px" >
<div style=" margin-top: 20px; margin-bottom: 12px; font-size: 14px; line-height: 1.25; color: #89898c; " >---- 回复的原邮件 ----</div>
<div style=" margin-bottom: 12px; font-size: 13px; line-height: 1.25; color: #2c2c2e; padding: 2px; border-radius: 8px; background-color: #f0f0f0; " >
<table width="100%" cellpadding="0" cellspacing="10" border="0">
<tr>
<td valign="top" style=" width: 4em; font-size: 13px; line-height: 1.25; color: #89898c; white-space: nowrap; " >发件人</td>
<td valign="top" style=" font-size: 13px; line-height: 1.25; color: #2c2c2e; word-break: break-all; " ><a class="mail-from" style="color: #1c83eb; text-decoration: none" ***@***.***" >***@***.***></a></td>
</tr>
<tr>
<td valign="top" style=" width: 4em; font-size: 13px; line-height: 1.25; color: #89898c; white-space: nowrap; " >日期</td>
<td class="mail-date" valign="top" style=" font-size: 13px; line-height: 1.25; color: #2c2c2e; word-break: break-all; " >2023年12月18日 16:20</td>
</tr>
<tr style="">
<td valign="top" style=" width: 4em; font-size: 13px; line-height: 1.25; color: #89898c; " >收件人</td>
<td valign="top" style=" font-size: 13px; line-height: 1.25; color: #2c2c2e; word-break: break-all; " ><a class="mail-to" style="color: #1c83eb; text-decoration: none" ***@***.***" >***@***.***></a></td>
</tr>
<tr style="">
<td valign="top" style=" width: 4em; font-size: 13px; line-height: 1.25; color: #89898c; " >抄送至</td>
<td valign="top" style=" font-size: 13px; line-height: 1.25; color: #2c2c2e; word-break: break-all; " ><a class="mail-cc" style="color: #1c83eb; text-decoration: none" ***@***.***" >***@***.***></a>、<a class="mail-cc" style="color: #1c83eb; text-decoration: none" ***@***.***" >***@***.***></a></td>
</tr>
<tr>
<td valign="top" style=" width: 4em; font-size: 13px; line-height: 1.25; color: #89898c; " >主题</td>
<td class="mail-subject" valign="top" style=" font-size: 13px; line-height: 1.25; color: #2c2c2e; word-break: break-all; " >Re: [rcore-os/rCore-Tutorial-Book-v3] rCore-Tutorial-Book-v3/chapter1/4first-instruction-in-kernel2 (Issue #96)</td>
</tr>
</table>
</div>
<div><p></p>
<p dir="auto">不好意思。。。是qemu版本问题,这个开发机镜像自带了个qemu...</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="#96 (comment)">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/A724RMPNRHOEOUP3VTZWGK3YJ74GHAVCNFSM5LJLZTA2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBVHE3TKMZRGU3Q">unsubscribe</a>.<br />You are receiving this because you commented.<img src="https://github.com/notifications/beacon/A724RMIZ5VZISC4FCTQT763YJ74GHA5CNFSM5LJLZTA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGON3MZJRI.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><rcore-os/rCore-Tutorial-Book-v3/issues/96/1859753157</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
***@***.***": "http://schema.org",
***@***.***": "EmailMessage",
"potentialAction": {
***@***.***": "ViewAction",
"target": "#96 (comment)",
"url": "#96 (comment)",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
***@***.***": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script></div>
</div>
</body>
</html>
|
一直卡在这个地方是什么原因导致的?无法跳转到0x80200000断点地址。 |
我在单步调试时得到的结果如下:(地址在单步执行5次后跳转) |
使用main分支下bootloader下的rustsbi-qemu.bin 可以解决。 一直卡住,不运行的问题 |
我与main分支下的rustsbi-qemu.bin是一样的,且切到main分支也测试过。还是一样的问题 |
@1059915154 你从github上下一个新的下来试试, 我就是下的新的替换了, 可以的。 大小是32Kb |
试了一下,链接器脚本可以改成这样
} |
有个困惑,既然链接脚本已经指定好0x80200000的地址,那为什么在没有做strip的时候,那些元数据会导致第一条指令会从0x80200000的地方被挤走呢?难道说,RustSBI无法从.bin文件的信息中,聪明地跳过“元数据”,直接把entry代码拷贝到0x80200000的位置上? |
脑袋看炸了 |
“有个困惑,既然链接脚本已经指定好0x80200000的地址,那为什么在没有做strip的时候,那些元数据会导致第一条指令会从0x80200000的地方被挤走呢?难道说,RustSBI无法从.bin文件的信息中,聪明地跳过“元数据”,直接把entry代码拷贝到0x80200000的位置上?” rustSBI加载不会解析elf格式,而且也不确定你的bin文件是否不是其他格式,如果解析,那RustSBI的代码量会增加,所以最简单的方式就是直接当成裸指令格式,直接jmp到那个地址。 你只需要将你要执行的第一条直连放在那个位置即可 |
|
I've received your message, and will respond as soon as possible.
|
内核第一条指令(实践篇) — rCore-Tutorial-Book-v3 3.6.0-alpha.1 文档
https://rcore-os.github.io/rCore-Tutorial-Book-v3/chapter1/4first-instruction-in-kernel2.html
The text was updated successfully, but these errors were encountered: