學號 | GitHub 帳號 | 姓名 | |
---|---|---|---|
0856004 |
calee0219 |
李家安 |
sz110010@gmail.com, calee.cs08@nycu.edu.tw calee.cs08g@nctu.edu.tw |
On Fedora
sudo dnf install -y clang # Using clang as compiler
sudo dnf install -y lld # Using llvm lld as linker
sudo dnf install -y llvm # Using llvm-objcopy as obj file translator
sudo dnf install -y qemu # Using qemu as emulator
sudo dnf install -y make # Using make as make tools
# All in one
make all # or make
# Seperated
make obj # Generate all obj file (.S to .o)
make elf # Generate ELF file (link obj)
make img # copy elf to image file, same as make all
# For optional build
ENV=debug make
LANG=rust make # not implement yet
qemu-system-aarch64 -M raspi3 -kernel ./kernel8.img -display none -serial null -serial stdio
# -M/-machine: Supported machine, here using Raspberry Pi 3B
# -display: display backend type, none, gtk, ...
- Using debug mode when build:
ENV=debug make
- Run
qemu-system-aarch64 -M raspi3 -kernel ./kernel8.img -display none -serial null -serial stdio -s -S
- Run
gdb -x gdbcmd.gdb
dd if=nctuos.img of=/dev/sdc bs=512 # if for input, of for output, bs for block size
cp kernel8.img ${your SD card mount folder} # replace kernel8.elf with your image
UART | RPi |
---|---|
GND | GND / ping 6 |
RXD | UARTD_TXD / ping 8 / GPIO 14 |
TXD | UARTD_RXD / ping 10 / GPIO 15 |
dmesg | grep -i tty # Using dmesg command to check tty
sudo screen /dev/ttyUSB0 115200 # Attach tty using root permission, or screen may terminate
boot.S for sp set, bss clear, then jump to kernel (write by C)
- Folder architecture
/osc2021
├── bootloader [4/2622]
│ ├── include
│ │ ├── mmio.h
│ │ ├── shell.h
│ │ └── util.h
│ ├── linker.lds
│ ├── linker_qemu.lds
│ ├── Makefile
│ └── src
│ ├── bootloader.c
│ ├── boot.S
│ ├── mmio.c
│ ├── shell.c
│ └── util.c
├── LICENSE
├── Makefile
├── Makefile.env
├── Makefile.inc
├── os
│ ├── boot
│ │ └── boot.S
│ ├── kernel
│ │ ├── include
│ │ │ ├── cpio.h
│ │ │ ├── mmio.h
│ │ │ ├── shell.h
│ │ │ └── util.h
│ │ ├── Makefile
│ │ └── src
│ │ ├── cpio.c
│ │ ├── kernel.c
│ │ ├── mmio.c
│ │ ├── shell.c
│ │ └── util.c
│ ├── linker.lds
│ ├── linker_qemu.lds
│ └── Makefile
├── README.md
├── REFERENCE.md
├── setup
│ ├── bootcode.bin
│ ├── config.txt
│ ├── fixup.dat
│ ├── initramfs.cpio
│ ├── kernel8.img
│ └── start.elf
└── tools
├── boot_uart.py
└── gdbcmd.gdb
- File usage
- boot: Files for boot up, runs before kernel
- c-impl: The kernel source code that implement in C language
- include: .h header file
- lib: .c source file, also place object file here after compile
- kernel.c: main process after OS boot up
- rust-impl: The kernel source code that implement in rust language
- *.gdb: gdb helper file
- linker.lds: linker script
- Makefile: makefile for os
- README.md: documentation
- REFERENCE.md: reference link when doing the labs