Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
CROSS ?= riscv64-unknown-elf
# Default cross-compiler prefix. We prefer `riscv64-elf-` because that's
# what the mainstream bare-metal toolchain (xpack-riscv-none-elf-gcc,
# riscv-collaborations/riscv-gnu-toolchain) installs on most distros.
#
# If you have the `riscv64-unknown-elf-` variant instead (Debian's
# `gcc-riscv64-unknown-elf` package), override with:
# make CROSS=riscv64-unknown-elf
#
# If you have the Linux-targeted `riscv64-linux-gnu-` (Arch's
# `riscv64-linux-gnu-gcc`), bare-metal OnyxBoot won't link correctly —
# install a bare-metal variant instead.
CROSS ?= riscv64-elf
CC = $(CROSS)-gcc
OBJCOPY = $(CROSS)-objcopy

Expand All @@ -16,18 +27,18 @@ SRCS = src/boot_entry.c src/boot_main.c src/string.c fs/fat.c fs/ext4.c
all: bootloader.bin

bootloader.elf: $(SRCS)
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

bootloader.bin: bootloader.elf
$(OBJCOPY) -O binary $< $@
$(OBJCOPY) -O binary $< $@

clean:
rm -f bootloader.elf bootloader.bin
rm -f bootloader.elf bootloader.bin

test:
./test/run_qemu.sh
./test/run_qemu.sh
Comment on lines +30 to +39

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Use real tab characters for Make recipes instead of spaces to avoid make errors.

The recipe lines for bootloader.elf, bootloader.bin, clean, test, and test-all are now indented with spaces instead of a literal tab, which will trigger missing separator errors in many make implementations and break the build. Please change these indentations back to actual tab characters to keep the Makefile functional.


test-all:
./test/test_all.sh
./test/test_all.sh

.PHONY: all clean test test-all
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ First-stage loader for [OnyxOS](https://github.com/anomalyco/OnyxOS).
## Quick start

```console
$ make CROSS=riscv64-elf
$ make # default: CROSS=riscv64-elf
$ qemu-system-riscv64 -M virt -m 256M -bios bootloader.bin \
-drive file=disk.img,format=raw,if=none,id=drive0 \
-device virtio-blk-device,drive=drive0 \
Expand All @@ -67,17 +67,22 @@ $ bash test/run_qemu.sh

| Tool | Purpose |
|------|---------|
| `riscv64-elf-g++` or `riscv64-unknown-elf-g++` | Cross-compiler |
| `riscv64-elf-g++` (preferred) or `riscv64-unknown-elf-g++` | Cross-compiler |
| `riscv64-elf-objcopy` | Binary extraction |
| `make` | Build |
| `qemu-system-riscv64` | Test (optional) |

Override toolchain:
Override toolchain (if you have the `riscv64-unknown-elf-` variant):

```console
make CROSS=riscv64-unknown-elf
```

The Makefile's default is `CROSS ?= riscv64-elf` — this matches the
mainstream bare-metal toolchain (xpack-riscv-none-elf-gcc, RISC-V
collaborations/riscv-gnu-toolchain). If you have Debian's
`gcc-riscv64-unknown-elf` package instead, override as shown above.

----

## How it works
Expand Down
11 changes: 8 additions & 3 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OnyxBoot - крошечный bare-metal загрузчик для RISC-V 64-bit
## Быстрый старт

```console
$ make CROSS=riscv64-elf
$ make # по умолчанию CROSS=riscv64-elf
$ qemu-system-riscv64 -M virt -m 256M -bios bootloader.bin \
-drive file=disk.img,format=raw,if=none,id=drive0 \
-device virtio-blk-device,drive=drive0 \
Expand All @@ -41,17 +41,22 @@ $ bash test/run_qemu.sh

| Инструмент | Назначение |
|-----------|-----------|
| `riscv64-elf-g++` или `riscv64-unknown-elf-g++` | Кросс-компилятор |
| `riscv64-elf-g++` (предпочтительно) или `riscv64-unknown-elf-g++` | Кросс-компилятор |
| `riscv64-elf-objcopy` | Извлечение бинарника |
| `make` | Сборка |
| `qemu-system-riscv64` | Тестирование (опционально) |

Сменить тулчейн:
Сменить тулчейн (если у вас вариант `riscv64-unknown-elf-`):

```console
make CROSS=riscv64-unknown-elf
```

В Makefile по умолчанию `CROSS ?= riscv64-elf` — это соответствует
основному bare-metal тулчейну (xpack-riscv-none-elf-gcc, RISC-V
collaborations/riscv-gnu-toolchain). Если у вас установлен Debian-пакет
`gcc-riscv64-unknown-elf`, переопределите как показано выше.

----

## Как это работает
Expand Down
Loading