adding GRUB iso creating and readme
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -69,4 +69,3 @@ modules.order
|
|||||||
Module.symvers
|
Module.symvers
|
||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
|
||||||
|
|||||||
4
scripts/README.md
Normal file
4
scripts/README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Troubleshooting
|
||||||
|
|
||||||
|
# ISO when booted with qemu returns `could not read from cdroom code 0004`
|
||||||
|
Install `grub-pc` on Fedora or `grub-pc-bin` on Ubuntu and run `create_iso.sh` again
|
||||||
25
scripts/create_iso.sh
Executable file
25
scripts/create_iso.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
GRUB_CFG="menuentry \"appa-os\" {
|
||||||
|
multiboot /boot/appa-os.bin
|
||||||
|
}"
|
||||||
|
|
||||||
|
BIN_NAME="appa-os.bin"
|
||||||
|
BIN_PATH="$(find "$(pwd)" -iname "$BIN_NAME" -not -path "$(pwd)/isodir/*")"
|
||||||
|
|
||||||
|
echo "Found BIN at $BIN_PATH"
|
||||||
|
if grub2-file --is-x86-multiboot "$BIN_PATH"; then
|
||||||
|
echo "multiboot confirmed"
|
||||||
|
else
|
||||||
|
echo "the file is not multiboot"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf isodir/
|
||||||
|
mkdir -p isodir/boot/grub
|
||||||
|
echo "$GRUB_CFG" > isodir/boot/grub/grub.cfg
|
||||||
|
cp "$BIN_PATH" isodir/boot/$BIN_NAME
|
||||||
|
|
||||||
|
grub2-mkrescue -o appa-os.iso isodir
|
||||||
@@ -3,11 +3,19 @@
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import sys
|
||||||
|
|
||||||
# Define file path and QEMU command
|
# Define file paths and default QEMU command
|
||||||
file_path = "build/src/kernel/appa-os.bin"
|
bin_file_path = "build/src/kernel/appa-os.bin"
|
||||||
qemu_command = ["qemu-system-i386", "-kernel", file_path]
|
iso_file_path = "appa-os.iso"
|
||||||
|
qemu_command = ["qemu-system-i386"]
|
||||||
|
use_iso = "--iso" in sys.argv
|
||||||
|
|
||||||
|
# Adjust command based on the --iso argument
|
||||||
|
if use_iso:
|
||||||
|
qemu_command += ["-cdrom", iso_file_path]
|
||||||
|
else:
|
||||||
|
qemu_command += ["-kernel", bin_file_path]
|
||||||
|
|
||||||
|
|
||||||
# Function to start QEMU
|
# Function to start QEMU
|
||||||
@@ -18,19 +26,36 @@ def start_qemu():
|
|||||||
|
|
||||||
|
|
||||||
# Function to check if the file has been modified
|
# Function to check if the file has been modified
|
||||||
def has_been_modified(last_mod_time):
|
def has_been_modified(last_mod_time, file_path):
|
||||||
return os.path.getmtime(file_path) > last_mod_time
|
return os.path.getmtime(file_path) > last_mod_time
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# Choose the file path based on --iso flag
|
||||||
|
file_path = iso_file_path if use_iso else bin_file_path
|
||||||
|
|
||||||
|
# Check if the file exists; if not, wait until it becomes available
|
||||||
|
if not os.path.isfile(file_path):
|
||||||
|
print(f"Warning: {file_path} not found. Waiting for the file to be created...")
|
||||||
|
while not os.path.isfile(file_path):
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# Initialize variables
|
# Initialize variables
|
||||||
last_mod_time = os.path.getmtime(file_path)
|
last_mod_time = os.path.getmtime(file_path)
|
||||||
qemu_process = start_qemu()
|
qemu_process = start_qemu()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
# Check if the file exists
|
||||||
|
if not os.path.isfile(file_path):
|
||||||
|
print(f"Warning: {file_path} not found. Terminating QEMU process...")
|
||||||
|
qemu_process.terminate()
|
||||||
|
qemu_process.wait()
|
||||||
|
time.sleep(1)
|
||||||
|
continue
|
||||||
|
|
||||||
# Check for file modification
|
# Check for file modification
|
||||||
if has_been_modified(last_mod_time):
|
if has_been_modified(last_mod_time, file_path):
|
||||||
print("File has been modified. Restarting QEMU...")
|
print("File has been modified. Restarting QEMU...")
|
||||||
last_mod_time = os.path.getmtime(file_path)
|
last_mod_time = os.path.getmtime(file_path)
|
||||||
|
|
||||||
|
|||||||
3
src/kernel/grub.cfg
Normal file
3
src/kernel/grub.cfg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
menuentry "appa-os" {
|
||||||
|
multiboot /boot/appa-os.bin
|
||||||
|
}
|
||||||
@@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
#define APPA_OS_VERSION_MAJOR 0
|
#define APPA_OS_VERSION_MAJOR 0
|
||||||
#define APPA_OS_VERSION_MINOR 0
|
#define APPA_OS_VERSION_MINOR 0
|
||||||
#define APPA_OS_VERSION_PATCH 75
|
#define APPA_OS_VERSION_PATCH 78
|
||||||
#define APPA_OS_COMMIT_HASH cd01d7d8d36862bc00ae88f7cd185c352a7b7eda
|
#define APPA_OS_COMMIT_HASH cd01d7d8d36862bc00ae88f7cd185c352a7b7eda
|
||||||
#define APPA_OS_BUILD_TIMESTAMP 1730492888
|
#define APPA_OS_BUILD_TIMESTAMP 1730637275
|
||||||
|
|
||||||
#endif // INCLUDE_APPA_OS_VERSION_H_
|
#endif // INCLUDE_APPA_OS_VERSION_H_
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
#define LIB_C_VERSION_MAJOR 0
|
#define LIB_C_VERSION_MAJOR 0
|
||||||
#define LIB_C_VERSION_MINOR 0
|
#define LIB_C_VERSION_MINOR 0
|
||||||
#define LIB_C_VERSION_PATCH 87
|
#define LIB_C_VERSION_PATCH 90
|
||||||
#define LIB_C_COMMIT_HASH cd01d7d8d36862bc00ae88f7cd185c352a7b7eda
|
#define LIB_C_COMMIT_HASH cd01d7d8d36862bc00ae88f7cd185c352a7b7eda
|
||||||
#define LIB_C_BUILD_TIMESTAMP 1730492888
|
#define LIB_C_BUILD_TIMESTAMP 1730637275
|
||||||
|
|
||||||
#endif // INCLUDE_LIB_C_VERSION_H_
|
#endif // INCLUDE_LIB_C_VERSION_H_
|
||||||
|
|
||||||
|
|||||||
@@ -3,25 +3,29 @@
|
|||||||
## Install dependencies
|
## Install dependencies
|
||||||
|
|
||||||
### Ubuntu/Debian
|
### Ubuntu/Debian
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt install build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo libisl-dev gcc-multilib
|
sudo apt install build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo libisl-dev gcc-multilib
|
||||||
```
|
```
|
||||||
|
|
||||||
### Fedora
|
### Fedora
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo dnf install gcc gcc-c++ make bison flex gmp-devel libmpc-devel mpfr-devel texinfo isl-devel
|
sudo dnf install gcc gcc-c++ make bison flex gmp-devel libmpc-devel mpfr-devel texinfo isl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Others
|
### Others
|
||||||
|
|
||||||
For others please check [OSDev Wiki Installing Dependencies](https://wiki.osdev.org/GCC_Cross-Compiler#Installing_Dependencies) section
|
For others please check [OSDev Wiki Installing Dependencies](https://wiki.osdev.org/GCC_Cross-Compiler#Installing_Dependencies) section
|
||||||
|
|
||||||
|
|
||||||
## Compile
|
## Compile
|
||||||
> This is compilling `GCC` version `14.x` and `binutils` version `2.43.x`, make sure your OS gcc and binutils are the same major version!
|
|
||||||
|
|
||||||
|
> This is compiling `GCC` version `14.x` and `binutils` version `2.43.x`, make sure your OS gcc and binutils are the same major version!
|
||||||
|
|
||||||
### Setting up the environment
|
### Setting up the environment
|
||||||
|
|
||||||
First, create the prefix folder, from your project folder execute
|
First, create the prefix folder, from your project folder execute
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir $(pwd)/toolchain/
|
mkdir $(pwd)/toolchain/
|
||||||
export PREFIX="$(pwd)/toolchain/"
|
export PREFIX="$(pwd)/toolchain/"
|
||||||
@@ -29,11 +33,15 @@ export PATH="$PREFIX/bin:$PATH"
|
|||||||
```
|
```
|
||||||
|
|
||||||
Set the target to be a i686
|
Set the target to be a i686
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export TARGET=i686-elf
|
export TARGET=i686-elf
|
||||||
```
|
```
|
||||||
|
|
||||||
### Building `binutils`
|
### Building `binutils`
|
||||||
|
|
||||||
From your project folder execute:
|
From your project folder execute:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir -p tools/build/build-binutils
|
mkdir -p tools/build/build-binutils
|
||||||
cd tools/build/build-binutils
|
cd tools/build/build-binutils
|
||||||
@@ -45,7 +53,9 @@ make install
|
|||||||
To check what each flag does consult [OSDev Wiki](https://wiki.osdev.org/GCC_Cross-Compiler#Binutils)
|
To check what each flag does consult [OSDev Wiki](https://wiki.osdev.org/GCC_Cross-Compiler#Binutils)
|
||||||
|
|
||||||
### Build `GCC`
|
### Build `GCC`
|
||||||
|
|
||||||
First, check if `binutils` is reachable from within `$PATH`
|
First, check if `binutils` is reachable from within `$PATH`
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
which i686-elf-ld | grep $PREFIX -q && echo "Found i686-elf-ld" || echo "NOT found i686-elf-ld"
|
which i686-elf-ld | grep $PREFIX -q && echo "Found i686-elf-ld" || echo "NOT found i686-elf-ld"
|
||||||
```
|
```
|
||||||
@@ -53,6 +63,7 @@ which i686-elf-ld | grep $PREFIX -q && echo "Found i686-elf-ld" || echo "NOT fou
|
|||||||
If you see `Found i686-elf-ld` you are good to got, if not you have made some mistake on the steps above.
|
If you see `Found i686-elf-ld` you are good to got, if not you have made some mistake on the steps above.
|
||||||
|
|
||||||
Now, compile `GCC` and `libgcc`. From your project folder execute:
|
Now, compile `GCC` and `libgcc`. From your project folder execute:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir -p tools/build/build-gcc
|
mkdir -p tools/build/build-gcc
|
||||||
cd build-gcc
|
cd build-gcc
|
||||||
@@ -63,8 +74,8 @@ make install-gcc
|
|||||||
make install-target-libgcc
|
make install-target-libgcc
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Finals
|
## Finals
|
||||||
|
|
||||||
Once everything is compile you should have some binaries inside `$PREFIX/bin`, mainly `i686-elf-gcc`, `i686-elf-ld`, `i686-elf-gdb`, `i686-elf-as` and `i686-elf-g++`.
|
Once everything is compile you should have some binaries inside `$PREFIX/bin`, mainly `i686-elf-gcc`, `i686-elf-ld`, `i686-elf-gdb`, `i686-elf-as` and `i686-elf-g++`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
Reference in New Issue
Block a user