运行环境
Ubuntu 20.04.5 LTS
实验记录
一、安装依赖
-
更新apt源
apt update
-
安装编译C程序必需的依赖
apt install gcc bison flex
-
下载gcc-arm-none-eabi
可以去官网下载,或者点击链接下载。
将下载好的gcc-arm-none-eabi通过sftp发送到服务器上。
-
将gcc-arm-none-eabi解压:
sudo tar xjf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 -C /usr/share/
-
为解压好的gcc-arm-none-eabi创建如下软链接:
-
arm-none-eabi-gcc
sudo ln -s /usr/share/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc
-
arm-none-eabi-g++
sudo ln -s /usr/share/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-g++ /usr/bin/arm-none-eabi-g++
-
arm-none-eabi-gdb
sudo ln -s /usr/share/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb /usr/bin/arm-none-eabi-gdb
-
arm-none-eabi-size
sudo ln -s /usr/share/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-size /usr/bin/arm-none-eabi-size
-
arm-none-eabi-objcopy
sudo ln -s /usr/share/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy /usr/bin/arm-none-eabi-objcopy
-
-
安装依赖项libncurses-dev
sudo apt install libncurses-dev
-
创建软链接
-
检查一下arm-none-eabi的安装情况:
arm-none-eabi-gcc --version arm-none-eabi-g++ --version arm-none-eabi-gdb --version arm-none-eabi-size --version
二、运行Xinu
-
从github上clone源码:
git clone https://github.com/xinu-os/xinu
-
修改/xinu/compile/Makefile,将第27行出修改为(解决编译器 undefined
reference to __stack_chk_fail 报错):
CFLAGS := -fno-stack-protector
-
在xinu/compile/platforms/x86/platformVars,在13行插入(修正64位环境下的链接问题):
LDFLAGS += -melf_i386
-
编辑xinu/loader/platforms/x86/start.S文件,将文件修改为如下:
/** * @file start.S * */ /* Embedded XINU, Copyright (C) 2007. .text All rights reserved. */ .align 4 .globl _start .extern startup .extern _end +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 +#define MULTIBOOT_HEADER_FLAGS 0x00000003 _start: /* disable any interrupts from coming in */ cli @@ -22,3 +24,9 @@ _start: movl %eax, %esp # set stack pointer jmp startup + + /* Enable multiboot support */ +.align 4 +.long MULTIBOOT_HEADER_MAGIC +.long MULTIBOOT_HEADER_FLAGS +.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
-
修改完成后进入compile执行make命令
-
使用apt安装qemu-system-x86:
apt install qemu-system-x86
-
在compile目录下执行如下命令即可启动xinu:
qemu-system-i386 -kernel xinu.elf -nographic