Skip to content

Commit abb3a72

Browse files
committed
update(README)
Signed-off-by: aLinChe <1129332011@qq.com>
1 parent f553117 commit abb3a72

3 files changed

Lines changed: 19 additions & 12 deletions

File tree

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 用户指定的架构,默认使用 `x86_64`,可选 `x86_64`,`arm64`
2-
ARCH ?= arm64
2+
ARCH ?= x86_64
33
VALID_ARCHS := x86_64 arm64
44
ifneq ($(filter $(ARCH),$(VALID_ARCHS)),)
55
ARCH := $(ARCH)
@@ -39,7 +39,7 @@ endif
3939
DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJ_DIR)/$*.d
4040

4141
# 路径配置
42-
BIN := bin
42+
BINARY := bin
4343
SRC_DIR := usr-code
4444
BIN_DIR := rootfs/bin
4545
OBJ_DIR := usr-code/obj
@@ -91,7 +91,7 @@ $(addprefix build-,$(PROJECTS)): build-%:
9191
initramfs: $(TARGET)
9292
@echo "===== 生成 initramfs (ARCH=$(ARCH)) ====="
9393
@mkdir -p $(BUILD_DIR) initramfs/bin
94-
@cp $(BIN)/busybox/busybox-$(ARCH) initramfs/bin/busybox
94+
@cp $(BINARY)/busybox/busybox-$(ARCH) initramfs/bin/busybox
9595
cd initramfs && find . -print0 | cpio --null -ov --format=newc | gzip -9 \
9696
> ../$(BUILD_DIR)/initramfs.cpio.gz
9797
@echo "===== initramfs 已成功生成至 $(BUILD_DIR)/initramfs.cpio.gz ====="
@@ -118,14 +118,14 @@ run-bridge:
118118
echo "[SUCCESS] 网桥 br0 创建成功"; \
119119
sleep 3; \
120120
fi
121-
sudo sh -c "bash ./tools/run-qemu.sh --display nographic --bios legacy --bridge --ext4"
121+
sudo sh -c "bash ./tools/run-qemu.sh --arch $(ARCH) --display nographic --bios legacy --bridge --ext4"
122122

123123
# # sudo ln ~/linux/vmlinuz_debug ~/path/to/Linux-minimal/bin/vmlinuz/vmlinuz_my4debug-ln
124124
# gdb bin/vmlinuz/vmlinuz_my4debug-ln -ex 'target remote localhost:1234'
125125
# (gdb) info r # CPU RESET
126126
# (gdb) b *0x1000000
127127
debug:
128-
sh -c "bash ./tools/run-qemu.sh --display nographic --ext4 --debug"
128+
sh -c "bash ./tools/run-qemu.sh --arch $(ARCH) --display nographic --ext4 --debug"
129129

130130
bridge:
131131
sudo ./tools/bridge-setup.sh
@@ -148,7 +148,7 @@ clean:
148148
@echo "===== 清理完成 ====="
149149

150150
info:
151-
@echo "当前架构: $(ARCH)"
151+
@echo "当前架构: $(ARCH)"
152152
@echo "当前shell: $(MYSHELL_SRC_DIR)"
153153

154154
help:
@@ -162,4 +162,5 @@ help:
162162
@echo " make run-nographic 启动 QEMU (无图形界面)"
163163
@echo " make run-bridge 检测并创建 br0 网桥后启动 QEMU"
164164
@echo " make debug 启动 QEMU 内核调试模式"
165-
@echo " make clean 清理构建文件"
165+
@echo " make clean 清理构建文件"
166+
@echo " make ARCH=arm64 build && make ARCH=arm64 run-nographic 手动指定架构"

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Linux-minimal && myshell
2+
3+
用于教学或实验的**极简Linux系统****自定义Shell**开发环境。提供了完整的构建系统,使用 `QEMU` 进行虚拟仿真 `x86_64``arm64` 架构的Linux系统。
4+
25
### How to use?
36
```bash
47
make help # 查看所有可用命令
5-
make build # 编译并打包项目
6-
make run-nographic # 以无图形化模式运行打包文件
7-
# make run # 以图形化模式运行
8+
make build # 使用默认配置(`ARCH=x86_64`, `MYSHELL=myshell-cpp`)编译构建项目
9+
make run-nographic # 以无图形化模式运行系统(会把所有在 rootfs/ 中的文件拷贝到磁盘 `build/disk.img` 里)
10+
make run # 以图形化模式运行
11+
make debug # 启动QEMU并等待GDB连接,用于Linux内核调试
12+
make run-bridge # 不使用默认的USER网络模式,而是创建网桥供QEMU使用
13+
make clean # 清除所有构建产物
814
```
915
> This will compile the project and launch QEMU for simulation.
1016
> For more details, you can type `make help` or refer to the `Makefile`.

tools/run-qemu.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ APPEND_PARAMS=""
55
CMDLINE=""
66

77
QEMU_DEVICES=""
8-
QEMU_DISK_IMAGE="build/rootfs.img"
8+
QEMU_DISK_IMAGE="build/disk.img"
99
QEMU_SMP="2,cores=2,threads=1,sockets=1"
1010
QEMU_MEMORY="256M"
1111
QEMU_ARGUMENT=" -smp ${QEMU_SMP} -m ${QEMU_MEMORY} "
@@ -94,7 +94,7 @@ while true; do
9494
done
9595

9696
if [ -z ${ARCH}]; then
97-
echo "Error Not Found ARCH. please add --arch [option]"
97+
echo "[Error] Not Found ARCH. please add --arch [option]"
9898
exit 1
9999
fi
100100

0 commit comments

Comments
 (0)