diff --git a/Makefile b/Makefile index 7c9ee57..3b153fc 100644 --- a/Makefile +++ b/Makefile @@ -231,13 +231,14 @@ fs: $(UPROGS) sudo cp $$file $(dst)/bin/$${file#$U/_}; done @sudo umount $(dst) -# Write sdcard -sdcard: fs - @if [ "$(sd)" != "" ]; then \ - echo "flashing into sd card..."; \ - sudo dd if=fs.img of=$(sd); \ - else \ - echo "sd card not detected!"; fi +# Write mounted sdcard +sdcard: userprogs + @if [ ! -d "$(dst)/bin" ]; then sudo mkdir $(dst)/bin; fi + @for file in $$( ls $U/_* ); do \ + sudo cp $$file $(dst)/bin/$${file#$U/_}; done + @sudo cp $U/_init $(dst)/init + @sudo cp $U/_sh $(dst)/sh + @sudo cp README $(dst)/README clean: rm -f *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \ diff --git a/README.md b/README.md index 7d392c6..4e1803f 100644 --- a/README.md +++ b/README.md @@ -24,36 +24,31 @@ Run xv6-riscv on k210 board git clone https://github.com/HUST-OS/xv6-k210 ``` -## Build +## Run on k210 board First you need to connect your k210 board to your PC. -And check the `USB serial port`: +And check the `USB serial port` (In my situation it will be `ttyUSB0`): ```bash ls /dev/ | grep USB ``` -In my situation it will be `ttyUSB0` +Build the kernel and user program: ```bash cd xv6-k210 make build ``` - -## Run on k210 board Instead of the original file system, xv6-k210 runs with FAT32. You might need an SD card with FAT32 format. -To start `shell`, you need to rename the "_init" and "_sh" in the "/xv6-user" to "init" and "sh" after building, -then copy them to the root of your SD card. -Also, you can copy other programs start with "\_". -Or you can directly run the command as below with your SD card connected to your PC (SD card reader required). - -Warning: this will format your SD card and clean your original data! +Your SD card should NOT keep a partition table. To start `shell` and other user programs, you need to copy them into your SD card. +First, connect and mount your SD card (SD card reader required). ```bash -make sdcard sd="your SD card device's path" +ls /dev/ # To check your SD device +mount +make sdcard dst="SD card mount point" +umount ``` - -To run on k210: +Then, insert the SD card to your k210 board and run: ```bash make run ``` - Sometimes you should change the `USB serial port`: ```bash make run k210-serialport=`Your-USB-port`(default by ttyUSB0) diff --git a/README_cn.md b/README_cn.md index 30c6f59..6ed9df2 100644 --- a/README_cn.md +++ b/README_cn.md @@ -24,30 +24,29 @@ git clone https://github.com/HUST-OS/xv6-k210 ``` -## 编译 +## 在 k210 开发板上运行 首先您需要连接 `k210` 开发板到电脑,然后检查 USB 端口: ```bash ls /dev/ | grep USB ``` 在我的机器上的情况是将会显示 `ttyUSB0`,这就是 USB 端口。 -然后运行以下命令: +然后运行以下命令,以编译内核和用户程序: ```bash cd xv6-k210 make build ``` -## 在 k210 开发板上运行 -Xv6-k210 采用 FAT32 文件系统,而不是其原本的文件系统。您需要一张 FAT32 格式的 SD 卡才能运行。 -在编译项目后,您需要将 “/xv6-user” 目录下的 “_init” 和 “_sh” 重命名为 “init” 和 “sh”,并拷贝至 SD 卡的根目录下。您还可以拷贝其他编译好的程序(以“\_”开头的文件)。 -或者,您可以将 SD 卡连至主机(需要读卡器),再直接运行以下命令。 - -警告:这会格式化您的 SD 卡并清除卡上的原有数据! +Xv6-k210 采用 FAT32 文件系统,而不是其原本的文件系统。您需要一张 FAT32 格式的 SD 卡才能运行。并且 SD 卡上不能有分区表。 +为了能启动 `shell` 和其他用户程序,您需要将它们拷贝至 SD 卡中。 +首先,需要将 SD 卡连至主机(需要读卡器)并进行挂载。 ```bash -make sdcard sd="your SD card device's path" +ls /dev/ # 确认您的 SD 卡设备名 +mount <挂载点> +make sdcard dst="挂载点" +umount <挂载点> ``` - -运行以下命令以在 `k210` 上运行: +然后,将 SD 卡接入 `k210` 并运行: ```bash make run ``` @@ -117,5 +116,5 @@ Shell 命令其实也是用户程序。这些程序应当放置在 SD 卡或 `fs - [X] 稳定的键盘输入(k210) ## TODO -解决用户态导致 RUSTSBI 报 panic 的 bug +解决用户态由于未知原因导致 panic 的 bug